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
b18dd29f
Commit
b18dd29f
authored
Jan 14, 2020
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: browse page by ID
parent
e836a497
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
2 deletions
+42
-2
data.yml
server/app/data.yml
+2
-0
common.js
server/controllers/common.js
+33
-0
servers.js
server/core/servers.js
+1
-1
master.js
server/master.js
+6
-1
No files found.
server/app/data.yml
View file @
b18dd29f
...
...
@@ -16,6 +16,8 @@ defaults:
db
:
wiki
ssl
:
false
storage
:
./db.sqlite
sslOptions
:
auto
:
true
ssl
:
enabled
:
false
pool
:
...
...
server/controllers/common.js
View file @
b18dd29f
...
...
@@ -130,6 +130,39 @@ router.get(['/h', '/h/*'], async (req, res, next) => {
})
/**
* Page ID redirection
*/
router
.
get
([
'/i'
,
'/i/:id'
],
async
(
req
,
res
,
next
)
=>
{
const
pageId
=
_
.
toSafeInteger
(
req
.
params
.
id
)
if
(
pageId
<=
0
)
{
return
res
.
redirect
(
'/'
)
}
const
page
=
await
WIKI
.
models
.
pages
.
query
().
column
([
'path'
,
'localeCode'
,
'isPrivate'
,
'privateNS'
]).
findById
(
pageId
)
if
(
!
page
)
{
_
.
set
(
res
.
locals
,
'pageMeta.title'
,
'Page Not Found'
)
return
res
.
status
(
404
).
render
(
'notfound'
,
{
action
:
'view'
})
}
if
(
!
WIKI
.
auth
.
checkAccess
(
req
.
user
,
[
'read:pages'
],
{
locale
:
page
.
localeCode
,
path
:
page
.
path
,
private
:
page
.
isPrivate
,
privateNS
:
page
.
privateNS
,
explicitLocale
:
false
}))
{
_
.
set
(
res
.
locals
,
'pageMeta.title'
,
'Unauthorized'
)
return
res
.
render
(
'unauthorized'
,
{
action
:
'view'
})
}
if
(
WIKI
.
config
.
lang
.
namespacing
)
{
return
res
.
redirect
(
`/
${
page
.
localeCode
}
/
${
page
.
path
}
`
)
}
else
{
return
res
.
redirect
(
`/
${
page
.
path
}
`
)
}
})
/**
* Profile
*/
router
.
get
([
'/p'
,
'/p/*'
],
(
req
,
res
,
next
)
=>
{
...
...
server/core/servers.js
View file @
b18dd29f
...
...
@@ -136,7 +136,7 @@ module.exports = {
* Close all active connections
*/
closeConnections
()
{
for
(
const
conn
of
this
.
connections
)
{
for
(
const
conn
of
this
.
connections
.
values
()
)
{
conn
.
destroy
()
}
this
.
connections
.
clear
()
...
...
server/master.js
View file @
b18dd29f
...
...
@@ -81,6 +81,12 @@ module.exports = async () => {
app
.
use
(
WIKI
.
auth
.
authenticate
)
// ----------------------------------------
// GraphQL Server
// ----------------------------------------
await
WIKI
.
servers
.
startGraphQL
()
// ----------------------------------------
// SEO
// ----------------------------------------
...
...
@@ -173,7 +179,6 @@ module.exports = async () => {
// Start HTTP Server(s)
// ----------------------------------------
await
WIKI
.
servers
.
startGraphQL
()
await
WIKI
.
servers
.
startHTTP
()
if
(
WIKI
.
config
.
ssl
.
enabled
===
true
||
WIKI
.
config
.
ssl
.
enabled
===
'true'
||
WIKI
.
config
.
ssl
.
enabled
===
1
||
WIKI
.
config
.
ssl
.
enabled
===
'1'
)
{
...
...
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