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
763bf4b9
Commit
763bf4b9
authored
Nov 11, 2018
by
Nicolas Giard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: sidebar rendering
parent
0b5a4e0c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
17 deletions
+31
-17
nav-sidebar.vue
client/themes/default/components/nav-sidebar.vue
+2
-15
page.vue
client/themes/default/components/page.vue
+1
-0
common.js
server/controllers/common.js
+2
-1
navigation.js
server/graph/resolvers/navigation.js
+1
-0
navigation.js
server/models/navigation.js
+10
-1
setup.js
server/setup.js
+2
-0
page.pug
server/views/page.pug
+13
-0
No files found.
client/themes/default/components/nav-sidebar.vue
View file @
763bf4b9
<
template
lang=
"pug"
>
v-list(dense, :class='color', :dark='dark')
v-list-tile.pt-2(href='/')
v-list-tile-avatar: v-icon home
v-list-tile-title Home
v-divider.my-2
v-subheader.pl-4 Navigation
v-list-tile
v-list-tile-avatar: v-icon stars
v-list-tile-title The Universe
v-list-tile
v-list-tile-avatar: v-icon directions_boat
v-list-tile-title Ships
v-list-tile
v-list-tile-avatar: v-icon local_airport
v-list-tile-title Airports
v-list.py-2(dense, :class='color', :dark='dark')
slot
</
template
>
<
script
>
...
...
client/themes/default/components/page.vue
View file @
763bf4b9
...
...
@@ -12,6 +12,7 @@
v-model='navShown'
)
nav-sidebar
slot(name='sidebar')
v-content
v-toolbar(color='grey lighten-3', flat, dense)
...
...
server/controllers/common.js
View file @
763bf4b9
...
...
@@ -75,7 +75,8 @@ router.get('/*', async (req, res, next) => {
isPrivate
:
false
})
if
(
page
)
{
res
.
render
(
'page'
,
{
page
})
const
sidebar
=
await
WIKI
.
models
.
navigation
.
getTree
({
cache
:
true
})
res
.
render
(
'page'
,
{
page
,
sidebar
})
}
else
if
(
pageArgs
.
path
===
'home'
)
{
res
.
render
(
'welcome'
)
}
else
{
...
...
server/graph/resolvers/navigation.js
View file @
763bf4b9
...
...
@@ -21,6 +21,7 @@ module.exports = {
await
WIKI
.
models
.
navigation
.
query
().
patch
({
config
:
args
.
tree
}).
where
(
'key'
,
'site'
)
await
WIKI
.
redis
.
set
(
'nav:sidebar'
,
JSON
.
stringify
(
args
.
tree
),
'EX'
,
300
)
return
{
responseResult
:
graphHelper
.
generateSuccess
(
'Navigation updated successfully'
)
...
...
server/models/navigation.js
View file @
763bf4b9
...
...
@@ -21,9 +21,18 @@ module.exports = class Navigation extends Model {
}
}
static
async
getTree
()
{
static
async
getTree
({
cache
=
false
}
=
{})
{
if
(
cache
)
{
const
navTreeCached
=
await
WIKI
.
redis
.
get
(
'nav:sidebar'
)
if
(
navTreeCached
)
{
return
JSON
.
parse
(
navTreeCached
)
}
}
const
navTree
=
await
WIKI
.
models
.
navigation
.
query
().
findOne
(
'key'
,
'site'
)
if
(
navTree
)
{
if
(
cache
)
{
await
WIKI
.
redis
.
set
(
'nav:sidebar'
,
JSON
.
stringify
(
navTree
.
config
),
'EX'
,
300
)
}
return
navTree
.
config
}
else
{
WIKI
.
logger
.
warn
(
'Site Navigation is missing or corrupted.'
)
...
...
server/setup.js
View file @
763bf4b9
const
path
=
require
(
'path'
)
const
uuid
=
require
(
'uuid/v4'
)
/* global WIKI */
...
...
@@ -209,6 +210,7 @@ module.exports = () => {
key
:
'site'
,
config
:
[
{
id
:
uuid
(),
icon
:
'home'
,
kind
:
'link'
,
label
:
'Home'
,
...
...
server/views/page.pug
View file @
763bf4b9
...
...
@@ -16,4 +16,17 @@ block body
:author-id=page.authorId
:is-published=page.isPublished
)
template(slot='sidebar')
each navItem in sidebar
if navItem.kind === 'link'
v-list-tile(
href=navItem.target
)
v-list-tile-avatar
v-icon= navItem.icon
v-list-tile-title= navItem.label
else if navItem.kind === 'divider'
v-divider.my-2
else if navItem.kind === 'header'
v-subheader.pl-4= navItem.label
template(slot='contents')!= page.render
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