Refactor: move src to folder (#63)
* move all source code to src/ * replace express response patch with middleware * fix readdir not looking in src * fix stray redirect * add base to manifest * remove secret.txt from src/config/secret * add src/config/secret/secret.txt to gitignore
This commit is contained in:
parent
363146c331
commit
0d7d73744c
1569 changed files with 25 additions and 1159 deletions
9
src/views/admin-clear-wishlists.pug
Normal file
9
src/views/admin-clear-wishlists.pug
Normal file
|
@ -0,0 +1,9 @@
|
|||
extends layout.pug
|
||||
|
||||
block content
|
||||
h2= lang('ADMIN_CLEAR_WISHLISTS_HEADER')
|
||||
p!= lang('ADMIN_CLEAR_WISHLISTS_DESCRIPTION')
|
||||
form(method='POST', action=`${_CC.config.base}admin-settings/clear-wishlists`)
|
||||
.field
|
||||
.control
|
||||
input.button.is-danger(type='submit' value=lang('ADMIN_CLEAR_WISHLISTS_BUTTON'))
|
107
src/views/admin-user-edit.pug
Normal file
107
src/views/admin-user-edit.pug
Normal file
|
@ -0,0 +1,107 @@
|
|||
extends layout.pug
|
||||
|
||||
block title
|
||||
h1(style="margin-bottom: 0;")
|
||||
a(href='..') <
|
||||
| #{config.siteTitle}
|
||||
p= lang('ADMIN_USER_EDIT_EDITING_USER', user._id)
|
||||
|
||||
block content
|
||||
.columns
|
||||
.column
|
||||
if user.signupToken
|
||||
- const signupLink = `${_CC.config.base}confirm-account/${user.signupToken}`
|
||||
.box(style='overflow: hidden;')
|
||||
.columns(style='margin-bottom: 0;')
|
||||
.column.is-narrow(style='padding-bottom: 0;')
|
||||
h2= lang('ADMIN_USER_EDIT_CONFIRMATION_LINK')
|
||||
.column(style='padding-bottom: 0;')
|
||||
p
|
||||
span= lang('ADMIN_USER_EDIT_ACCOUNT_UNCONFIRMED')
|
||||
br
|
||||
if user.expiry > new Date().getTime()
|
||||
span= lang('ADMIN_USER_EDIT_LINK_EXPIRY_FUTURE', _CC.moment(user.expiry).fromNow())
|
||||
else
|
||||
span.has-text-weight-bold(style='color: red;')= lang('ADMIN_USER_EDIT_LINK_EXPIRY_PAST', _CC.moment(user.expiry).fromNow())
|
||||
h3(style='margin-bottom: 0; margin-top: 0;')
|
||||
.level
|
||||
.level-left
|
||||
.level-item
|
||||
form(method='POST', action=`${_CC.config.base}admin-settings/edit/refresh-signup-token/${user._id}`)
|
||||
input.button.is-rounded(type='submit', value=lang('ADMIN_USER_EDIT_GENERATE_NEW_LINK'))
|
||||
.level-item
|
||||
a(href=signupLink, style='font-family: monospaced; word-break: break-all;')= signupLink
|
||||
.columns
|
||||
.column.is-narrow
|
||||
h2= lang('ADMIN_USER_EDIT_CHANGE_NAME')
|
||||
form(action=`${_CC.config.base}admin-settings/edit/rename/${user._id}`, method='POST')
|
||||
.field
|
||||
label.label= lang('ADMIN_USER_EDIT_USERNAME')
|
||||
.control.has-icons-left
|
||||
input.input(type='text', name='newUsername', placeholder=user._id, value=user._id)
|
||||
span.icon.is-small.is-left
|
||||
i.fas.fa-user
|
||||
.field
|
||||
.control
|
||||
input.button.is-primary(type='submit' value=lang('ADMIN_USER_EDIT_CHANGE_USERNAME'))
|
||||
.column.is-narrow
|
||||
h2= lang('ADMIN_USER_EDIT_ADMIN')
|
||||
//- Yes, ternary exists, but I think the code is cleaner with a more "naive" style :)
|
||||
//- p.is-marginless #{user._id} is #{user.admin ? '' : 'not '}an admin.
|
||||
//- vs.
|
||||
if user.admin
|
||||
p.is-marginless= lang('ADMIN_USER_EDIT_ADMIN_ISADMIN', user._id)
|
||||
form(action=`${_CC.config.base}admin-settings/edit/demote/${user._id}`, method='POST')
|
||||
.field
|
||||
.control
|
||||
if user._id === req.user._id
|
||||
input.input.button(disabled, type='submit', value=lang('ADMIN_USER_EDIT_DEMOTE_SELF'), style='margin-top: 1em;')
|
||||
else
|
||||
input.input.button(type='submit', value=lang('ADMIN_USER_EDIT_DEMOTE', user._id), style='margin-top: 1em;')
|
||||
else
|
||||
p.is-marginless= lang('ADMIN_USER_EDIT_ADMIN_NOTADMIN', user._id)
|
||||
form(action=`${_CC.config.base}admin-settings/edit/promote/${user._id}`, method='POST')
|
||||
.field
|
||||
.control
|
||||
input.input.button(type='submit', value=lang('ADMIN_USER_EDIT_PROMOTE', user._id), style='margin-top: 1em;')
|
||||
if user._id !== req.user._id
|
||||
.column.is-narrow
|
||||
h2= lang('ADMIN_USER_EDIT_IMPERSONATE_HEADER')
|
||||
form(action=`${_CC.config.base}admin-settings/edit/impersonate/${user._id}`, method='POST')
|
||||
.field
|
||||
.control
|
||||
input.input.button.is-warning(type='submit', value=lang('ADMIN_USER_EDIT_IMPERSONATE_BUTTON', user._id), style='margin-top: 1em;')
|
||||
h2(style='margin-bottom: 1em;')= lang('ADMIN_USER_EDIT_RESET_PASSWORD_HEADER')
|
||||
if user.pwToken
|
||||
- const resetLink = `${_CC.config.base}resetpw/${user.pwToken}`
|
||||
p= lang('ADMIN_USER_EDIT_RESET_PASSWORD_HASLINK')
|
||||
if user.pwExpiry > new Date().getTime()
|
||||
span= lang('ADMIN_USER_EDIT_RESET_PASSWORD_HASLINK_EXPIRY_FUTURE', _CC.moment(user.pwExpiry).fromNow())
|
||||
else
|
||||
span.has-text-weight-bold.has-text-danger= lang('ADMIN_USER_EDIT_RESET_PASSWORD_HASLINK_EXPIRY_PAST', _CC.moment(user.pwExpiry).fromNow())
|
||||
a(href=resetLink)= resetLink
|
||||
.columns
|
||||
.column.is-narrow
|
||||
form(method='POST', action=`${_CC.config.base}admin-settings/edit/resetpw/${user._id}`)
|
||||
.field
|
||||
.control
|
||||
input.button.is-primary(type='submit' value=lang('ADMIN_USER_EDIT_RESET_PASSWORD_LINK_REFRESH'))
|
||||
.column.is-narrow
|
||||
form(method='POST', action=`${_CC.config.base}admin-settings/edit/cancelresetpw/${user._id}`)
|
||||
.field
|
||||
.control
|
||||
input.button.is-info(type='submit' value=lang('ADMIN_USER_EDIT_RESET_PASSWORD_LINK_CANCEL'))
|
||||
else
|
||||
form(method='POST', action=`${_CC.config.base}admin-settings/edit/resetpw/${user._id}`)
|
||||
.field
|
||||
.control
|
||||
input.button.is-danger(type='submit' value=lang('ADMIN_USER_EDIT_RESET_PASSWORD_LINK_CREATE'))
|
||||
.column.is-narrow
|
||||
h2= lang('ADMIN_USER_EDIT_DELETE_HEADER')
|
||||
form(method='POST', action=`${_CC.config.base}admin-settings/edit/remove/${user._id}`)
|
||||
.field
|
||||
.control
|
||||
if user.admin
|
||||
input.button.is-danger(disabled, type='submit' value=lang('ADMIN_USER_EDIT_DELETE_ADMIN'))
|
||||
else
|
||||
input.button.is-danger(type='submit' value=lang('ADMIN_USER_EDIT_DELETE_USER', user._id))
|
32
src/views/adminSettings.pug
Normal file
32
src/views/adminSettings.pug
Normal file
|
@ -0,0 +1,32 @@
|
|||
extends layout.pug
|
||||
|
||||
block content
|
||||
h2= lang('ADMIN_SETTINGS_USERS_HEADER')
|
||||
each user in users
|
||||
span.is-size-6.inline= user.id
|
||||
a(href=`${_CC.config.base}admin-settings/edit/${user.id}`)
|
||||
span.is-size-7.icon.has-text-info
|
||||
i.fas.fa-edit
|
||||
span.is-sr-only
|
||||
= lang('ADMIN_SETTINGS_USERS_EDIT')
|
||||
br
|
||||
h3= lang('ADMIN_SETTINGS_USERS_ADD_HEADER')
|
||||
form(action=`${_CC.config.base}admin-settings/add`, method='POST')
|
||||
.field
|
||||
p.has-text-danger#error-label= add_user_error
|
||||
label.label= lang('ADMIN_SETTINGS_USERS_ADD_USERNAME')
|
||||
.control.has-icons-left
|
||||
input.input(type='text', name='newUserUsername', placeholder=lang('ADMIN_SETTINGS_USERS_ADD_PLACEHOLDER'))
|
||||
span.icon.is-small.is-left
|
||||
i.fas.fa-user
|
||||
.field
|
||||
.control
|
||||
input.button.is-primary(type='submit' value=lang('ADMIN_SETTINGS_USERS_ADD_BUTTON'))
|
||||
h3= lang('ADMIN_SETTINGS_CLEARDB_HEADER')
|
||||
p!= lang('ADMIN_SETTINGS_CLEARDB_DESCRIPTION')
|
||||
a.button.is-danger(href=`${_CC.config.base}admin-settings/clear-wishlists`)= lang('ADMIN_SETTINGS_CLEARDB_BUTTON')
|
||||
h3= lang('ADMIN_SETTINGS_VERSION_INFO')
|
||||
p Christmas Community: v#{_CC.package.version}
|
||||
p Get Product Data: v#{_CC.require('get-product-name/package.json').version}
|
||||
p Node: #{process.version}
|
||||
p PID: #{process.pid}
|
34
src/views/confirm-account.pug
Normal file
34
src/views/confirm-account.pug
Normal file
|
@ -0,0 +1,34 @@
|
|||
extends layout.pug
|
||||
|
||||
mixin icon(c, text)
|
||||
.columns.is-vcentered.is-mobile
|
||||
.column.is-narrow
|
||||
span.icon.is-large
|
||||
i.fa-3x(class=c)
|
||||
.column #{text}
|
||||
|
||||
block title
|
||||
if doc
|
||||
h1= lang('CONFIRM_ACCOUNT_HEADER_VALID')
|
||||
else
|
||||
h1= lang('CONFIRM_ACCOUNT_HEADER_INVALID')
|
||||
|
||||
block content
|
||||
if doc
|
||||
if doc.expiry > new Date().getTime()
|
||||
+icon('fas fa-smile-beam', lang('CONFIRM_ACCOUNT_SET_PW_TEXT', doc._id))
|
||||
form(method='POST')
|
||||
.field
|
||||
label.label Password
|
||||
.control.has-icons-left
|
||||
input.input(type='password', name='password', placeholder=lang('CONFIRM_ACCOUNT_SET_PW_PLACEHOLDER'))
|
||||
span.icon.is-small.is-left
|
||||
i.fas.fa-lock
|
||||
.field
|
||||
.control
|
||||
input.button.is-primary(type='submit' value=lang('CONFIRM_ACCOUNT_SET_PW_BUTTON'))
|
||||
else
|
||||
+icon('fas fa-frown-open', lang('CONFIRM_ACCOUNT_EXPIRED'))
|
||||
else
|
||||
+icon('fas fa-frown-open', lang('CONFIRM_ACCOUNT_INVALID'))
|
||||
|
9
src/views/includes/messages.pug
Normal file
9
src/views/includes/messages.pug
Normal file
|
@ -0,0 +1,9 @@
|
|||
- successes = req.flash('success');
|
||||
- errors = req.flash('error');
|
||||
|
||||
if successes
|
||||
each success in successes
|
||||
p.has-text-success= (success.toString().startsWith('[object ') ? JSON.stringify(success) : success.toString())
|
||||
if errors
|
||||
each error in errors
|
||||
p.has-text-danger= (error.toString().startsWith('[object ') ? JSON.stringify(error) : error.toString())
|
39
src/views/includes/navbar.pug
Normal file
39
src/views/includes/navbar.pug
Normal file
|
@ -0,0 +1,39 @@
|
|||
mixin navBarLink(href, title)
|
||||
if href === req.path
|
||||
a.is-active.navbar-item(href=href)= title
|
||||
else
|
||||
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 _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=_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')
|
||||
span(aria-hidden='true')
|
||||
span(aria-hidden='true')
|
||||
.navbar-menu#navBarMenu
|
||||
.navbar-start
|
||||
if req.isAuthenticated()
|
||||
if req.user._id === '_CCUNKNOWN'
|
||||
.navbar-item
|
||||
a.button.is-primary(href='/login')= lang('NAVBAR_LOGIN')
|
||||
else
|
||||
.navbar-item.has-dropdown.is-hoverable
|
||||
a.navbar-link= req.user._id
|
||||
.navbar-dropdown
|
||||
+navBarLink(`${_CC.config.base}wishlist/${req.user._id}`, lang('NAVBAR_WISHLIST'))
|
||||
+navBarLink(`${_CC.config.base}profile`, lang('NAVBAR_PROFILE'))
|
||||
if req.user.admin
|
||||
+navBarLink(`${_CC.config.base}admin-settings`, lang('NAVBAR_ADMIN'))
|
||||
hr.navbar-divider
|
||||
.navbar-item
|
||||
form#logoutForm(action=`${_CC.config.base}logout`, method='POST')
|
||||
button.button.is-warning(type='submit')= lang('NAVBAR_LOGOUT')
|
||||
script(src=`${_CC.config.base}js/nav.js`)
|
5
src/views/includes/updateNotice.pug
Normal file
5
src/views/includes/updateNotice.pug
Normal file
|
@ -0,0 +1,5 @@
|
|||
if req.user && req.user.admin && _CC.updateNotice
|
||||
.columns
|
||||
.column
|
||||
.column.is-narrow
|
||||
.box!= lang('UPDATE_NOTICE', _CC.updateNotice.current, _CC.updateNotice.latest)
|
44
src/views/layout.pug
Normal file
44
src/views/layout.pug
Normal file
|
@ -0,0 +1,44 @@
|
|||
doctype html
|
||||
html(lang='en')
|
||||
head
|
||||
meta(name='viewport', content='width=device-width, initial-scale=1, user-scalable=no')
|
||||
|
||||
link(rel='manifest', href=`${_CC.config.base}manifest.json`)
|
||||
link(rel='apple-touch-icon', href=`${_CC.config.base}img/logo.png`, sizes='1280x1280')
|
||||
link(rel='shortcut icon', type='image/png', href=`${_CC.config.base}img/logo.transparent.png`)
|
||||
|
||||
if title
|
||||
title #{config.siteTitle} - #{title}
|
||||
else
|
||||
title #{config.siteTitle}
|
||||
link(rel='stylesheet', href=`${_CC.config.base}libraries/bulmaswatch/${_CC.config.bulmaswatch}/bulmaswatch.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
|
||||
section.section(style='padding-bottom: 0;')
|
||||
.container.is-marginless.fullwidth
|
||||
block print
|
||||
style.
|
||||
.print { display: none !important; }
|
||||
.notprint { display: block !important; }
|
||||
@media print {
|
||||
.notprint-padding { display: none; }
|
||||
nav { display: none}
|
||||
}
|
||||
.notprint
|
||||
include includes/navbar.pug
|
||||
div.content.has-navbar-fixed-top#pageContent
|
||||
div.notprint-padding(style='margin-top: 1.5em;')
|
||||
section.section
|
||||
div.container.is-marginless.fullwidth
|
||||
block title
|
||||
if title
|
||||
h1= title
|
||||
else if title !== false
|
||||
h1 #{config.siteTitle}
|
||||
include includes/messages.pug
|
||||
block content
|
||||
include includes/updateNotice.pug
|
20
src/views/login.pug
Normal file
20
src/views/login.pug
Normal file
|
@ -0,0 +1,20 @@
|
|||
extends layout.pug
|
||||
|
||||
block content
|
||||
form(method='POST')
|
||||
.field
|
||||
label.label= lang('LOGIN_USERNAME')
|
||||
.control.has-icons-left
|
||||
input.input(type='text', name='username', placeholder=lang('LOGIN_USERNAME_PLACEHOLDER'))
|
||||
span.icon.is-small.is-left
|
||||
i.fas.fa-user
|
||||
.field
|
||||
label.label= lang('LOGIN_PASSWORD')
|
||||
.control.has-icons-left
|
||||
input.input(type='password', name='password', placeholder=lang('LOGIN_PASSWORD_PLACEHOLDER'))
|
||||
span.icon.is-small.is-left
|
||||
i.fas.fa-lock
|
||||
.field
|
||||
.control
|
||||
input.button.is-primary(type='submit' value=lang('LOGIN_BUTTON'))
|
||||
|
7
src/views/logout.pug
Normal file
7
src/views/logout.pug
Normal file
|
@ -0,0 +1,7 @@
|
|||
extends layout.pug
|
||||
|
||||
block content
|
||||
form(method='POST')
|
||||
.field
|
||||
.control
|
||||
input.button.is-primary(type='submit' value=lang('LOGOUT_BUTTON'))
|
40
src/views/note.pug
Normal file
40
src/views/note.pug
Normal file
|
@ -0,0 +1,40 @@
|
|||
extends layout.pug
|
||||
|
||||
block content
|
||||
a(href='..') <i class="fas fa-arrow-left"></i> #{lang('NOTE_BACK', req.params.user)}
|
||||
form(id='refreshform', method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/refresh/${req.params.id}`)
|
||||
form.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/note/${req.params.id}`)
|
||||
.columns
|
||||
.column
|
||||
.field
|
||||
label.label= lang('NOTE_NAME')
|
||||
.control
|
||||
input.input(name='name', value=item.name)
|
||||
.column
|
||||
.field
|
||||
label.label= lang('NOTE_URL')
|
||||
.control
|
||||
input.input(name='url', value=item.url)
|
||||
.column
|
||||
.field
|
||||
label.label= lang('NOTE_PRICE')
|
||||
.control
|
||||
input.input(name='price', value=item.price)
|
||||
.column
|
||||
.field
|
||||
label.label= lang('NOTE_IMAGE_URL')
|
||||
.control
|
||||
input.input(name='image', value=item.image)
|
||||
.column.is-narrow
|
||||
.field
|
||||
label.label= lang('NOTE_GET_PRODUCT_DATA')
|
||||
input.is-ghost.button(type='submit', value=lang('NOTE_REFRESH_DATA') style='width: 100%;', form='refreshform')
|
||||
.field
|
||||
label.label= lang('NOTE_NOTE')
|
||||
.control
|
||||
textarea.textarea(
|
||||
name='note'
|
||||
)= item.note
|
||||
.field.inline
|
||||
.control.inline
|
||||
input.button.is-primary(type='submit' value=lang('NOTE_SAVE_BUTTON'))
|
21
src/views/profile-password.pug
Normal file
21
src/views/profile-password.pug
Normal file
|
@ -0,0 +1,21 @@
|
|||
extends layout.pug
|
||||
|
||||
block content
|
||||
a.button(href=`${_CC.config.base}profile`)= lang('BACK_BUTTON')
|
||||
form(method='POST')
|
||||
.field
|
||||
label.label= lang('PROFILE_PASSWORD_OLD')
|
||||
.control.has-icons-left
|
||||
input.input(type='password', name='oldPassword', placeholder=lang('PROFILE_PASSWORD_PLACEHOLDER'))
|
||||
span.icon.is-small.is-left
|
||||
i.fas.fa-lock
|
||||
.field
|
||||
label.label= lang('PROFILE_PASSWORD_NEW')
|
||||
.control.has-icons-left
|
||||
input.input(type='password', name='newPassword', placeholder=lang('PROFILE_PASSWORD_PLACEHOLDER'))
|
||||
span.icon.is-small.is-left
|
||||
i.fas.fa-lock
|
||||
.field
|
||||
.control
|
||||
input.button.is-primary(type='submit' value=lang('PROFILE_PASSWORD_BUTTON'))
|
||||
|
32
src/views/profile.pug
Normal file
32
src/views/profile.pug
Normal file
|
@ -0,0 +1,32 @@
|
|||
extends layout.pug
|
||||
|
||||
block content
|
||||
if config.pfp
|
||||
h2= lang('PROFILE_HEADER')
|
||||
div(style='margin-top: 1em;')
|
||||
.columns(style='margin-top: 1em;')
|
||||
.column.is-narrow
|
||||
.box
|
||||
.columns
|
||||
.column
|
||||
figure.image.is-square(style='display: inline-block; width: 90%;')
|
||||
img.is-rounded(src=req.user.pfp, style='object-fit: cover;')
|
||||
.column.is-narrow
|
||||
.column
|
||||
span.is-size-3= req.user._id
|
||||
br
|
||||
br
|
||||
form(action=`${_CC.config.base}profile/pfp`, method='POST')
|
||||
label.label= lang('PROFILE_PFP_IMAGE_URL')
|
||||
.field.has-addons
|
||||
.control
|
||||
input.input(name='image', value=req.user.pfp)
|
||||
.control
|
||||
button.button.is-primary(type='submit')
|
||||
span.icon
|
||||
i.fas.fa-save
|
||||
h2= lang('PROFILE_SECURITY')
|
||||
a.button.is-primary(href=`${_CC.config.base}profile/password`)
|
||||
span.icon
|
||||
i.fas.fa-shield-alt
|
||||
span= lang('PROFILE_SECURITY_CHANGE_PASSWORD')
|
34
src/views/resetpw.pug
Normal file
34
src/views/resetpw.pug
Normal file
|
@ -0,0 +1,34 @@
|
|||
extends layout.pug
|
||||
|
||||
mixin icon(c, text)
|
||||
.columns.is-vcentered.is-mobile
|
||||
.column.is-narrow
|
||||
span.icon.is-large
|
||||
i.fa-3x(class=c)
|
||||
.column #{text}
|
||||
|
||||
block title
|
||||
if doc
|
||||
h1= lang('RESET_PASSWORD_HEADER_VALID')
|
||||
else
|
||||
h1= lang('RESET_PASSWORD_HEADER_INVALID')
|
||||
|
||||
block content
|
||||
if doc
|
||||
if doc.pwExpiry > new Date().getTime()
|
||||
+icon('fas fa-smile-beam', lang('RESET_PASSWORD_GREETING_VALID', doc._id))
|
||||
form(method='POST')
|
||||
.field
|
||||
label.label= lang('RESET_PASSWORD_PASSWORD')
|
||||
.control.has-icons-left
|
||||
input.input(type='password', name='password', placeholder=lang('RESET_PASSWORD_PASSWORD_PLACEHOLDER'))
|
||||
span.icon.is-small.is-left
|
||||
i.fas.fa-lock
|
||||
.field
|
||||
.control
|
||||
input.button.is-primary(type='submit' value=`Reset Password`)
|
||||
else
|
||||
+icon('fas fa-frown-open', lang('RESET_PASSWORD_GREETING_EXPIRED'))
|
||||
else
|
||||
+icon('fas fa-frown-open', lang('RESET_PASSWORD_INVALID'))
|
||||
|
20
src/views/setup.pug
Normal file
20
src/views/setup.pug
Normal file
|
@ -0,0 +1,20 @@
|
|||
extends layout.pug
|
||||
|
||||
block content
|
||||
h2= lang('SETUP_ADMIN_USER')
|
||||
form(action=`${_CC.config.base}setup`, method='POST')
|
||||
.field
|
||||
label.label= lang('SETUP_USERNAME')
|
||||
.control.has-icons-left
|
||||
input.input(type='text', name='adminUsername', placeholder=lang('SETUP_USERNAME_PLACEHOLDER'))
|
||||
span.icon.is-small.is-left
|
||||
i.fas.fa-user
|
||||
.field
|
||||
label.label= lang('SETUP_PASSWORD')
|
||||
.control.has-icons-left
|
||||
input.input(type='password', name='adminPassword', placeholder=lang('SETUP_PASSWORD_PLACEHOLDER'))
|
||||
span.icon.is-small.is-left
|
||||
i.fas.fa-lock
|
||||
.field
|
||||
.control
|
||||
input.button.is-primary(type='submit' value=lang('SETUP_BUTTON'))
|
10
src/views/supported-sites.pug
Normal file
10
src/views/supported-sites.pug
Normal file
|
@ -0,0 +1,10 @@
|
|||
extends layout.pug
|
||||
|
||||
block content
|
||||
if req.headers.referer
|
||||
span.is-size-3(style='margin-top: 0; padding-top: 0;')
|
||||
a(href=req.headers.referer) < #{lang('BACK_BUTTON')}
|
||||
ul
|
||||
for site of _CC.require('get-product-name').sites
|
||||
li= site.name
|
||||
p!= lang('SUPPORTED_SITES_TEXT')
|
247
src/views/wishlist.pug
Normal file
247
src/views/wishlist.pug
Normal file
|
@ -0,0 +1,247 @@
|
|||
extends layout.pug
|
||||
|
||||
block title
|
||||
h1
|
||||
.level
|
||||
.level-left
|
||||
.level-item
|
||||
button.button.is-rounded(onclick='this.firstChild.firstChild.classList.add("fa-pulse"); location.reload()')
|
||||
span.icon
|
||||
i.fas.fa-sync-alt
|
||||
.level-item
|
||||
span= lang('WISHLIST_TITLE', name)
|
||||
|
||||
block content
|
||||
script(type='data/user_id')= req.user._id
|
||||
if global._CC.config.wishlist.table
|
||||
.box
|
||||
table.table.has-mobile-cards
|
||||
thead
|
||||
th #
|
||||
th(style='width: 15%;')= lang('WISHLIST_IMAGE')
|
||||
th(style='width: 25%;')= lang('WISHLIST_NAME')
|
||||
th(style='width: 50%;')= lang('WISHLIST_NOTE')
|
||||
th(style='width: 10%;')= lang('WISHLIST_PRICE')
|
||||
th= lang('WISHLIST_EDIT_ITEM')
|
||||
th= lang('WISHLIST_ADDED_BY')
|
||||
if req.params.user === req.user._id
|
||||
th= lang('WISHLIST_MOVE_TOP')
|
||||
th= lang('WISHLIST_MOVE_UP')
|
||||
th= lang('WISHLIST_MOVE_DOWN')
|
||||
else
|
||||
th= lang('WISHLIST_PLEDGE')
|
||||
th= lang('WISHLIST_DELETE')
|
||||
tbody
|
||||
each item, index in wishlist
|
||||
if req.user._id === item.addedBy || req.params.user !== req.user._id
|
||||
tr(id=item.id)
|
||||
td.rank= index + 1
|
||||
td
|
||||
figure(style='width: 100%; margin: 0;')
|
||||
img(src=item.image, style='width: 100%; max-height: 20em; object-fit: contain;')
|
||||
if item.url
|
||||
td.ugc(data-label='Name')
|
||||
a(
|
||||
href=item.url,
|
||||
rel='noopener noreferrer',
|
||||
target='_blank'
|
||||
)= (item.name ? item.name : item.url)
|
||||
else
|
||||
td.ugc(data-label=lang('WISHLIST_NAME'))= item.name
|
||||
if _CC.config.wishlist.note.markdown
|
||||
td.ugc(data-label=lang('WISHLIST_NOTE'))
|
||||
div!= item.note
|
||||
else
|
||||
td.ugc(data-label=lang('WISHLIST_NOTE'))= item.note
|
||||
td.ugc(data-label=lang('WISHLIST_PRICE'))= item.price
|
||||
td(data-label=lang('WISHLIST_EDIT_ITEM'))
|
||||
form.inline(method='GET', action=`${_CC.config.base}wishlist/${req.params.user}/note/${item.id}`)
|
||||
.field.inline
|
||||
.control.inline
|
||||
button.button.is-text(
|
||||
type='submit',
|
||||
style='text-decoration: none;'
|
||||
disabled=item.addedBy !== req.user._id
|
||||
)
|
||||
span.icon
|
||||
i.far.fa-edit
|
||||
td.ugc(data-label=lang('WISHLIST_ADDED_BY'))= item.addedBy
|
||||
if req.params.user === req.user._id
|
||||
td(data-label=lang('WISHLIST_MOVE_ITEM_TOP'))
|
||||
form.topForm.inline(method='POST', action=`${_CC.config.base}wishlist/${req.params.user}/move/top/${item.id}`)
|
||||
.field.inline
|
||||
.control.inline
|
||||
button.button.is-text(
|
||||
type='submit',
|
||||
style='text-decoration: none;',
|
||||
disabled=index === firstCanSee
|
||||
)
|
||||
span.icon
|
||||
i.fas.fa-angle-double-up
|
||||
td(data-label=lang('WISHLIST_MOVE_ITEM_UP'))
|
||||
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(
|
||||
type='submit',
|
||||
style='text-decoration: none;',
|
||||
disabled=index === firstCanSee
|
||||
)
|
||||
span.icon
|
||||
i.fas.fa-arrow-up
|
||||
td(data-label=lang('WISHLIST_MOVE_ITEM_DOWN'))
|
||||
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(
|
||||
type='submit',
|
||||
style='text-decoration: none;',
|
||||
disabled=index === lastCanSee
|
||||
)
|
||||
span.icon
|
||||
i.fas.fa-arrow-down
|
||||
else
|
||||
td(data-label=lang('WISHLIST_PLEDGE'))
|
||||
if req.params.user !== req.user._id && !item.pledgedBy
|
||||
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=lang('WISHLIST_PLEDGE_ITEM'))
|
||||
if item.pledgedBy === req.user._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=lang('WISHLIST_UNPLEDGE'))
|
||||
if item.pledgedBy && item.pledgedBy !== req.user._id
|
||||
if item.pledgedBy === '_CCUNKNOWN'
|
||||
span.ugc=lang('WISHLIST_PLEDGED_GUEST')
|
||||
else
|
||||
span.ugc=lang('WISHLIST_PLEDGED', item.pledgedBy)
|
||||
td(data-label='Delete Item')
|
||||
form.inline(
|
||||
method='POST',
|
||||
action=`${_CC.config.base}wishlist/${req.params.user}/remove/${item.id}`
|
||||
)
|
||||
.field.inline
|
||||
.control.inline
|
||||
button.button.is-text(
|
||||
type='submit',
|
||||
style='text-decoration: none;',
|
||||
disabled=item.addedBy !== req.user._id
|
||||
)
|
||||
span.icon
|
||||
i.fas.fa-trash
|
||||
|
||||
else
|
||||
each item, index in wishlist
|
||||
if req.user._id === item.addedBy || req.params.user !== req.user._id
|
||||
.box
|
||||
if item.price
|
||||
.tag
|
||||
i.fas.fa-tag(style='margin-right: .5em;')
|
||||
span= item.price
|
||||
span.overflowWrap
|
||||
if item.price
|
||||
span= ' '
|
||||
if item.url
|
||||
a(
|
||||
href=item.url,
|
||||
rel='noopener noreferrer',
|
||||
target='_blank'
|
||||
)= (item.name ? item.name : item.url)
|
||||
else
|
||||
span= item.name
|
||||
hr
|
||||
if item.note || item.image
|
||||
.columns
|
||||
if item.image
|
||||
.column
|
||||
figure(style='width: 100%; padding: 2em;')
|
||||
img(src=item.image, style='width: 100%;')
|
||||
.column.is-three-quarters
|
||||
if item.note
|
||||
textarea.textarea.has-fixed-size(
|
||||
style='height: 100%;'
|
||||
readonly
|
||||
)= item.note
|
||||
span.overflowWrap=lang('WISHLIST_ADDED_BY', item.addedBy)
|
||||
hr
|
||||
div
|
||||
if req.params.user !== req.user._id && !item.pledgedBy
|
||||
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=lang('WISHLIST_PLEDGE'))
|
||||
if item.pledgedBy === req.user._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=lang('WISHLIST_UNPLEDGE'))
|
||||
if req.user._id === req.params.user
|
||||
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=lang('WISHLIST_DELETE'))
|
||||
if req.user._id === req.params.user || req.user._id === item.addedBy
|
||||
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=lang('WISHLIST_EDIT_ITEM'))
|
||||
if index !== firstCanSee && req.user._id === req.params.user
|
||||
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=lang('WISHLIST_MOVE_ITEM_UP'))
|
||||
if index !== lastCanSee && req.user._id === req.params.user
|
||||
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=lang('WISHLIST_MOVE_ITEM_DOWN'))
|
||||
form(method='POST')
|
||||
.field
|
||||
label.label!=lang('WISHLIST_URL_LABEL')
|
||||
.control.has-icons-left
|
||||
input.input(
|
||||
type='text',
|
||||
name='itemUrlOrName',
|
||||
placeholder=lang('WISHLIST_URL_PLACEHOLDER')
|
||||
)
|
||||
span.icon.is-small.is-left
|
||||
i.fas.fa-gift
|
||||
.field
|
||||
label.label= lang('WISHLIST_NOTE')
|
||||
.control
|
||||
textarea.textarea(
|
||||
name='note',
|
||||
placeholder=lang('WISHLIST_OPTIONAL')
|
||||
)
|
||||
.field.is-grouped
|
||||
.control
|
||||
input.button(type='submit' value=(req.user._id === req.params.user ? lang('WISHLIST_ADD') : lang('WISHLIST_PLEDGE_ITEM')))
|
||||
if req.user._id !== req.params.user
|
||||
.control
|
||||
input.inline.button(type='submit', value=lang('WISHLIST_SUGGEST'), name='suggest')
|
||||
script(src=`${_CC.config.base}js/wishlist.js`)
|
||||
|
||||
block print
|
||||
h1 #{req.params.user}'s Wishlist
|
||||
.print-gifts
|
||||
each item, index in wishlist.filter(item => item.addedBy === req.params.user)
|
||||
.print-gift(style='page-break-inside: avoid;')
|
||||
if index > 0
|
||||
hr(style='margin-top: .5em; margin-bottom: .5em; background-color: black;')
|
||||
if item.price
|
||||
.tag
|
||||
i.fas.fa-tag(style='margin-right: .5em;')
|
||||
span= item.price
|
||||
span= ' '
|
||||
span.is-size-6.ugc= item.name
|
||||
span= ' '
|
||||
span.ugc.has-text-grey= item.url
|
||||
span.is-block Added by: #{item.addedBy}
|
||||
if item.note
|
||||
.box
|
||||
if _CC.config.wishlist.note.markdown
|
||||
span.is-block.ugc!= item.note
|
||||
else
|
||||
span.is-block.ugc= item.note
|
84
src/views/wishlists.pug
Normal file
84
src/views/wishlists.pug
Normal file
|
@ -0,0 +1,84 @@
|
|||
extends layout.pug
|
||||
|
||||
mixin wishlistDetails(wishlist, onlyShowAddedByUser)
|
||||
.wishlist-dropdown-container.wishlist-dropdown-container-unloaded
|
||||
button.wishlist-dropdown-button.button.is-rounded
|
||||
span.icon.is-small
|
||||
i.fas.fa-chevron-left
|
||||
i.fas.fa-chevron-down
|
||||
ul.wishlist-dropdown
|
||||
for item in wishlist
|
||||
if onlyShowAddedByUser === undefined || item.addedBy === onlyShowAddedByUser
|
||||
li= item.name
|
||||
|
||||
block content
|
||||
style.
|
||||
.wishlist-dropdown-container-unloaded {
|
||||
display: none;
|
||||
}
|
||||
.wishlist-dropdown-button {
|
||||
margin-left: auto;
|
||||
margin-right: 0;
|
||||
display: block;
|
||||
}
|
||||
.wishlist-dropdown {
|
||||
display: none;
|
||||
}
|
||||
.wishlist-dropdown li {
|
||||
list-style-type: disc !important;
|
||||
}
|
||||
.wishlist-dropdown-container-active > .wishlist-dropdown {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.wishlist-dropdown-container .fa-chevron-left {
|
||||
display: inline-block;
|
||||
}
|
||||
.wishlist-dropdown-container .fa-chevron-down {
|
||||
display: none;
|
||||
}
|
||||
.wishlist-dropdown-container.wishlist-dropdown-container-active .fa-chevron-left {
|
||||
display: none;
|
||||
}
|
||||
.wishlist-dropdown-container.wishlist-dropdown-container-active .fa-chevron-down {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
ul.noStyle.noLeftMargin
|
||||
if req.user._id !== '_CCUNKNOWN'
|
||||
li
|
||||
.box
|
||||
a(href=`${_CC.config.base}wishlist/${req.user._id}`, style='color: #4a4a4a;')
|
||||
.columns.is-mobile
|
||||
if config.pfp
|
||||
.column.is-1(style='overflow: hidden; padding: 0 0.5rem 0 0;')
|
||||
figure.image.is-square.is-fullwidth.is-marginless(style='display: inline-block;')
|
||||
img.is-rounded.is-fullwidth(src=req.user.pfp, style='object-fit: cover;')
|
||||
.column
|
||||
span
|
||||
span=lang('WISHLISTS_COUNTS_SELF', req.user._id)
|
||||
progress.progress(value=1, max=1)
|
||||
+wishlistDetails(req.user.wishlist, req.user._id)
|
||||
each user in users
|
||||
if req.user._id !== user.id
|
||||
li
|
||||
.box
|
||||
a(href=`${_CC.config.base}wishlist/${user.id}`, style='color: #4a4a4a;')
|
||||
.columns.is-mobile
|
||||
if config.pfp
|
||||
.column.is-1(style='overflow: hidden; padding: 0 0.5rem 0 0;')
|
||||
figure.image.is-square.is-fullwidth.is-marginless(style='display: inline-block;')
|
||||
img.is-rounded.is-fullwidth(src=user.doc.pfp, style='object-fit: cover;')
|
||||
.column
|
||||
span= lang('WISHLISTS_COUNTS', user.id, totals(user.doc.wishlist).pledged, user.doc.wishlist.length)
|
||||
progress.progress.is-info(value=totals(user.doc.wishlist).pledged, max=user.doc.wishlist.length)
|
||||
+wishlistDetails(user.doc.wishlist)
|
||||
script.
|
||||
document.querySelectorAll('.wishlist-dropdown-button')
|
||||
.forEach(button => {
|
||||
button.addEventListener('click', e => {
|
||||
button.parentElement.classList.toggle('wishlist-dropdown-container-active')
|
||||
})
|
||||
})
|
||||
document.querySelectorAll('.wishlist-dropdown-container-unloaded')
|
||||
.forEach(container => container.classList.remove('wishlist-dropdown-container-unloaded'))
|
Loading…
Add table
Add a link
Reference in a new issue