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
17b2117b
Commit
17b2117b
authored
May 20, 2018
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: knex remaining models
parent
c9b643fb
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
424 additions
and
445 deletions
+424
-445
editor.vue
client/components/editor.vue
+7
-7
editor-code.vue
client/components/editor/editor-code.vue
+55
-94
nav-header.vue
client/components/nav-header.vue
+1
-4
2.0.0.js
server/db/migrations/2.0.0.js
+91
-22
groups.js
server/db/models/groups.js
+2
-3
pages.js
server/db/models/pages.js
+70
-0
tags.js
server/db/models/tags.js
+49
-0
users.js
server/db/models/users.js
+3
-3
page.js
server/graph/resolvers/page.js
+51
-0
page.graphql
server/graph/schemas/page.graphql
+78
-0
_relations.js
server/models_old/_relations.js
+0
-16
comment.js
server/models_old/comment.js
+0
-16
document.js
server/models_old/document.js
+0
-64
file.js
server/models_old/file.js
+0
-42
folder.js
server/models_old/folder.js
+0
-22
group.js
server/models_old/group.js
+0
-16
locale.js
server/models_old/locale.js
+0
-39
right.js
server/models_old/right.js
+0
-36
setting.js
server/models_old/setting.js
+0
-26
tag.js
server/models_old/tag.js
+0
-22
local.js
server/modules/authentication/local.js
+3
-3
setup.js
server/setup.js
+14
-10
No files found.
client/components/editor.vue
View file @
17b2117b
...
...
@@ -3,7 +3,7 @@
nav-header
template(slot='actions')
v-btn(outline, color='green', @click.native.stop='save')
v-icon(color='green', left)
save
v-icon(color='green', left)
check
span.white--text Save
v-btn(icon): v-icon(color='red') close
v-btn(icon, @click.native.stop='openModal(`properties`)'): v-icon(color='white') sort_by_alpha
...
...
@@ -11,12 +11,12 @@
v-content
editor-code
component(:is='currentModal')
v-dialog(v-model='dialogProgress', persistent, max-width='3
0
0')
v-card
v-
progress-linear.my-0(indeterminate, color='primary', height='5')
v-card-text.text-xs-center
.
headline Sav
ing
.caption Please wait...
v-dialog(v-model='dialogProgress', persistent, max-width='3
5
0')
v-card
(color='blue darken-3', dark)
v-
card-text.text-xs-center.py-4
v-progress-circular(indeterminate, color='white', width='1')
.
subheading Process
ing
.caption
.blue--text.text--lighten-3
Please wait...
</
template
>
<
script
>
...
...
client/components/editor/editor-code.vue
View file @
17b2117b
<
template
lang=
'pug'
>
.editor-code
.editor-code-toolbar
.editor-code-toolbar-group
.editor-code-toolbar-item(@click='toggleAround("**", "**")')
v-toolbar.editor-code-toolbar.px-3(dense, color='primary', dark)
v-btn(icon).mx-0
svg.icons.is-18(role='img')
title Bold
use(xlink:href='#fa-bold')
v-btn(icon).mx-0
svg.icons.is-18(role='img')
title Italic
use(xlink:href='#fa-italic')
v-btn(icon).mx-0
svg.icons.is-18(role='img')
title Strikethrough
use(xlink:href='#fa-strikethrough')
v-menu(offset-y, open-on-hover)
v-btn(icon, slot='activator').mx-0
svg.icons.is-18(role='img')
title Bold
use(xlink:href='#fa-bold')
.editor-code-toolbar-item
svg.icons.is-18(role='img')
title Italic
use(xlink:href='#fa-italic')
.editor-code-toolbar-item
svg.icons.is-18(role='img')
title Strikethrough
use(xlink:href='#fa-strikethrough')
.editor-code-toolbar-group
v-menu(offset-y, open-on-hover)
.editor-code-toolbar-item.is-dropdown(slot='activator')
svg.icons.is-18(role='img')
title Heading
use(xlink:href='#fa-heading')
v-list
v-list-tile(v-for='(n, idx) in 6', @click='', :key='idx')
v-list-tile-action: v-icon format_size
v-list-tile-title Heading
{{
n
}}
.editor-code-toolbar-item
svg.icons.is-18(role='img')
title Blockquote
use(xlink:href='#fa-quote-left')
.editor-code-toolbar-group
.editor-code-toolbar-item
svg.icons.is-18(role='img')
title Unordered List
use(xlink:href='#fa-list-ul')
.editor-code-toolbar-item
svg.icons.is-18(role='img')
title Ordered List
use(xlink:href='#fa-list-ol')
.editor-code-toolbar-group
.editor-code-toolbar-item
svg.icons.is-18(role='img')
title Link
use(xlink:href='#fa-link')
.editor-code-toolbar-group
.editor-code-toolbar-item
svg.icons.is-18(role='img')
title Inline Code
use(xlink:href='#fa-terminal')
.editor-code-toolbar-item
svg.icons.is-18(role='img')
title Code Block
use(xlink:href='#fa-code')
.editor-code-toolbar-group
.editor-code-toolbar-item
svg.icons.is-18(role='img')
title Horizontal Bar
use(xlink:href='#fa-minus')
title Heading
use(xlink:href='#fa-heading')
v-list
v-list-tile(v-for='(n, idx) in 6', @click='', :key='idx')
v-list-tile-action
svg.icons.is-18(role='img')
title Heading
{{
n
}}
use(xlink:href='#fa-heading')
v-list-tile-title Heading
{{
n
}}
v-btn(icon).mx-0
svg.icons.is-18(role='img')
title Blockquote
use(xlink:href='#fa-quote-left')
v-btn(icon).mx-0
svg.icons.is-18(role='img')
title Unordered List
use(xlink:href='#fa-list-ul')
v-btn(icon).mx-0
svg.icons.is-18(role='img')
title Ordered List
use(xlink:href='#fa-list-ol')
v-btn(icon).mx-0
svg.icons.is-18(role='img')
title Link
use(xlink:href='#fa-link')
v-btn(icon).mx-0
svg.icons.is-18(role='img')
title Inline Code
use(xlink:href='#fa-terminal')
v-btn(icon).mx-0
svg.icons.is-18(role='img')
title Code Block
use(xlink:href='#fa-code')
v-btn(icon).mx-0
svg.icons.is-18(role='img')
title Horizontal Bar
use(xlink:href='#fa-minus')
.editor-code-main
.editor-code-editor
.editor-code-editor-title(v-if='previewShown', @click='previewShown = false') Editor
.editor-code-editor-title(v-else='previewShown', @click='previewShown = true'): v-icon(dark)
search
.editor-code-editor-title(v-else='previewShown', @click='previewShown = true'): v-icon(dark)
drag_indicator
codemirror(ref='cm', v-model='code', :options='cmOptions', @ready='onCmReady', @input='onCmInput')
transition(name='editor-code-preview')
.editor-code-preview(v-if='previewShown')
.editor-code-preview-title(@click='previewShown = false') Preview
.editor-code-preview-content.markdown-content(ref='editorPreview', v-html='previewHTML')
v-speed-dial(v-model='fabInsertMenu', :open-on-hover='true', direction='top', transition='slide-y-reverse-transition', fixed,
righ
t, bottom)
v-speed-dial(v-model='fabInsertMenu', :open-on-hover='true', direction='top', transition='slide-y-reverse-transition', fixed,
lef
t, bottom)
v-btn(color='blue', fab, dark, v-model='fabInsertMenu', slot='activator')
v-icon add_circle
v-icon close
...
...
@@ -276,7 +273,7 @@ export default {
background-color
:
darken
(
mc
(
'grey'
,
'900'
)
,
4
.5%
);
flex
:
1
1
50%
;
display
:
block
;
height
:
calc
(
100vh
-
100
px
);
height
:
calc
(
100vh
-
96
px
);
position
:
relative
;
&
-title
{
...
...
@@ -361,48 +358,12 @@ export default {
&
-toolbar
{
background-color
:
mc
(
'blue'
,
'700'
);
background-image
:
linear-gradient
(
to
bottom
,
mc
(
'blue'
,
'700'
)
0%
,
mc
(
'blue'
,
'800'
)
100%
);
height
:
50px
;
color
:
#FFF
;
display
:
flex
;
@include
until
(
$tablet
)
{
justify-content
:
center
;
}
&
-group
{
display
:
flex
;
+
.editor-code-toolbar-group
{
border-left
:
1px
solid
rgba
(
mc
(
'blue'
,
'600'
)
,
.5
);
}
}
&
-item
{
width
:
40px
;
height
:
50px
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
transition
:
all
.4s
ease
;
cursor
:
pointer
;
&
:first-child
{
padding-left
:
.5rem
;
}
&
:last-child
{
padding-right
:
.5rem
;
}
&
:hover
{
background-color
:
mc
(
'blue'
,
'600'
);
}
@include
until
(
$tablet
)
{
width
:
35px
;
}
}
svg
{
use
{
color
:
#FFF
;
...
...
client/components/nav-header.vue
View file @
17b2117b
...
...
@@ -31,10 +31,7 @@
v-subheader Assets
v-list-tile(avatar, @click='')
v-list-tile-avatar: v-icon(color='blue-grey') burst_mode
v-list-tile-content Images
v-list-tile(avatar, @click='')
v-list-tile-avatar: v-icon(color='blue-grey') description
v-list-tile-content Files
v-list-tile-content Images & Files
v-toolbar-title
span.subheading Wiki.js
v-spacer
...
...
server/db/migrations/2.0.0.js
View file @
17b2117b
exports
.
up
=
knex
=>
{
return
knex
.
schema
// -------------------------------------
// GROUPS
// -------------------------------------
// =====================================
// MODEL TABLES
// =====================================
// ASSETS ------------------------------
.
createTable
(
'assets'
,
table
=>
{
table
.
increments
(
'id'
).
primary
()
table
.
string
(
'filename'
).
notNullable
()
table
.
string
(
'basename'
).
notNullable
()
table
.
string
(
'ext'
).
notNullable
()
table
.
enum
(
'kind'
,
[
'binary'
,
'image'
]).
notNullable
().
defaultTo
(
'binary'
)
table
.
string
(
'mime'
).
notNullable
().
defaultTo
(
'application/octet-stream'
)
table
.
integer
(
'fileSize'
).
unsigned
().
comment
(
'In kilobytes'
)
table
.
jsonb
(
'metadata'
)
table
.
string
(
'createdAt'
).
notNullable
()
table
.
string
(
'updatedAt'
).
notNullable
()
})
// ASSET FOLDERS -----------------------
.
createTable
(
'assetFolders'
,
table
=>
{
table
.
increments
(
'id'
).
primary
()
table
.
string
(
'name'
).
notNullable
()
table
.
string
(
'slug'
).
notNullable
()
table
.
integer
(
'parentId'
).
unsigned
().
references
(
'id'
).
inTable
(
'assetFolders'
)
})
// COMMENTS ----------------------------
.
createTable
(
'comments'
,
table
=>
{
table
.
increments
(
'id'
).
primary
()
table
.
text
(
'content'
).
notNullable
()
table
.
string
(
'createdAt'
).
notNullable
()
table
.
string
(
'updatedAt'
).
notNullable
()
})
// GROUPS ------------------------------
.
createTable
(
'groups'
,
table
=>
{
table
.
increments
(
'id'
).
primary
()
table
.
string
(
'name'
).
notNullable
()
table
.
string
(
'createdAt'
).
notNullable
()
table
.
string
(
'updatedAt'
).
notNullable
()
})
// -------------------------------------
// LOCALES
// -------------------------------------
// LOCALES -----------------------------
.
createTable
(
'locales'
,
table
=>
{
table
.
increments
(
'id'
).
primary
()
table
.
string
(
'code'
,
2
).
notNullable
().
unique
()
table
.
json
(
'strings'
)
table
.
json
b
(
'strings'
)
table
.
boolean
(
'isRTL'
).
notNullable
().
defaultTo
(
false
)
table
.
string
(
'name'
).
notNullable
()
table
.
string
(
'nativeName'
).
notNullable
()
table
.
string
(
'createdAt'
).
notNullable
()
table
.
string
(
'updatedAt'
).
notNullable
()
})
// -------------------------------------
// SETTINGS
// -------------------------------------
// PAGES -------------------------------
.
createTable
(
'pages'
,
table
=>
{
table
.
increments
(
'id'
).
primary
()
table
.
string
(
'path'
).
notNullable
()
table
.
string
(
'title'
).
notNullable
()
table
.
string
(
'description'
)
table
.
boolean
(
'isPublished'
).
notNullable
().
defaultTo
(
false
)
table
.
string
(
'publishStartDate'
)
table
.
string
(
'publishEndDate'
)
table
.
text
(
'content'
)
table
.
string
(
'createdAt'
).
notNullable
()
table
.
string
(
'updatedAt'
).
notNullable
()
})
// SETTINGS ----------------------------
.
createTable
(
'settings'
,
table
=>
{
table
.
increments
(
'id'
).
primary
()
table
.
string
(
'key'
).
notNullable
().
unique
()
table
.
json
(
'value'
)
table
.
jsonb
(
'value'
)
table
.
string
(
'createdAt'
).
notNullable
()
table
.
string
(
'updatedAt'
).
notNullable
()
})
// TAGS --------------------------------
.
createTable
(
'tags'
,
table
=>
{
table
.
increments
(
'id'
).
primary
()
table
.
string
(
'tag'
).
notNullable
().
unique
()
table
.
string
(
'title'
)
table
.
string
(
'createdAt'
).
notNullable
()
table
.
string
(
'updatedAt'
).
notNullable
()
})
// -------------------------------------
// USERS
// -------------------------------------
// USERS -------------------------------
.
createTable
(
'users'
,
table
=>
{
table
.
increments
(
'id'
).
primary
()
table
.
string
(
'email'
).
notNullable
()
table
.
string
(
'name'
).
notNullable
()
table
.
string
(
'provider'
).
notNullable
().
defaultTo
(
'local'
)
...
...
@@ -54,22 +93,52 @@ exports.up = knex => {
table
.
unique
([
'provider'
,
'email'
])
})
// -------------------------------------
// USER GROUPS
// -------------------------------------
// =====================================
// RELATION TABLES
// =====================================
// PAGE TAGS ---------------------------
.
createTable
(
'pageTags'
,
table
=>
{
table
.
increments
(
'id'
).
primary
()
table
.
integer
(
'pageId'
).
unsigned
().
references
(
'id'
).
inTable
(
'pages'
)
table
.
integer
(
'tagId'
).
unsigned
().
references
(
'id'
).
inTable
(
'tags'
)
})
// USER GROUPS -------------------------
.
createTable
(
'userGroups'
,
table
=>
{
table
.
increments
(
'id'
).
primary
()
table
.
integer
(
'userId'
).
unsigned
().
references
(
'id'
).
inTable
(
'users'
)
table
.
integer
(
'groupId'
).
unsigned
().
references
(
'id'
).
inTable
(
'groups'
)
})
// =====================================
// REFERENCES
// =====================================
.
table
(
'assets'
,
table
=>
{
table
.
integer
(
'folderId'
).
unsigned
().
references
(
'id'
).
inTable
(
'assetFolders'
)
table
.
integer
(
'authorId'
).
unsigned
().
references
(
'id'
).
inTable
(
'users'
)
})
.
table
(
'comments'
,
table
=>
{
table
.
integer
(
'pageId'
).
unsigned
().
references
(
'id'
).
inTable
(
'pages'
)
table
.
integer
(
'authorId'
).
unsigned
().
references
(
'id'
).
inTable
(
'users'
)
})
.
table
(
'pages'
,
table
=>
{
table
.
string
(
'locale'
,
2
).
references
(
'code'
).
inTable
(
'locales'
)
table
.
integer
(
'authorId'
).
unsigned
().
references
(
'id'
).
inTable
(
'users'
)
})
.
table
(
'users'
,
table
=>
{
table
.
string
(
'locale'
,
2
).
references
(
'code'
).
inTable
(
'locales'
)
})
}
exports
.
down
=
knex
=>
{
return
knex
.
schema
.
dropTableIfExists
(
'userGroups'
)
.
dropTableIfExists
(
'pageTags'
)
.
dropTableIfExists
(
'assets'
)
.
dropTableIfExists
(
'assetFolders'
)
.
dropTableIfExists
(
'comments'
)
.
dropTableIfExists
(
'groups'
)
.
dropTableIfExists
(
'locales'
)
.
dropTableIfExists
(
'pages'
)
.
dropTableIfExists
(
'settings'
)
.
dropTableIfExists
(
'tags'
)
.
dropTableIfExists
(
'users'
)
}
server/db/models/groups.js
View file @
17b2117b
const
Model
=
require
(
'objection'
).
Model
/**
*
Setting
s model
*
Group
s model
*/
module
.
exports
=
class
Group
extends
Model
{
static
get
tableName
()
{
return
'groups'
}
...
...
@@ -21,11 +21,10 @@ module.exports = class Group extends Model {
}
static
get
relationMappings
()
{
const
User
=
require
(
'./users'
)
return
{
users
:
{
relation
:
Model
.
ManyToManyRelation
,
modelClass
:
User
,
modelClass
:
require
(
'./users'
)
,
join
:
{
from
:
'groups.id'
,
through
:
{
...
...
server/db/models/pages.js
0 → 100644
View file @
17b2117b
const
Model
=
require
(
'objection'
).
Model
/**
* Pages model
*/
module
.
exports
=
class
Page
extends
Model
{
static
get
tableName
()
{
return
'pages'
}
static
get
jsonSchema
()
{
return
{
type
:
'object'
,
required
:
[
'path'
,
'title'
],
properties
:
{
id
:
{
type
:
'integer'
},
path
:
{
type
:
'string'
},
title
:
{
type
:
'string'
},
description
:
{
type
:
'string'
},
isPublished
:
{
type
:
'boolean'
},
publishStartDate
:
{
type
:
'string'
},
publishEndDate
:
{
type
:
'string'
},
content
:
{
type
:
'string'
},
createdAt
:
{
type
:
'string'
},
updatedAt
:
{
type
:
'string'
}
}
}
}
static
get
relationMappings
()
{
return
{
tags
:
{
relation
:
Model
.
ManyToManyRelation
,
modelClass
:
require
(
'./tags'
),
join
:
{
from
:
'pages.id'
,
through
:
{
from
:
'pageTags.pageId'
,
to
:
'pageTags.tagId'
},
to
:
'tags.id'
}
},
author
:
{
relation
:
Model
.
BelongsToOneRelation
,
modelClass
:
require
(
'./users'
),
join
:
{
from
:
'pages.authorId'
,
to
:
'users.id'
}
},
locale
:
{
relation
:
Model
.
BelongsToOneRelation
,
modelClass
:
require
(
'./locales'
),
join
:
{
from
:
'users.locale'
,
to
:
'locales.code'
}
}
}
}
$beforeUpdate
()
{
this
.
updatedAt
=
new
Date
().
toISOString
()
}
$beforeInsert
()
{
this
.
createdAt
=
new
Date
().
toISOString
()
this
.
updatedAt
=
new
Date
().
toISOString
()
}
}
server/db/models/tags.js
0 → 100644
View file @
17b2117b
const
Model
=
require
(
'objection'
).
Model
/**
* Tags model
*/
module
.
exports
=
class
Tag
extends
Model
{
static
get
tableName
()
{
return
'tags'
}
static
get
jsonSchema
()
{
return
{
type
:
'object'
,
required
:
[
'tag'
],
properties
:
{
id
:
{
type
:
'integer'
},
tag
:
{
type
:
'string'
},
title
:
{
type
:
'string'
},
createdAt
:
{
type
:
'string'
},
updatedAt
:
{
type
:
'string'
}
}
}
}
static
get
relationMappings
()
{
return
{
pages
:
{
relation
:
Model
.
ManyToManyRelation
,
modelClass
:
require
(
'./pages'
),
join
:
{
from
:
'tags.id'
,
through
:
{
from
:
'pageTags.tagId'
,
to
:
'pageTags.pageId'
},
to
:
'pages.id'
}
}
}
}
$beforeUpdate
()
{
this
.
updatedAt
=
new
Date
().
toISOString
()
}
$beforeInsert
()
{
this
.
createdAt
=
new
Date
().
toISOString
()
this
.
updatedAt
=
new
Date
().
toISOString
()
}
}
server/db/models/users.js
View file @
17b2117b
...
...
@@ -29,6 +29,7 @@ module.exports = class User extends Model {
role
:
{
type
:
'string'
,
enum
:
[
'admin'
,
'guest'
,
'user'
]},
tfaIsActive
:
{
type
:
'boolean'
,
default
:
false
},
tfaSecret
:
{
type
:
'string'
},
locale
:
{
type
:
'string'
},
createdAt
:
{
type
:
'string'
},
updatedAt
:
{
type
:
'string'
}
}
...
...
@@ -36,11 +37,10 @@ module.exports = class User extends Model {
}
static
get
relationMappings
()
{
const
Group
=
require
(
'./groups'
)
return
{
groups
:
{
relation
:
Model
.
ManyToManyRelation
,
modelClass
:
Group
,
modelClass
:
require
(
'./groups'
)
,
join
:
{
from
:
'users.id'
,
through
:
{
...
...
@@ -79,7 +79,7 @@ module.exports = class User extends Model {
}
async
verifyPassword
(
pwd
)
{
if
(
await
bcrypt
.
compare
(
this
.
password
,
pw
d
)
===
true
)
{
if
(
await
bcrypt
.
compare
(
pwd
,
this
.
passwor
d
)
===
true
)
{
return
true
}
else
{
throw
new
WIKI
.
Error
.
AuthLoginFailed
()
...
...
server/graph/resolvers/page.js
0 → 100644
View file @
17b2117b
const
graphHelper
=
require
(
'../../helpers/graph'
)
/* global WIKI */
module
.
exports
=
{
Query
:
{
async
pages
()
{
return
{}
}
},
Mutation
:
{
async
pages
()
{
return
{}
}
},
PageQuery
:
{
async
list
(
obj
,
args
,
context
,
info
)
{
return
WIKI
.
db
.
groups
.
query
().
select
(
'groups.*'
,
WIKI
.
db
.
groups
.
relatedQuery
(
'users'
).
count
().
as
(
'userCount'
)
)
},
async
single
(
obj
,
args
,
context
,
info
)
{
return
WIKI
.
db
.
groups
.
query
().
findById
(
args
.
id
)
}
},
PageMutation
:
{
async
create
(
obj
,
args
)
{
const
group
=
await
WIKI
.
db
.
pages
.
query
().
insertAndFetch
({
name
:
args
.
name
})
return
{
responseResult
:
graphHelper
.
generateSuccess
(
'Group created successfully.'
),
group
}
},
async
delete
(
obj
,
args
)
{
await
WIKI
.
db
.
groups
.
query
().
deleteById
(
args
.
id
)
return
{
responseResult
:
graphHelper
.
generateSuccess
(
'Group has been deleted.'
)
}
},
async
update
(
obj
,
args
)
{
await
WIKI
.
db
.
groups
.
query
().
patch
({
name
:
args
.
name
}).
where
(
'id'
,
args
.
id
)
return
{
responseResult
:
graphHelper
.
generateSuccess
(
'Group has been updated.'
)
}
}
},
Page
:
{
// comments(pg) {
// return pg.$relatedQuery('comments')
// }
}
}
server/graph/schemas/page.graphql
0 → 100644
View file @
17b2117b
# ===============================================
# PAGES
# ===============================================
extend
type
Query
{
pages
:
PageQuery
}
extend
type
Mutation
{
pages
:
PageMutation
}
# -----------------------------------------------
# QUERIES
# -----------------------------------------------
type
PageQuery
{
list
(
filter
:
String
orderBy
:
String
):
[
PageMinimal
]
single
(
id
:
Int
!
):
Page
}
# -----------------------------------------------
# MUTATIONS
# -----------------------------------------------
type
PageMutation
{
create
(
description
:
String
isPublished
:
Boolean
locale
:
String
path
:
String
!
publishEndDate
:
Date
publishStartDate
:
Date
tags
:
[
String
]
title
:
String
!
):
PageResponse
update
(
id
:
Int
!
name
:
String
!
):
DefaultResponse
delete
(
id
:
Int
!
):
DefaultResponse
}
# -----------------------------------------------
# TYPES
# -----------------------------------------------
type
PageResponse
{
responseResult
:
ResponseStatus
!
page
:
Page
}
type
PageMinimal
{
id
:
Int
!
name
:
String
!
userCount
:
Int
createdAt
:
Date
!
updatedAt
:
Date
!
}
type
Page
{
id
:
Int
!
name
:
String
!
rights
:
[
Right
]
users
:
[
User
]
createdAt
:
Date
!
updatedAt
:
Date
!
}
server/models_old/_relations.js
deleted
100644 → 0
View file @
c9b643fb
/**
* Associate DB Model relations
*/
module
.
exports
=
db
=>
{
db
.
User
.
belongsToMany
(
db
.
Group
,
{
through
:
'userGroups'
})
db
.
Group
.
belongsToMany
(
db
.
User
,
{
through
:
'userGroups'
})
db
.
Group
.
hasMany
(
db
.
Right
)
db
.
Right
.
belongsTo
(
db
.
Group
)
db
.
Document
.
belongsToMany
(
db
.
Tag
,
{
through
:
'documentTags'
})
db
.
Document
.
hasMany
(
db
.
Comment
)
db
.
Tag
.
belongsToMany
(
db
.
Document
,
{
through
:
'documentTags'
})
db
.
File
.
belongsTo
(
db
.
Folder
)
db
.
Folder
.
hasMany
(
db
.
File
)
db
.
Comment
.
belongsTo
(
db
.
Document
)
db
.
Comment
.
belongsTo
(
db
.
User
,
{
as
:
'author'
})
}
server/models_old/comment.js
deleted
100644 → 0
View file @
c9b643fb
/**
* Comment schema
*/
module
.
exports
=
(
sequelize
,
DataTypes
)
=>
{
let
commentSchema
=
sequelize
.
define
(
'comment'
,
{
content
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
}
},
{
timestamps
:
true
,
version
:
true
})
return
commentSchema
}
server/models_old/document.js
deleted
100644 → 0
View file @
c9b643fb
/**
* Document schema
*/
module
.
exports
=
(
sequelize
,
DataTypes
)
=>
{
let
documentSchema
=
sequelize
.
define
(
'setting'
,
{
path
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
},
title
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
,
validate
:
{
len
:
[
2
,
255
]
}
},
subtitle
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
true
,
defaultValue
:
''
},
parentPath
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
true
,
defaultValue
:
''
},
parentTitle
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
true
,
defaultValue
:
''
},
isDirectory
:
{
type
:
DataTypes
.
BOOLEAN
,
allowNull
:
false
,
defaultValue
:
false
},
isEntry
:
{
type
:
DataTypes
.
BOOLEAN
,
allowNull
:
false
,
defaultValue
:
false
},
isDraft
:
{
type
:
DataTypes
.
BOOLEAN
,
allowNull
:
false
,
defaultValue
:
false
},
searchContent
:
{
type
:
DataTypes
.
TEXT
,
allowNull
:
true
,
defaultValue
:
''
}
},
{
timestamps
:
true
,
version
:
true
,
indexes
:
[
{
unique
:
true
,
fields
:
[
'path'
]
}
]
})
return
documentSchema
}
server/models_old/file.js
deleted
100644 → 0
View file @
c9b643fb
/**
* File schema
*/
module
.
exports
=
(
sequelize
,
DataTypes
)
=>
{
let
fileSchema
=
sequelize
.
define
(
'file'
,
{
category
:
{
type
:
DataTypes
.
ENUM
(
'binary'
,
'image'
),
allowNull
:
false
,
defaultValue
:
'binary'
},
mime
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
,
defaultValue
:
'application/octet-stream'
},
extra
:
{
type
:
DataTypes
.
JSON
,
allowNull
:
true
},
filename
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
},
basename
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
},
filesize
:
{
type
:
DataTypes
.
INTEGER
,
allowNull
:
false
,
validate
:
{
isInt
:
true
,
min
:
0
}
}
},
{
timestamps
:
true
,
version
:
true
})
return
fileSchema
}
server/models_old/folder.js
deleted
100644 → 0
View file @
c9b643fb
/**
* Folder schema
*/
module
.
exports
=
(
sequelize
,
DataTypes
)
=>
{
let
folderSchema
=
sequelize
.
define
(
'folder'
,
{
name
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
}
},
{
timestamps
:
true
,
version
:
true
,
indexes
:
[
{
unique
:
true
,
fields
:
[
'name'
]
}
]
})
return
folderSchema
}
server/models_old/group.js
deleted
100644 → 0
View file @
c9b643fb
/**
* Group schema
*/
module
.
exports
=
(
sequelize
,
DataTypes
)
=>
{
let
groupSchema
=
sequelize
.
define
(
'group'
,
{
name
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
}
},
{
timestamps
:
true
,
version
:
true
})
return
groupSchema
}
server/models_old/locale.js
deleted
100644 → 0
View file @
c9b643fb
/**
* Locale schema
*/
module
.
exports
=
(
sequelize
,
DataTypes
)
=>
{
let
localeSchema
=
sequelize
.
define
(
'locale'
,
{
code
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
},
strings
:
{
type
:
DataTypes
.
JSON
,
allowNull
:
true
},
isRTL
:
{
type
:
DataTypes
.
BOOLEAN
,
allowNull
:
false
,
defaultValue
:
false
},
name
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
},
nativeName
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
}
},
{
timestamps
:
true
,
version
:
true
,
indexes
:
[
{
unique
:
true
,
fields
:
[
'code'
]
}
]
})
return
localeSchema
}
server/models_old/right.js
deleted
100644 → 0
View file @
c9b643fb
/**
* Right schema
*/
module
.
exports
=
(
sequelize
,
DataTypes
)
=>
{
let
rightSchema
=
sequelize
.
define
(
'right'
,
{
path
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
},
role
:
{
type
:
DataTypes
.
ENUM
(
'read'
,
'write'
,
'manage'
),
allowNull
:
false
,
defaultValue
:
'read'
},
exact
:
{
type
:
DataTypes
.
BOOLEAN
,
allowNull
:
false
,
defaultValue
:
false
},
allow
:
{
type
:
DataTypes
.
BOOLEAN
,
allowNull
:
false
,
defaultValue
:
false
}
},
{
timestamps
:
true
,
version
:
true
,
indexes
:
[
{
fields
:
[
'path'
]
}
]
})
return
rightSchema
}
server/models_old/setting.js
deleted
100644 → 0
View file @
c9b643fb
/**
* Settings schema
*/
module
.
exports
=
(
sequelize
,
DataTypes
)
=>
{
let
settingSchema
=
sequelize
.
define
(
'setting'
,
{
key
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
},
config
:
{
type
:
DataTypes
.
JSON
,
allowNull
:
false
}
},
{
timestamps
:
true
,
version
:
true
,
indexes
:
[
{
unique
:
true
,
fields
:
[
'key'
]
}
]
})
return
settingSchema
}
server/models_old/tag.js
deleted
100644 → 0
View file @
c9b643fb
/**
* Tags schema
*/
module
.
exports
=
(
sequelize
,
DataTypes
)
=>
{
let
tagSchema
=
sequelize
.
define
(
'tag'
,
{
key
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
}
},
{
timestamps
:
true
,
version
:
true
,
indexes
:
[
{
unique
:
true
,
fields
:
[
'key'
]
}
]
})
return
tagSchema
}
server/modules/authentication/local.js
View file @
17b2117b
...
...
@@ -23,12 +23,12 @@ module.exports = {
}).
then
((
user
)
=>
{
if
(
user
)
{
return
user
.
verifyPassword
(
uPassword
).
then
(()
=>
{
return
done
(
null
,
user
)
||
true
done
(
null
,
user
)
}).
catch
((
err
)
=>
{
return
done
(
err
,
null
)
done
(
err
,
null
)
})
}
else
{
return
done
(
new
WIKI
.
Error
.
AuthLoginFailed
(),
null
)
done
(
new
WIKI
.
Error
.
AuthLoginFailed
(),
null
)
}
}).
catch
((
err
)
=>
{
done
(
err
,
null
)
...
...
server/setup.js
View file @
17b2117b
...
...
@@ -250,6 +250,8 @@ module.exports = () => {
app
.
post
(
'/finalize'
,
async
(
req
,
res
)
=>
{
WIKI
.
telemetry
.
sendEvent
(
'setup'
,
'finalize'
)
console
.
error
(
'DUDE'
)
try
{
// Upgrade from WIKI.js 1.x?
if
(
req
.
body
.
upgrade
)
{
...
...
@@ -307,6 +309,16 @@ module.exports = () => {
{
key
:
'uploads'
,
value
:
WIKI
.
config
.
uploads
}
])
// Create default locale
WIKI
.
logger
.
info
(
'Installing default locale...'
)
await
WIKI
.
db
.
locales
.
query
().
insert
({
code
:
'en'
,
strings
:
require
(
'./locales/default.json'
),
isRTL
:
false
,
name
:
'English'
,
nativeName
:
'English'
})
// Create root administrator
WIKI
.
logger
.
info
(
'Creating root administrator...'
)
await
WIKI
.
db
.
users
.
query
().
insert
({
...
...
@@ -315,6 +327,7 @@ module.exports = () => {
password
:
req
.
body
.
adminPassword
,
name
:
'Administrator'
,
role
:
'admin'
,
locale
:
'en'
,
tfaIsActive
:
false
})
...
...
@@ -331,20 +344,11 @@ module.exports = () => {
name
:
'Guest'
,
password
:
''
,
role
:
'guest'
,
locale
:
'en'
,
tfaIsActive
:
false
})
}
// Create default locale
WIKI
.
logger
.
info
(
'Installing default locale...'
)
await
WIKI
.
db
.
locales
.
query
().
insert
({
code
:
'en'
,
strings
:
require
(
'./locales/default.json'
),
isRTL
:
false
,
name
:
'English'
,
nativeName
:
'English'
})
WIKI
.
logger
.
info
(
'Setup is complete!'
)
res
.
json
({
ok
:
true
,
...
...
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