Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
28cf67cd
Commit
28cf67cd
authored
Jun 21, 2019
by
Nick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: sideloading + locales nav menu
parent
e4fc2b7b
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
151 additions
and
23 deletions
+151
-23
nav-header.vue
client/components/common/nav-header.vue
+14
-16
config.sample.yml
config.sample.yml
+8
-0
master.pug
dev/templates/master.pug
+1
-1
data.yml
server/app/data.yml
+4
-0
kernel.js
server/core/kernel.js
+1
-0
scheduler.js
server/core/scheduler.js
+5
-1
sideloader.js
server/core/sideloader.js
+76
-0
telemetry.js
server/core/telemetry.js
+1
-1
localization.js
server/graph/resolvers/localization.js
+2
-0
master.js
server/master.js
+13
-3
locales.js
server/models/locales.js
+25
-0
master.pug
server/views/master.pug
+1
-1
No files found.
client/components/common/nav-header.vue
View file @
28cf67cd
...
...
@@ -137,17 +137,17 @@
icon
)
v-icon(color='grey') search
//- v-menu(offset-y, left, transition='slide-y-transition
')
//-
v-tooltip(bottom, slot='activator')
//-
v-btn(icon, slot='activator')
//-
v-icon(color='grey') language
//-
span Language
//-
v-list.py-0
//-
template(v-for='(lc, idx) of locales')
//-
v-list-tile(@click='changeLocale(lc)')
//-
v-list-tile-action: v-chip(:color='lc.code === $i18n.i18next.language ? `blue` : `grey`', small, label, dark)
{{
lc
.
code
.
toUpperCase
()
}}
//-
v-list-tile-title
{{
lc
.
name
}}
//-
v-divider.my-0(v-if='idx < locales.length - 1')
v-menu(offset-y, left, transition='slide-y-transition', v-if='mode === `view` && locales.length > 0
')
v-tooltip(bottom, slot='activator')
v-btn(icon, slot='activator')
v-icon(color='grey') language
span Language
v-list.py-0
template(v-for='(lc, idx) of locales')
v-list-tile(@click='changeLocale(lc)')
v-list-tile-action: v-chip(:color='lc.code === $i18n.i18next.language ? `blue` : `grey`', small, label, dark)
{{
lc
.
code
.
toUpperCase
()
}}
v-list-tile-title
{{
lc
.
name
}}
v-divider.my-0(v-if='idx < locales.length - 1')
v-tooltip(bottom, v-if='isAuthenticated && isAdmin')
v-btn.btn-animate-rotate(icon, href='/a', slot='activator')
v-icon(color='grey') settings
...
...
@@ -196,6 +196,8 @@ import { get, sync } from 'vuex-pathify'
import
_
from
'lodash'
import
Cookies
from
'js-cookie'
/* global siteLangs */
export
default
{
components
:
{
PageDelete
:
()
=>
import
(
'./page-delete.vue'
)
...
...
@@ -217,11 +219,7 @@ export default {
searchAdvMenuShown
:
false
,
newPageModal
:
false
,
deletePageModal
:
false
,
locales
:
[
{
code
:
'en'
,
name
:
'English'
},
{
code
:
'fr'
,
name
:
'Français'
},
{
code
:
'es'
,
name
:
'Español'
}
]
locales
:
siteLangs
}
},
computed
:
{
...
...
config.sample.yml
View file @
28cf67cd
...
...
@@ -105,3 +105,11 @@ uploads:
maxFileSize
:
5242880
# Maximum file uploads per request (default: 20)
maxFiles
:
10
# ---------------------------------------------------------------------
# Offline Mode
# ---------------------------------------------------------------------
# If your server cannot access the internet. Set to true and manually
# download the offline files for sideloading.
offline
:
false
dev/templates/master.pug
View file @
28cf67cd
...
...
@@ -29,7 +29,7 @@ html
//- Site Properties
script.
var siteConfig = !{JSON.stringify(
{ title: config.title, theme: config.theming.theme, darkMode: config.theming.darkMode, lang: config.lang.code, rtl: config.lang.rtl, company: config.company }
)}
var siteConfig = !{JSON.stringify(
siteConfig)}; var siteLangs = !{JSON.stringify(langs
)}
//- CSS
<% for (var index in htmlWebpackPlugin.files.css) { %>
...
...
server/app/data.yml
View file @
28cf67cd
...
...
@@ -24,6 +24,7 @@ defaults:
uploads
:
maxFileSize
:
5242880
maxFiles
:
10
offline
:
false
# DB defaults
graphEndpoint
:
'
https://graph.requarks.io'
lang
:
...
...
@@ -63,12 +64,15 @@ jobs:
purgeUploads
:
onInit
:
true
schedule
:
PT15M
offlineSkip
:
false
syncGraphLocales
:
onInit
:
true
schedule
:
P1D
offlineSkip
:
true
syncGraphUpdates
:
onInit
:
true
schedule
:
P1D
offlineSkip
:
true
groups
:
defaultPermissions
:
-
'
read:pages'
...
...
server/core/kernel.js
View file @
28cf67cd
...
...
@@ -34,6 +34,7 @@ module.exports = {
await
this
.
initTelemetry
()
WIKI
.
cache
=
require
(
'./cache'
).
init
()
WIKI
.
scheduler
=
require
(
'./scheduler'
).
init
()
WIKI
.
sideloader
=
require
(
'./sideloader'
).
init
()
WIKI
.
events
=
new
EventEmitter
()
}
catch
(
err
)
{
WIKI
.
logger
.
error
(
err
)
...
...
server/core/scheduler.js
View file @
28cf67cd
...
...
@@ -87,7 +87,6 @@ class Job {
}
}
module
.
exports
=
{
jobs
:
[],
init
()
{
...
...
@@ -95,6 +94,11 @@ module.exports = {
},
start
()
{
_
.
forOwn
(
WIKI
.
data
.
jobs
,
(
queueParams
,
queueName
)
=>
{
if
(
WIKI
.
config
.
offline
&&
queueParams
.
offlineSkip
)
{
WIKI
.
logger
.
warn
(
`Skipping job
${
queueName
}
because offline mode is enabled. [SKIPPED]`
)
return
}
const
schedule
=
(
configHelper
.
isValidDurationString
(
queueParams
.
schedule
))
?
queueParams
.
schedule
:
_
.
get
(
WIKI
.
config
,
queueParams
.
schedule
)
this
.
registerJob
({
name
:
_
.
kebabCase
(
queueName
),
...
...
server/core/sideloader.js
0 → 100644
View file @
28cf67cd
const
fs
=
require
(
'fs-extra'
)
const
path
=
require
(
'path'
)
const
_
=
require
(
'lodash'
)
/* global WIKI */
module
.
exports
=
{
async
init
()
{
if
(
!
WIKI
.
config
.
offline
)
{
return
}
const
sideloadExists
=
await
fs
.
pathExists
(
path
.
join
(
WIKI
.
ROOTPATH
,
'data/sideload'
))
if
(
!
sideloadExists
)
{
return
}
WIKI
.
logger
.
info
(
'Sideload directory detected. Looking for packages...'
)
try
{
await
this
.
importLocales
()
}
catch
(
err
)
{
WIKI
.
logger
.
warn
(
err
)
}
},
async
importLocales
()
{
const
localeExists
=
await
fs
.
pathExists
(
path
.
join
(
WIKI
.
ROOTPATH
,
'data/sideload/locales.json'
))
if
(
localeExists
)
{
WIKI
.
logger
.
info
(
'Found locales master file. Importing locale packages...'
)
let
importedLocales
=
0
const
locales
=
await
fs
.
readJson
(
path
.
join
(
WIKI
.
ROOTPATH
,
'data/sideload/locales.json'
))
if
(
locales
&&
_
.
has
(
locales
,
'data.localization.locales'
))
{
for
(
const
locale
of
locales
.
data
.
localization
.
locales
)
{
try
{
const
localeData
=
await
fs
.
readJson
(
path
.
join
(
WIKI
.
ROOTPATH
,
`data/sideload/
${
locale
.
code
}
.json`
))
if
(
localeData
)
{
WIKI
.
logger
.
info
(
`Importing
${
locale
.
name
}
locale package...`
)
let
lcObj
=
{}
_
.
forOwn
(
localeData
,
(
value
,
key
)
=>
{
if
(
_
.
includes
(
key
,
'::'
))
{
return
}
if
(
_
.
isEmpty
(
value
))
{
value
=
key
}
_
.
set
(
lcObj
,
key
.
replace
(
':'
,
'.'
),
value
)
})
const
localeExists
=
await
WIKI
.
models
.
locales
.
query
().
select
(
'code'
).
where
(
'code'
,
locale
.
code
).
first
()
if
(
localeExists
)
{
await
WIKI
.
models
.
locales
.
query
().
update
({
code
:
locale
.
code
,
strings
:
lcObj
,
isRTL
:
locale
.
isRTL
,
name
:
locale
.
name
,
nativeName
:
locale
.
nativeName
}).
where
(
'code'
,
locale
.
code
)
}
else
{
await
WIKI
.
models
.
locales
.
query
().
insert
({
code
:
locale
.
code
,
strings
:
lcObj
,
isRTL
:
locale
.
isRTL
,
name
:
locale
.
name
,
nativeName
:
locale
.
nativeName
})
}
importedLocales
++
}
}
catch
(
err
)
{
// skip
}
}
WIKI
.
logger
.
info
(
`Imported
${
importedLocales
}
locale packages: [COMPLETED]`
)
}
}
}
}
server/core/telemetry.js
View file @
28cf67cd
...
...
@@ -28,7 +28,7 @@ module.exports = {
})
WIKI
.
telemetry
=
this
if
(
_
.
get
(
WIKI
.
config
,
'telemetry.isEnabled'
,
false
)
===
true
)
{
if
(
_
.
get
(
WIKI
.
config
,
'telemetry.isEnabled'
,
false
)
===
true
&&
WIKI
.
config
.
offline
!==
true
)
{
this
.
enabled
=
true
this
.
sendOSInfo
()
}
...
...
server/graph/resolvers/localization.js
View file @
28cf67cd
...
...
@@ -66,6 +66,8 @@ module.exports = {
await
WIKI
.
lang
.
setCurrentLocale
(
args
.
locale
)
await
WIKI
.
lang
.
refreshNamespaces
()
await
WIKI
.
cache
.
del
(
'nav:locales'
)
return
{
responseResult
:
graphHelper
.
generateSuccess
(
'Locale config updated'
)
}
...
...
server/master.js
View file @
28cf67cd
...
...
@@ -105,9 +105,6 @@ module.exports = async () => {
// ----------------------------------------
app
.
locals
.
basedir
=
WIKI
.
ROOTPATH
app
.
locals
.
_
=
require
(
'lodash'
)
app
.
locals
.
moment
=
require
(
'moment'
)
app
.
locals
.
moment
.
locale
(
WIKI
.
config
.
lang
.
code
)
app
.
locals
.
config
=
WIKI
.
config
app
.
locals
.
pageMeta
=
{
title
:
''
,
...
...
@@ -146,6 +143,19 @@ module.exports = async () => {
// Routing
// ----------------------------------------
app
.
use
(
async
(
req
,
res
,
next
)
=>
{
res
.
locals
.
siteConfig
=
{
title
:
WIKI
.
config
.
title
,
theme
:
WIKI
.
config
.
theming
.
theme
,
darkMode
:
WIKI
.
config
.
theming
.
darkMode
,
lang
:
WIKI
.
config
.
lang
.
code
,
rtl
:
WIKI
.
config
.
lang
.
rtl
,
company
:
WIKI
.
config
.
company
}
res
.
locals
.
langs
=
await
WIKI
.
models
.
locales
.
getNavLocales
({
cache
:
true
})
next
()
})
app
.
use
(
'/'
,
ctrl
.
auth
)
app
.
use
(
'/'
,
ctrl
.
upload
)
app
.
use
(
'/'
,
ctrl
.
common
)
...
...
server/models/locales.js
View file @
28cf67cd
const
Model
=
require
(
'objection'
).
Model
/* global WIKI */
/**
* Locales model
*/
...
...
@@ -34,4 +36,27 @@ module.exports = class Locale extends Model {
this
.
createdAt
=
new
Date
().
toISOString
()
this
.
updatedAt
=
new
Date
().
toISOString
()
}
static
async
getNavLocales
({
cache
=
false
}
=
{})
{
if
(
!
WIKI
.
config
.
lang
.
namespacing
)
{
return
[]
}
if
(
cache
)
{
const
navLocalesCached
=
await
WIKI
.
cache
.
get
(
'nav:locales'
)
if
(
navLocalesCached
)
{
return
navLocalesCached
}
}
const
navLocales
=
await
WIKI
.
models
.
locales
.
query
().
select
(
'code'
,
'nativeName AS name'
).
whereIn
(
'code'
,
WIKI
.
config
.
lang
.
namespaces
).
orderBy
(
'code'
)
if
(
navLocales
)
{
if
(
cache
)
{
await
WIKI
.
cache
.
set
(
'nav:locales'
,
navLocales
,
300
)
}
return
navLocales
}
else
{
WIKI
.
logger
.
warn
(
'Site Locales for navigation are missing or corrupted.'
)
return
[]
}
}
}
server/views/master.pug
View file @
28cf67cd
...
...
@@ -29,7 +29,7 @@ html
//- Site Properties
script.
var siteConfig = !{JSON.stringify(
{ title: config.title, theme: config.theming.theme, darkMode: config.theming.darkMode, lang: config.lang.code, rtl: config.lang.rtl, company: config.company }
)}
var siteConfig = !{JSON.stringify(
siteConfig)}; var siteLangs = !{JSON.stringify(langs
)}
//- CSS
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment