feat: Admin localization

This commit is contained in:
NGPixel 2017-05-03 22:10:12 -04:00
parent 5cf775d7ec
commit b3e3973b90
8 changed files with 150 additions and 109 deletions

View File

@ -32,6 +32,7 @@ global.db = require('./libs/db').init()
global.upl = require('./libs/uploads-agent').init() global.upl = require('./libs/uploads-agent').init()
global.git = require('./libs/git').init() global.git = require('./libs/git').init()
global.entries = require('./libs/entries').init() global.entries = require('./libs/entries').init()
global.lang = require('i18next')
global.mark = require('./libs/markdown') global.mark = require('./libs/markdown')
// ---------------------------------------- // ----------------------------------------
@ -43,9 +44,31 @@ const Promise = require('bluebird')
const fs = Promise.promisifyAll(require('fs-extra')) const fs = Promise.promisifyAll(require('fs-extra'))
const klaw = require('klaw') const klaw = require('klaw')
const Cron = require('cron').CronJob const Cron = require('cron').CronJob
const i18nextBackend = require('i18next-node-fs-backend')
const i18nextMw = require('i18next-express-middleware')
const entryHelper = require('./helpers/entry') const entryHelper = require('./helpers/entry')
// ----------------------------------------
// Localization Engine
// ----------------------------------------
lang
.use(i18nextBackend)
.use(i18nextMw.LanguageDetector)
.init({
load: 'languageOnly',
ns: ['common', 'errors', 'git'],
defaultNS: 'common',
saveMissing: false,
supportedLngs: ['en', 'fr'],
preload: ['en', 'fr'],
fallbackLng: 'en',
backend: {
loadPath: path.join(SERVERPATH, 'locales/{{lng}}/{{ns}}.json')
}
})
// ---------------------------------------- // ----------------------------------------
// Start Cron // Start Cron
// ---------------------------------------- // ----------------------------------------

View File

@ -124,7 +124,7 @@ lang
.use(i18nextMw.LanguageDetector) .use(i18nextMw.LanguageDetector)
.init({ .init({
load: 'languageOnly', load: 'languageOnly',
ns: ['common', 'auth'], ns: ['common', 'admin', 'auth', 'errors', 'git'],
defaultNS: 'common', defaultNS: 'common',
saveMissing: false, saveMissing: false,
supportedLngs: ['en', 'fr'], supportedLngs: ['en', 'fr'],

View File

@ -0,0 +1,51 @@
{
"profile": {
"displayname": "Display Name",
"displaynameexample": "John Smith",
"email": "Email",
"lastprofileupdate": "Last Profile Update",
"membersince": "Member since",
"password": "Password",
"passwordverify": "Verify Password",
"provider": "Provider",
"savechanges": "Save Changes",
"subtitle": "Profile and authentication info"
},
"stats": {
"subtitle": "General site-wide statistics",
"entries": "Entries",
"uploads": "Uploads",
"users": "Users"
},
"settings": {
"subtitle": "Manage site configuration",
"systemversion": "System Version",
"currentversion": "Current Version",
"latestversion": "Latest Version",
"upgrade": "Upgrade",
"reinstall": "Re-install current version",
"versioncheckfailed": "Unable to query latest version. Try again later.",
"administrativetools": "Administrative Tools",
"flushcache": "Flush cache and rebuild indexes",
"flushcachetext": "If content or search results seems out-of-date or do not include latest content, flushing the cache can help resolve these issues.",
"flushcachebtn": "Flush and Rebuild",
"resetaccounts": "Reset the system accounts to defaults",
"resetaccountstext": "The system accounts (such as the Guest account) will be reset to their default settings.",
"resetaccountsbtn": "Reset System Accounts",
"flushsessions": "Flush all active user sessions",
"flushsessionstext": "All users will be logged out and forced to login again. Your current session will also be affected!",
"flushsessionsbtn": "Flush Sessions"
},
"users": {
"createauthorize": "Create / Authorize User",
"subtitle": "Manage users and access rights",
"name": "Name",
"email": "Email Address",
"provider": "Provider",
"createdon": "Created On",
"updatedon": "Updated On",
"returntousers": "Return to Users",
"edituser": "Edit User",
"uniqueid": "Unique ID"
}
}

View File

@ -3,35 +3,35 @@ extends ./_layout.pug
block adminContent block adminContent
#page-type-admin-profile #page-type-admin-profile
.hero .hero
h1.title#title My Profile h1.title#title= t('nav.myprofile')
h2.subtitle Profile and authentication info h2.subtitle= t('admin:profile.subtitle')
.form-sections .form-sections
.columns.is-gapless .columns.is-gapless
.column.is-two-thirds .column.is-two-thirds
section section
label.label Email label.label= t('admin:profile.email')
p.control.is-fullwidth p.control.is-fullwidth
input.input(type='text', placeholder='Email', value=user.email, disabled) input.input(type='text', placeholder=t('admin:profile.email'), value=user.email, disabled)
if user.provider === 'local' if user.provider === 'local'
section section
label.label Password label.label= t('admin:profile.password')
p.control.is-fullwidth p.control.is-fullwidth
input.input(type='password', placeholder='Password', value='********', v-model='password') input.input(type='password', placeholder=t('admin:profile.password'), value='********', v-model='password')
section section
label.label Verify Password label.label= t('admin:profile.passwordverify')
p.control.is-fullwidth p.control.is-fullwidth
input.input(type='password', placeholder='Password', value='********', v-model='passwordVerify') input.input(type='password', placeholder=t('admin:profile.password'), value='********', v-model='passwordVerify')
section section
label.label Display Name label.label= t('admin:profile.displayname')
p.control.is-fullwidth p.control.is-fullwidth
input.input(type='text', placeholder='John Smith', v-model='name') input.input(type='text', placeholder=t('admin:profile.displaynameexample'), v-model='name')
section section
button.button.is-green(v-on:click='saveUser') button.button.is-green(v-on:click='saveUser')
i.icon-check i.icon-check
span Save Changes span= t('admin:profile.savechanges')
.column .column
.panel-aside .panel-aside
label.label Provider label.label= t('admin:profile.provider')
p.control.account-profile-provider p.control.account-profile-provider
case user.provider case user.provider
when 'local': i.icon-server when 'local': i.icon-server
@ -44,9 +44,9 @@ block adminContent
when 'ldap': i.icon-arrow-repeat-outline when 'ldap': i.icon-arrow-repeat-outline
default: i.icon-warning default: i.icon-warning
= t('auth:providers.' + user.provider) = t('auth:providers.' + user.provider)
label.label Member since label.label= t('admin:profile.membersince')
p.control= userMoment(user.createdAt).format('LL') p.control= userMoment(user.createdAt).format('LL')
label.label Last Profile Update label.label= t('admin:profile.lastprofileupdate')
p.control= userMoment(user.updatedAt).format('LL') p.control= userMoment(user.updatedAt).format('LL')
script(type='text/javascript'). script(type='text/javascript').

View File

@ -3,38 +3,35 @@ extends ./_layout.pug
block adminContent block adminContent
#page-type-admin-settings #page-type-admin-settings
.hero .hero
h1.title#title System Settings h1.title#title= t('nav.syssettings')
h2.subtitle Manage site configuration h2.subtitle= t('admin:settings.subtitle')
.form-sections .form-sections
section section
img(src='/images/logo.png', style={width:'200px', float:'right'}) img(src='/images/logo.png', style={width:'200px', float:'right'})
label.label System Version label.label= t('admin:settings.systemversion')
.section-block .section-block
p Current Version: #[strong= sysversion.current] p #{t('admin:settings.currentversion')}: #[strong= sysversion.current]
if sysversion.latest if sysversion.latest
p Latest Version: #[strong= sysversion.latest] #[em (Published #{userMoment(sysversion.latestPublishedAt).fromNow()})] p #{t('admin:settings.latestversion')}: #[strong= sysversion.latest] #[em (Published #{userMoment(sysversion.latestPublishedAt).fromNow()})]
p p
if sysversion.current !== sysversion.latest if sysversion.current !== sysversion.latest
button.button.is-deep-orange(v-on:click='upgrade') Upgrade button.button.is-deep-orange(v-on:click='upgrade')= t('admin:settings.upgrade')
else else
button.button.is-disabled Upgrade button.button.is-disabled= t('admin:settings.upgrade')
button.button.is-deep-orange.is-outlined(v-on:click='reinstall') Re-install current version button.button.is-deep-orange.is-outlined(v-on:click='reinstall')= t('admin:settings.reinstall')
else else
p: em Unable to query latest version. Try again later. p: em= t('admin:settings.versioncheckfailed')
section section
label.label Administrative Tools label.label= t('admin:settings.administrativetools')
.section-block .section-block
h6 Flush cache and rebuild indexes: h6 #{t('admin:settings.flushcache')}:
p.is-small If content or search results seems out-of-date or do not include latest content, flushing the cache can help resolve these issues. p.is-small= t('admin:settings.flushcachetext')
p: button.button.is-teal.is-outlined(v-on:click='flushcache') Flush and Rebuild p: button.button.is-teal.is-outlined(v-on:click='flushcache')= t('admin:settings.flushcachebtn')
h6 Reset the root administrator and guest accounts to defaults: h6 #{t('admin:settings.resetaccounts')}:
p.is-small p.is-small= t('admin:settings.resetaccountstext')
| The root administrator account will be reset to the email address in the configuration file and the password will be reinitialized to #[strong admin123]. p: button.button.is-teal.is-outlined(v-on:click='resetaccounts')= t('admin:settings.resetaccountsbtn')
br h6 #{t('admin:settings.flushsessions')}:
| The guest account will be recreated with its access rights set to defaults. p.is-small= t('admin:settings.flushsessionstext')
p: button.button.is-teal.is-outlined(v-on:click='resetaccounts') Reset System Accounts p: button.button.is-teal.is-outlined(v-on:click='flushsessions')= t('admin:settings.flushsessionsbtn')
h6 Flush all active user sessions:
p.is-small All users will be logged out and forced to login again. Your current session will also be affected!
p: button.button.is-teal.is-outlined(v-on:click='flushsessions') Flush Sessions
include ../../modals/admin-upgrade.pug include ../../modals/admin-upgrade.pug

View File

@ -2,13 +2,13 @@ extends ./_layout.pug
block adminContent block adminContent
.hero .hero
h1.title#title Stats h1.title#title= t('nav.stats')
h2.subtitle General site-wide statistics h2.subtitle= t('admin:stats.subtitle')
.form-sections .form-sections
section section
label.label Entries label.label= t('admin:stats.entries')
p.control= totalEntries p.control= totalEntries
label.label Uploads label.label= t('admin:stats.uploads')
p.control= totalUploads p.control= totalUploads
label.label Users label.label= t('admin:stats.users')
p.control= totalUsers p.control= totalUsers

View File

@ -5,66 +5,51 @@ block rootNavRight
.nav-item .nav-item
a.button(href='/admin/users') a.button(href='/admin/users')
i.icon-reply i.icon-reply
span Return to Users span= t('admin:users.returntousers')
block adminContent block adminContent
#page-type-admin-users-edit #page-type-admin-users-edit
.hero .hero
h1.title#title Edit User h1.title#title= t('admin:users.edituser')
h2.subtitle= usr.email h2.subtitle= usr.email
table.table table.table
thead thead
tr tr
th Unique ID th= t('admin:users.uniqueid')
th Provider th= t('admin:users.provider')
th Created On th= t('admin:users.createdon')
th Updated On th= t('admin:users.updatedon')
tbody tbody
tr tr
td.is-centered= usr._id td.is-centered= usr._id
td.is-centered.has-icons td.is-centered.has-icons
case usr.provider case usr.provider
when 'local' when 'local': i.icon-server
i.icon-server.is-deep-orange when 'windowslive': i.icon-windows2.is-blue
| Local Database when 'azure': i.icon-windows2.is-blue
when 'windowslive' when 'google': i.icon-google.is-blue
i.icon-windows2.is-blue when 'facebook': i.icon-facebook.is-indigo
| Microsoft Account when 'github': i.icon-github.is-grey
when 'azure' when 'slack': i.icon-slack.is-purple
i.icon-windows2.is-blue when 'ldap': i.icon-arrow-repeat-outline
| Azure Active Directory
when 'google'
i.icon-google.is-blue
| Google ID
when 'facebook'
i.icon-facebook.is-indigo
| Facebook
when 'github'
i.icon-github.is-blue-grey
| GitHub
when 'slack'
i.icon-slack.is-purple
| Slack
when 'ldap'
i.icon-arrow-repeat-outline
| LDAP / Active Directory
default: i.icon-warning default: i.icon-warning
= t('auth:providers.' + usr.provider)
td.is-centered= userMoment(usr.createdAt).format('lll') td.is-centered= userMoment(usr.createdAt).format('lll')
td.is-centered= userMoment(usr.updatedAt).format('lll') td.is-centered= userMoment(usr.updatedAt).format('lll')
.form-sections .form-sections
section section
label.label Email Address label.label= t('admin:profile.email')
p.control.is-fullwidth p.control.is-fullwidth
input.input(type='text', placeholder='john.smith@example.com', v-model='email', disabled=!usrOpts.canChangeEmail) input.input(type='text', placeholder='john.smith@example.com', v-model='email', disabled=!usrOpts.canChangeEmail)
section section
label.label Display Name label.label= t('admin:profile.displayname')
p.control.is-fullwidth p.control.is-fullwidth
input.input(type='text', placeholder='John Smith', v-model='name', disabled=!usrOpts.canChangeName) input.input(type='text', placeholder=t('admin:profile.displaynameexample'), v-model='name', disabled=!usrOpts.canChangeName)
if usrOpts.canChangePassword if usrOpts.canChangePassword
section section
label.label Password label.label= t('admin:profile.password')
p.control.is-fullwidth p.control.is-fullwidth
input.input(type='password', placeholder='Password', v-model='password', value='********') input.input(type='password', placeholder=t('admin:profile.password'), v-model='password', value='********')
section section
label.label Access Rights label.label Access Rights
table.table table.table

View File

@ -5,22 +5,22 @@ block rootNavRight
.nav-item .nav-item
a.button.btn-create-prompt a.button.btn-create-prompt
i.icon-plus i.icon-plus
span Create / Authorize User span= t('admin:users.createauthorize')
block adminContent block adminContent
#page-type-admin-users #page-type-admin-users
.hero .hero
h1.title#title Users h1.title#title= t('nav.users')
h2.subtitle Manage users and access rights h2.subtitle= t('admin:users.subtitle')
table.table table.table
thead thead
tr tr
th th
th Name th= t('admin:users.name')
th Email th= t('admin:users.email')
th Provider th= t('admin:users.provider')
th Created On th= t('admin:users.createdon')
th Updated On th= t('admin:users.updatedon')
tbody tbody
each usr in usrs each usr in usrs
tr tr
@ -31,31 +31,16 @@ block adminContent
td= usr.email td= usr.email
td.is-centered.has-icons td.is-centered.has-icons
case usr.provider case usr.provider
when 'local' when 'local': i.icon-server
i.icon-server.is-deep-orange when 'windowslive': i.icon-windows2.is-blue
| Local Database when 'azure': i.icon-windows2.is-blue
when 'windowslive' when 'google': i.icon-google.is-blue
i.icon-windows2.is-blue when 'facebook': i.icon-facebook.is-indigo
| Microsoft Account when 'github': i.icon-github.is-grey
when 'azure' when 'slack': i.icon-slack.is-purple
i.icon-windows2.is-blue when 'ldap': i.icon-arrow-repeat-outline
| Azure Active Directory
when 'google'
i.icon-google.is-blue
| Google ID
when 'facebook'
i.icon-facebook.is-purple
| Facebook
when 'github'
i.icon-github.is-blue-grey
| GitHub
when 'slack'
i.icon-slack.is-purple
| Slack
when 'ldap'
i.icon-arrow-repeat-outline
| LDAP / Active Directory
default: i.icon-warning default: i.icon-warning
= t('auth:providers.' + usr.provider)
td.is-centered= userMoment(usr.createdAt).format('lll') td.is-centered= userMoment(usr.createdAt).format('lll')
td.is-centered= userMoment(usr.updatedAt).format('lll') td.is-centered= userMoment(usr.updatedAt).format('lll')