v1.11.0: ROOT_PATH
This commit is contained in:
parent
066d72b153
commit
c99c897561
11 changed files with 1194 additions and 39 deletions
|
@ -18,6 +18,9 @@ To create a simple place for your entire family to use to find gifts that people
|
||||||
## Amazon Smile
|
## Amazon Smile
|
||||||
By default, Christmas Community converts www.amazon.com links to smile.amazon.com. If you do not want this, set the environment variable SMILE to false (if you are using Docker Compose, make sure to put "false" in quotes).
|
By default, Christmas Community converts www.amazon.com links to smile.amazon.com. If you do not want this, set the environment variable SMILE to false (if you are using Docker Compose, make sure to put "false" in quotes).
|
||||||
|
|
||||||
|
## Root Path
|
||||||
|
If you want put Christmas Community on a subdirectory, such as `/christmas-community`, set `ROOT_PATH` to that path.
|
||||||
|
|
||||||
## Docker
|
## Docker
|
||||||
```
|
```
|
||||||
docker run --detach --name christmas-community -p 80:80 --restart always wingysam/christmas-community
|
docker run --detach --name christmas-community -p 80:80 --restart always wingysam/christmas-community
|
||||||
|
|
|
@ -13,5 +13,6 @@ module.exports = {
|
||||||
siteTitle: process.env.SITE_TITLE || 'Christmas Community',
|
siteTitle: process.env.SITE_TITLE || 'Christmas Community',
|
||||||
shortTitle: process.env.SHORT_TITLE || 'Christmas',
|
shortTitle: process.env.SHORT_TITLE || 'Christmas',
|
||||||
useCDN: yesNo.parse(process.env.USE_CDN || true),
|
useCDN: yesNo.parse(process.env.USE_CDN || true),
|
||||||
wishlist: require('./wishlist')
|
wishlist: require('./wishlist'),
|
||||||
|
base: (process.env.ROOT_PATH || '/').endsWith('/') ? (process.env.ROOT_PATH || '/') : `${process.env.ROOT_PATH}/`
|
||||||
};
|
};
|
||||||
|
|
8
index.js
8
index.js
|
@ -1,3 +1,4 @@
|
||||||
|
global._CC = {}
|
||||||
const expressSessionLevel = require('express-session-level');
|
const expressSessionLevel = require('express-session-level');
|
||||||
const LocalStrategy = require('passport-local').Strategy;
|
const LocalStrategy = require('passport-local').Strategy;
|
||||||
const session = require('express-session');
|
const session = require('express-session');
|
||||||
|
@ -9,10 +10,12 @@ const PouchDB = require('pouchdb');
|
||||||
const level = require('level');
|
const level = require('level');
|
||||||
|
|
||||||
const config = require('./config');
|
const config = require('./config');
|
||||||
|
_CC.config = config
|
||||||
|
|
||||||
const logger = require('./logger');
|
const logger = require('./logger');
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
app.set('base', config.base)
|
||||||
|
|
||||||
const db = new PouchDB(config.dbUrl);
|
const db = new PouchDB(config.dbUrl);
|
||||||
|
|
||||||
|
@ -54,7 +57,8 @@ app.use(session({
|
||||||
store: new LevelStore(sessionDb),
|
store: new LevelStore(sessionDb),
|
||||||
cookie: {
|
cookie: {
|
||||||
maxAge: config.sessionMaxAge
|
maxAge: config.sessionMaxAge
|
||||||
}
|
},
|
||||||
|
name: 'christmas_community.connect.sid'
|
||||||
}));
|
}));
|
||||||
app.use(flash());
|
app.use(flash());
|
||||||
app.use(passport.initialize());
|
app.use(passport.initialize());
|
||||||
|
@ -68,6 +72,6 @@ app.use((req, res, next) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
app.set('view engine', 'pug');
|
app.set('view engine', 'pug');
|
||||||
app.use('/', require('./routes')({ db, config }));
|
app.use(config.base, require('./routes')({ db, config }));
|
||||||
|
|
||||||
app.listen(config.port, () => logger.success('express', `Express server started on port ${config.port}!`))
|
app.listen(config.port, () => logger.success('express', `Express server started on port ${config.port}!`))
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
{
|
{
|
||||||
"name": "christmas-community",
|
"name": "christmas-community",
|
||||||
"version": "1.10.5",
|
"version": "1.11.0",
|
||||||
"description": "Christmas lists for communities",
|
"description": "Christmas lists for communities",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"postinstall": "cp patched-express-response.js node_modules/express/lib/response.js",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"start": "node index.js"
|
"start": "node index.js"
|
||||||
},
|
},
|
||||||
|
@ -15,7 +16,7 @@
|
||||||
"chalk": "^2.4.1",
|
"chalk": "^2.4.1",
|
||||||
"connect-flash": "^0.1.1",
|
"connect-flash": "^0.1.1",
|
||||||
"dotenv": "^6.1.0",
|
"dotenv": "^6.1.0",
|
||||||
"express": "^4.16.4",
|
"express": "4.17.1",
|
||||||
"express-session": "^1.15.6",
|
"express-session": "^1.15.6",
|
||||||
"express-session-level": "^1.0.0",
|
"express-session-level": "^1.0.0",
|
||||||
"get-product-name": "^1.5.0",
|
"get-product-name": "^1.5.0",
|
||||||
|
|
1146
patched-express-response.js
Normal file
1146
patched-express-response.js
Normal file
File diff suppressed because it is too large
Load diff
|
@ -5,14 +5,14 @@ block content
|
||||||
each user in users
|
each user in users
|
||||||
span.is-size-6.inline= user.id
|
span.is-size-6.inline= user.id
|
||||||
if !user.doc.admin
|
if !user.doc.admin
|
||||||
a(href=`/admin-settings/remove/${user.id}`)
|
a(href=`${_CC.config.base}admin-settings/remove/${user.id}`)
|
||||||
span.is-size-7.icon.has-text-danger
|
span.is-size-7.icon.has-text-danger
|
||||||
i.fas.fa-times
|
i.fas.fa-times
|
||||||
span.is-sr-only
|
span.is-sr-only
|
||||||
Remove
|
Remove
|
||||||
br
|
br
|
||||||
h3 Add user
|
h3 Add user
|
||||||
form(action='/admin-settings/add', method='POST')
|
form(action=`${_CC.config.base}admin-settings/add`, method='POST')
|
||||||
.field
|
.field
|
||||||
label.label Username
|
label.label Username
|
||||||
.control.has-icons-left
|
.control.has-icons-left
|
||||||
|
|
|
@ -5,13 +5,13 @@ mixin navBarLink(href, title)
|
||||||
a.navbar-item(href=href)= title
|
a.navbar-item(href=href)= title
|
||||||
nav.navbar.is-fixed-top(role='navigation', aria-label='main navigation',style='box-shadow: 0px 0px 7px rgb(14, 15, 17);')
|
nav.navbar.is-fixed-top(role='navigation', aria-label='main navigation',style='box-shadow: 0px 0px 7px rgb(14, 15, 17);')
|
||||||
.navbar-brand
|
.navbar-brand
|
||||||
if '/' === req.path
|
if _CC.config.base === req.path
|
||||||
a.is-active.navbar-item(href='/')
|
a.is-active.navbar-item(href=_CC.config.base)
|
||||||
img(src='/img/logo.png', alt='')
|
img(src=`${_CC.config.base}img/logo.png`, alt='')
|
||||||
span #{config.siteTitle}
|
span #{config.siteTitle}
|
||||||
else
|
else
|
||||||
a.navbar-item(href='/')
|
a.navbar-item(href=_CC.config.base)
|
||||||
img(src='/img/logo.png', alt='')
|
img(src=`${_CC.config.base}img/logo.png`, alt='')
|
||||||
span #{config.siteTitle}
|
span #{config.siteTitle}
|
||||||
a.navbar-burger#navBarBurger(role='button', aria-label='menu', aria-expanded='false')
|
a.navbar-burger#navBarBurger(role='button', aria-label='menu', aria-expanded='false')
|
||||||
span(aria-hidden='true')
|
span(aria-hidden='true')
|
||||||
|
@ -23,13 +23,13 @@ nav.navbar.is-fixed-top(role='navigation', aria-label='main navigation',style='b
|
||||||
.navbar-item.has-dropdown.is-hoverable
|
.navbar-item.has-dropdown.is-hoverable
|
||||||
a.navbar-link= req.user._id
|
a.navbar-link= req.user._id
|
||||||
.navbar-dropdown
|
.navbar-dropdown
|
||||||
+navBarLink(`/wishlist/${req.user._id}`, 'My Wishlist')
|
+navBarLink(`${_CC.config.base}wishlist/${req.user._id}`, 'My Wishlist')
|
||||||
+navBarLink('/profile', 'Profile')
|
+navBarLink(`${_CC.config.base}profile`, 'Profile')
|
||||||
if req.user.admin
|
if req.user.admin
|
||||||
+navBarLink('/admin-settings', 'Admin settings')
|
+navBarLink(`${_CC.config.base}admin-settings`, 'Admin settings')
|
||||||
hr.navbar-divider
|
hr.navbar-divider
|
||||||
.navbar-item
|
.navbar-item
|
||||||
form#logoutForm(action='/logout', method='POST')
|
form#logoutForm(action=`${_CC.config.base}logout`, method='POST')
|
||||||
button.button.is-warning(type='submit') Log Out
|
button.button.is-warning(type='submit') Log Out
|
||||||
//-+navBarLink('javascript:document.getElementById("logoutForm").submit()', 'Log Out')
|
//-+navBarLink('javascript:document.getElementById("logoutForm").submit()', 'Log Out')
|
||||||
script(src="/js/nav.js")
|
script(src=`${_CC.config.base}js/nav.js`)
|
||||||
|
|
|
@ -3,8 +3,8 @@ html(lang='en')
|
||||||
head
|
head
|
||||||
meta(name='viewport', content='width=device-width, initial-scale=1, user-scalable=no')
|
meta(name='viewport', content='width=device-width, initial-scale=1, user-scalable=no')
|
||||||
|
|
||||||
link(rel='manifest', href='/manifest.json')
|
link(rel='manifest', href=`${_CC.config.base}manifest.json`)
|
||||||
link(rel='apple-touch-icon', href='/img/logo.png', sizes='1280x1280')
|
link(rel='apple-touch-icon', href=`${_CC.config.base}img/logo.png`, sizes='1280x1280')
|
||||||
|
|
||||||
if title
|
if title
|
||||||
title #{config.siteTitle} - #{title}
|
title #{config.siteTitle} - #{title}
|
||||||
|
@ -19,10 +19,10 @@ html(lang='en')
|
||||||
)
|
)
|
||||||
link(rel='stylesheet', href='https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.min.css')
|
link(rel='stylesheet', href='https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.min.css')
|
||||||
else
|
else
|
||||||
link(rel='stylesheet', href='/libraries/bulma.min.css')
|
link(rel='stylesheet', href=`${_CC.config.base}libraries/bulma.min.css`)
|
||||||
link(rel='stylesheet', href='/libraries/fontawesome/css/all.css')
|
link(rel='stylesheet', href=`${_CC.config.base}libraries/fontawesome/css/all.css`)
|
||||||
link(rel='stylesheet', href='/libraries/animate.min.css')
|
link(rel='stylesheet', href=`${_CC.config.base}libraries/animate.min.css`)
|
||||||
link(rel='stylesheet', href='/css/main.css')
|
link(rel='stylesheet', href=`${_CC.config.base}css/main.css`)
|
||||||
body
|
body
|
||||||
.print
|
.print
|
||||||
.content
|
.content
|
||||||
|
|
|
@ -2,7 +2,7 @@ extends layout.pug
|
||||||
|
|
||||||
block content
|
block content
|
||||||
h2 Admin User
|
h2 Admin User
|
||||||
form(action='/setup', method='POST')
|
form(action=`${_CC.config.base}setup`, method='POST')
|
||||||
.field
|
.field
|
||||||
label.label Username
|
label.label Username
|
||||||
.control.has-icons-left
|
.control.has-icons-left
|
||||||
|
|
|
@ -42,7 +42,7 @@ block content
|
||||||
td.ugc(data-label='Name')= item.name
|
td.ugc(data-label='Name')= item.name
|
||||||
td.ugc(data-label='Note')= item.note
|
td.ugc(data-label='Note')= item.note
|
||||||
td(data-label='Edit Item')
|
td(data-label='Edit Item')
|
||||||
form.inline(method='GET', action=`/wishlist/${req.params.user}/note/${item.id}`)
|
form.inline(method='GET', action=`${_CC.config.base}wishlist/${req.params.user}/note/${item.id}`)
|
||||||
.field.inline
|
.field.inline
|
||||||
.control.inline
|
.control.inline
|
||||||
button.button.is-text(
|
button.button.is-text(
|
||||||
|
@ -55,7 +55,7 @@ block content
|
||||||
td.ugc(data-label='Added By')= item.addedBy
|
td.ugc(data-label='Added By')= item.addedBy
|
||||||
if req.params.user === req.user._id
|
if req.params.user === req.user._id
|
||||||
td(data-label='Move Item Up')
|
td(data-label='Move Item Up')
|
||||||
form.upForm.inline(method='POST', action=`/wishlist/${req.params.user}/move/up/${item.id}`)
|
form.upForm.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/move/up/${item.id}`)
|
||||||
.field.inline
|
.field.inline
|
||||||
.control.inline
|
.control.inline
|
||||||
button.button.is-text(
|
button.button.is-text(
|
||||||
|
@ -66,7 +66,7 @@ block content
|
||||||
span.icon
|
span.icon
|
||||||
i.fas.fa-arrow-up
|
i.fas.fa-arrow-up
|
||||||
td(data-label='Move Item Down')
|
td(data-label='Move Item Down')
|
||||||
form.downForm.inline(method='POST', action=`/wishlist/${req.params.user}/move/down/${item.id}`)
|
form.downForm.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/move/down/${item.id}`)
|
||||||
.field.inline
|
.field.inline
|
||||||
.control.inline
|
.control.inline
|
||||||
button.button.is-text(
|
button.button.is-text(
|
||||||
|
@ -79,12 +79,12 @@ block content
|
||||||
else
|
else
|
||||||
td(data-label='Pledge')
|
td(data-label='Pledge')
|
||||||
if req.params.user !== req.user._id && !item.pledgedBy
|
if req.params.user !== req.user._id && !item.pledgedBy
|
||||||
form.inline(method='POST', action=`/wishlist/${req.params.user}/pledge/${item.id}`)
|
form.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/pledge/${item.id}`)
|
||||||
.field.inline
|
.field.inline
|
||||||
.control.inline
|
.control.inline
|
||||||
input.inline.button.is-primary(type='submit' value='Pledge')
|
input.inline.button.is-primary(type='submit' value='Pledge')
|
||||||
if item.pledgedBy === req.user._id
|
if item.pledgedBy === req.user._id
|
||||||
form.inline(method='POST', action=`/wishlist/${req.params.user}/unpledge/${item.id}`)
|
form.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/unpledge/${item.id}`)
|
||||||
.field.inline
|
.field.inline
|
||||||
.control.inline
|
.control.inline
|
||||||
input.inline.button(type='submit' value='Unpledge')
|
input.inline.button(type='submit' value='Unpledge')
|
||||||
|
@ -93,7 +93,7 @@ block content
|
||||||
td(data-label='Delete Item')
|
td(data-label='Delete Item')
|
||||||
form.inline(
|
form.inline(
|
||||||
method='POST',
|
method='POST',
|
||||||
action=`/wishlist/${req.params.user}/${req.user._id === req.params.user ? 'remove' : 'unpledge'}/${item.id}`
|
action=`${_CC.config.base}wishlist/${req.params.user}/${req.user._id === req.params.user ? 'remove' : 'unpledge'}/${item.id}`
|
||||||
)
|
)
|
||||||
.field.inline
|
.field.inline
|
||||||
.control.inline
|
.control.inline
|
||||||
|
@ -128,32 +128,32 @@ block content
|
||||||
hr
|
hr
|
||||||
div
|
div
|
||||||
if req.params.user !== req.user._id && !item.pledgedBy
|
if req.params.user !== req.user._id && !item.pledgedBy
|
||||||
form.inline(method='POST', action=`/wishlist/${req.params.user}/pledge/${item.id}`)
|
form.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/pledge/${item.id}`)
|
||||||
.field.inline
|
.field.inline
|
||||||
.control.inline
|
.control.inline
|
||||||
input.inline.button.is-primary(type='submit' value='Pledge')
|
input.inline.button.is-primary(type='submit' value='Pledge')
|
||||||
if item.pledgedBy === req.user._id
|
if item.pledgedBy === req.user._id
|
||||||
form.inline(method='POST', action=`/wishlist/${req.params.user}/unpledge/${item.id}`)
|
form.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/unpledge/${item.id}`)
|
||||||
.field.inline
|
.field.inline
|
||||||
.control.inline
|
.control.inline
|
||||||
input.inline.button(type='submit' value='Unpledge')
|
input.inline.button(type='submit' value='Unpledge')
|
||||||
if req.user._id === req.params.user
|
if req.user._id === req.params.user
|
||||||
form.inline(method='POST', action=`/wishlist/${req.params.user}/remove/${item.id}`)
|
form.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/remove/${item.id}`)
|
||||||
.field.inline
|
.field.inline
|
||||||
.control.inline
|
.control.inline
|
||||||
input.inline.button.is-warning(type='submit' value='Remove')
|
input.inline.button.is-warning(type='submit' value='Remove')
|
||||||
if req.user._id === req.params.user || req.user._id === item.addedBy
|
if req.user._id === req.params.user || req.user._id === item.addedBy
|
||||||
form.inline(method='GET', action=`/wishlist/${req.params.user}/note/${item.id}`)
|
form.inline(method='GET', action=`${_CC.config.base}wishlist/${req.params.user}/note/${item.id}`)
|
||||||
.field.inline
|
.field.inline
|
||||||
.control.inline
|
.control.inline
|
||||||
input.inline.button(type='submit', value='Edit item')
|
input.inline.button(type='submit', value='Edit item')
|
||||||
if index !== firstCanSee && req.user._id === req.params.user
|
if index !== firstCanSee && req.user._id === req.params.user
|
||||||
form.inline(method='POST', action=`/wishlist/${req.params.user}/move/up/${item.id}`)
|
form.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/move/up/${item.id}`)
|
||||||
.field.inline
|
.field.inline
|
||||||
.control.inline
|
.control.inline
|
||||||
input.inline.button(type='submit' value='Move item up')
|
input.inline.button(type='submit' value='Move item up')
|
||||||
if index !== lastCanSee && req.user._id === req.params.user
|
if index !== lastCanSee && req.user._id === req.params.user
|
||||||
form.inline(method='POST', action=`/wishlist/${req.params.user}/move/down/${item.id}`)
|
form.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/move/down/${item.id}`)
|
||||||
.field.inline
|
.field.inline
|
||||||
.control.inline
|
.control.inline
|
||||||
input.inline.button(type='submit' value='Move item down')
|
input.inline.button(type='submit' value='Move item down')
|
||||||
|
@ -178,7 +178,7 @@ block content
|
||||||
.field
|
.field
|
||||||
.control
|
.control
|
||||||
input.button(type='submit' value=(req.user._id === req.params.user ? 'Add item to wishlist' : 'Pledge item'))
|
input.button(type='submit' value=(req.user._id === req.params.user ? 'Add item to wishlist' : 'Pledge item'))
|
||||||
script(src='/js/wishlist.js')
|
script(src=`${_CC.config.base}js/wishlist.js`)
|
||||||
|
|
||||||
block print
|
block print
|
||||||
h1 #{req.params.user}'s Wishlist
|
h1 #{req.params.user}'s Wishlist
|
||||||
|
|
|
@ -3,7 +3,7 @@ extends layout.pug
|
||||||
block content
|
block content
|
||||||
ul.noStyle.noLeftMargin
|
ul.noStyle.noLeftMargin
|
||||||
li
|
li
|
||||||
a(href=`/wishlist/${req.user._id}`)
|
a(href=`${_CC.config.base}wishlist/${req.user._id}`)
|
||||||
.box
|
.box
|
||||||
span=req.user._id
|
span=req.user._id
|
||||||
span : ???/???
|
span : ???/???
|
||||||
|
@ -11,7 +11,7 @@ block content
|
||||||
each user in users
|
each user in users
|
||||||
if req.user._id !== user.id
|
if req.user._id !== user.id
|
||||||
li
|
li
|
||||||
a(href=`/wishlist/${user.id}`)
|
a(href=`${_CC.config.base}wishlist/${user.id}`)
|
||||||
.box
|
.box
|
||||||
span= user.id
|
span= user.id
|
||||||
span : #{totals(user.doc.wishlist).pledged}/#{user.doc.wishlist.length}
|
span : #{totals(user.doc.wishlist).pledged}/#{user.doc.wishlist.length}
|
||||||
|
|
Loading…
Reference in a new issue