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
|
||||
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 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',
|
||||
shortTitle: process.env.SHORT_TITLE || 'Christmas',
|
||||
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 LocalStrategy = require('passport-local').Strategy;
|
||||
const session = require('express-session');
|
||||
|
@ -9,10 +10,12 @@ const PouchDB = require('pouchdb');
|
|||
const level = require('level');
|
||||
|
||||
const config = require('./config');
|
||||
_CC.config = config
|
||||
|
||||
const logger = require('./logger');
|
||||
|
||||
const app = express();
|
||||
app.set('base', config.base)
|
||||
|
||||
const db = new PouchDB(config.dbUrl);
|
||||
|
||||
|
@ -54,7 +57,8 @@ app.use(session({
|
|||
store: new LevelStore(sessionDb),
|
||||
cookie: {
|
||||
maxAge: config.sessionMaxAge
|
||||
}
|
||||
},
|
||||
name: 'christmas_community.connect.sid'
|
||||
}));
|
||||
app.use(flash());
|
||||
app.use(passport.initialize());
|
||||
|
@ -68,6 +72,6 @@ app.use((req, res, next) => {
|
|||
});
|
||||
|
||||
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}!`))
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
{
|
||||
"name": "christmas-community",
|
||||
"version": "1.10.5",
|
||||
"version": "1.11.0",
|
||||
"description": "Christmas lists for communities",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"postinstall": "cp patched-express-response.js node_modules/express/lib/response.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "node index.js"
|
||||
},
|
||||
|
@ -15,7 +16,7 @@
|
|||
"chalk": "^2.4.1",
|
||||
"connect-flash": "^0.1.1",
|
||||
"dotenv": "^6.1.0",
|
||||
"express": "^4.16.4",
|
||||
"express": "4.17.1",
|
||||
"express-session": "^1.15.6",
|
||||
"express-session-level": "^1.0.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
|
||||
span.is-size-6.inline= user.id
|
||||
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
|
||||
i.fas.fa-times
|
||||
span.is-sr-only
|
||||
Remove
|
||||
br
|
||||
h3 Add user
|
||||
form(action='/admin-settings/add', method='POST')
|
||||
form(action=`${_CC.config.base}admin-settings/add`, method='POST')
|
||||
.field
|
||||
label.label Username
|
||||
.control.has-icons-left
|
||||
|
|
|
@ -5,13 +5,13 @@ mixin navBarLink(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);')
|
||||
.navbar-brand
|
||||
if '/' === req.path
|
||||
a.is-active.navbar-item(href='/')
|
||||
img(src='/img/logo.png', alt='')
|
||||
if _CC.config.base === req.path
|
||||
a.is-active.navbar-item(href=_CC.config.base)
|
||||
img(src=`${_CC.config.base}img/logo.png`, alt='')
|
||||
span #{config.siteTitle}
|
||||
else
|
||||
a.navbar-item(href='/')
|
||||
img(src='/img/logo.png', alt='')
|
||||
a.navbar-item(href=_CC.config.base)
|
||||
img(src=`${_CC.config.base}img/logo.png`, alt='')
|
||||
span #{config.siteTitle}
|
||||
a.navbar-burger#navBarBurger(role='button', aria-label='menu', aria-expanded='false')
|
||||
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
|
||||
a.navbar-link= req.user._id
|
||||
.navbar-dropdown
|
||||
+navBarLink(`/wishlist/${req.user._id}`, 'My Wishlist')
|
||||
+navBarLink('/profile', 'Profile')
|
||||
+navBarLink(`${_CC.config.base}wishlist/${req.user._id}`, 'My Wishlist')
|
||||
+navBarLink(`${_CC.config.base}profile`, 'Profile')
|
||||
if req.user.admin
|
||||
+navBarLink('/admin-settings', 'Admin settings')
|
||||
+navBarLink(`${_CC.config.base}admin-settings`, 'Admin settings')
|
||||
hr.navbar-divider
|
||||
.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
|
||||
//-+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
|
||||
meta(name='viewport', content='width=device-width, initial-scale=1, user-scalable=no')
|
||||
|
||||
link(rel='manifest', href='/manifest.json')
|
||||
link(rel='apple-touch-icon', href='/img/logo.png', sizes='1280x1280')
|
||||
link(rel='manifest', href=`${_CC.config.base}manifest.json`)
|
||||
link(rel='apple-touch-icon', href=`${_CC.config.base}img/logo.png`, sizes='1280x1280')
|
||||
|
||||
if 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')
|
||||
else
|
||||
link(rel='stylesheet', href='/libraries/bulma.min.css')
|
||||
link(rel='stylesheet', href='/libraries/fontawesome/css/all.css')
|
||||
link(rel='stylesheet', href='/libraries/animate.min.css')
|
||||
link(rel='stylesheet', href='/css/main.css')
|
||||
link(rel='stylesheet', href=`${_CC.config.base}libraries/bulma.min.css`)
|
||||
link(rel='stylesheet', href=`${_CC.config.base}libraries/fontawesome/css/all.css`)
|
||||
link(rel='stylesheet', href=`${_CC.config.base}libraries/animate.min.css`)
|
||||
link(rel='stylesheet', href=`${_CC.config.base}css/main.css`)
|
||||
body
|
||||
.print
|
||||
.content
|
||||
|
|
|
@ -2,7 +2,7 @@ extends layout.pug
|
|||
|
||||
block content
|
||||
h2 Admin User
|
||||
form(action='/setup', method='POST')
|
||||
form(action=`${_CC.config.base}setup`, method='POST')
|
||||
.field
|
||||
label.label Username
|
||||
.control.has-icons-left
|
||||
|
|
|
@ -42,7 +42,7 @@ block content
|
|||
td.ugc(data-label='Name')= item.name
|
||||
td.ugc(data-label='Note')= item.note
|
||||
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
|
||||
.control.inline
|
||||
button.button.is-text(
|
||||
|
@ -55,7 +55,7 @@ block content
|
|||
td.ugc(data-label='Added By')= item.addedBy
|
||||
if req.params.user === req.user._id
|
||||
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
|
||||
.control.inline
|
||||
button.button.is-text(
|
||||
|
@ -66,7 +66,7 @@ block content
|
|||
span.icon
|
||||
i.fas.fa-arrow-up
|
||||
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
|
||||
.control.inline
|
||||
button.button.is-text(
|
||||
|
@ -79,12 +79,12 @@ block content
|
|||
else
|
||||
td(data-label='Pledge')
|
||||
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
|
||||
.control.inline
|
||||
input.inline.button.is-primary(type='submit' value='Pledge')
|
||||
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
|
||||
.control.inline
|
||||
input.inline.button(type='submit' value='Unpledge')
|
||||
|
@ -93,7 +93,7 @@ block content
|
|||
td(data-label='Delete Item')
|
||||
form.inline(
|
||||
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
|
||||
.control.inline
|
||||
|
@ -128,32 +128,32 @@ block content
|
|||
hr
|
||||
div
|
||||
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
|
||||
.control.inline
|
||||
input.inline.button.is-primary(type='submit' value='Pledge')
|
||||
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
|
||||
.control.inline
|
||||
input.inline.button(type='submit' value='Unpledge')
|
||||
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
|
||||
.control.inline
|
||||
input.inline.button.is-warning(type='submit' value='Remove')
|
||||
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
|
||||
.control.inline
|
||||
input.inline.button(type='submit', value='Edit item')
|
||||
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
|
||||
.control.inline
|
||||
input.inline.button(type='submit' value='Move item up')
|
||||
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
|
||||
.control.inline
|
||||
input.inline.button(type='submit' value='Move item down')
|
||||
|
@ -178,7 +178,7 @@ block content
|
|||
.field
|
||||
.control
|
||||
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
|
||||
h1 #{req.params.user}'s Wishlist
|
||||
|
|
|
@ -3,7 +3,7 @@ extends layout.pug
|
|||
block content
|
||||
ul.noStyle.noLeftMargin
|
||||
li
|
||||
a(href=`/wishlist/${req.user._id}`)
|
||||
a(href=`${_CC.config.base}wishlist/${req.user._id}`)
|
||||
.box
|
||||
span=req.user._id
|
||||
span : ???/???
|
||||
|
@ -11,7 +11,7 @@ block content
|
|||
each user in users
|
||||
if req.user._id !== user.id
|
||||
li
|
||||
a(href=`/wishlist/${user.id}`)
|
||||
a(href=`${_CC.config.base}wishlist/${user.id}`)
|
||||
.box
|
||||
span= user.id
|
||||
span : #{totals(user.doc.wishlist).pledged}/#{user.doc.wishlist.length}
|
||||
|
|
Loading…
Reference in a new issue