Skip to content

Commit 17b2117

Browse files
committed
refactor: knex remaining models
1 parent c9b643f commit 17b2117

File tree

22 files changed

+424
-445
lines changed

22 files changed

+424
-445
lines changed

client/components/editor.vue

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
nav-header
44
template(slot='actions')
55
v-btn(outline, color='green', @click.native.stop='save')
6-
v-icon(color='green', left) save
6+
v-icon(color='green', left) check
77
span.white--text Save
88
v-btn(icon): v-icon(color='red') close
99
v-btn(icon, @click.native.stop='openModal(`properties`)'): v-icon(color='white') sort_by_alpha
1010
v-btn(icon, @click.native.stop='openModal(`access`)'): v-icon(color='white') vpn_lock
1111
v-content
1212
editor-code
1313
component(:is='currentModal')
14-
v-dialog(v-model='dialogProgress', persistent, max-width='300')
15-
v-card
16-
v-progress-linear.my-0(indeterminate, color='primary', height='5')
17-
v-card-text.text-xs-center
18-
.headline Saving
19-
.caption Please wait...
14+
v-dialog(v-model='dialogProgress', persistent, max-width='350')
15+
v-card(color='blue darken-3', dark)
16+
v-card-text.text-xs-center.py-4
17+
v-progress-circular(indeterminate, color='white', width='1')
18+
.subheading Processing
19+
.caption.blue--text.text--lighten-3 Please wait...
2020
</template>
2121

2222
<script>

client/components/editor/editor-code.vue

+55-94
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,70 @@
11
<template lang='pug'>
22
.editor-code
3-
.editor-code-toolbar
4-
.editor-code-toolbar-group
5-
.editor-code-toolbar-item(@click='toggleAround("**", "**")')
3+
v-toolbar.editor-code-toolbar.px-3(dense, color='primary', dark)
4+
v-btn(icon).mx-0
5+
svg.icons.is-18(role='img')
6+
title Bold
7+
use(xlink:href='#fa-bold')
8+
v-btn(icon).mx-0
9+
svg.icons.is-18(role='img')
10+
title Italic
11+
use(xlink:href='#fa-italic')
12+
v-btn(icon).mx-0
13+
svg.icons.is-18(role='img')
14+
title Strikethrough
15+
use(xlink:href='#fa-strikethrough')
16+
v-menu(offset-y, open-on-hover)
17+
v-btn(icon, slot='activator').mx-0
618
svg.icons.is-18(role='img')
7-
title Bold
8-
use(xlink:href='#fa-bold')
9-
.editor-code-toolbar-item
10-
svg.icons.is-18(role='img')
11-
title Italic
12-
use(xlink:href='#fa-italic')
13-
.editor-code-toolbar-item
14-
svg.icons.is-18(role='img')
15-
title Strikethrough
16-
use(xlink:href='#fa-strikethrough')
17-
.editor-code-toolbar-group
18-
v-menu(offset-y, open-on-hover)
19-
.editor-code-toolbar-item.is-dropdown(slot='activator')
20-
svg.icons.is-18(role='img')
21-
title Heading
22-
use(xlink:href='#fa-heading')
23-
v-list
24-
v-list-tile(v-for='(n, idx) in 6', @click='', :key='idx')
25-
v-list-tile-action: v-icon format_size
26-
v-list-tile-title Heading {{n}}
27-
.editor-code-toolbar-item
28-
svg.icons.is-18(role='img')
29-
title Blockquote
30-
use(xlink:href='#fa-quote-left')
31-
.editor-code-toolbar-group
32-
.editor-code-toolbar-item
33-
svg.icons.is-18(role='img')
34-
title Unordered List
35-
use(xlink:href='#fa-list-ul')
36-
.editor-code-toolbar-item
37-
svg.icons.is-18(role='img')
38-
title Ordered List
39-
use(xlink:href='#fa-list-ol')
40-
.editor-code-toolbar-group
41-
.editor-code-toolbar-item
42-
svg.icons.is-18(role='img')
43-
title Link
44-
use(xlink:href='#fa-link')
45-
.editor-code-toolbar-group
46-
.editor-code-toolbar-item
47-
svg.icons.is-18(role='img')
48-
title Inline Code
49-
use(xlink:href='#fa-terminal')
50-
.editor-code-toolbar-item
51-
svg.icons.is-18(role='img')
52-
title Code Block
53-
use(xlink:href='#fa-code')
54-
.editor-code-toolbar-group
55-
.editor-code-toolbar-item
56-
svg.icons.is-18(role='img')
57-
title Horizontal Bar
58-
use(xlink:href='#fa-minus')
19+
title Heading
20+
use(xlink:href='#fa-heading')
21+
v-list
22+
v-list-tile(v-for='(n, idx) in 6', @click='', :key='idx')
23+
v-list-tile-action
24+
svg.icons.is-18(role='img')
25+
title Heading {{n}}
26+
use(xlink:href='#fa-heading')
27+
v-list-tile-title Heading {{n}}
28+
v-btn(icon).mx-0
29+
svg.icons.is-18(role='img')
30+
title Blockquote
31+
use(xlink:href='#fa-quote-left')
32+
v-btn(icon).mx-0
33+
svg.icons.is-18(role='img')
34+
title Unordered List
35+
use(xlink:href='#fa-list-ul')
36+
v-btn(icon).mx-0
37+
svg.icons.is-18(role='img')
38+
title Ordered List
39+
use(xlink:href='#fa-list-ol')
40+
v-btn(icon).mx-0
41+
svg.icons.is-18(role='img')
42+
title Link
43+
use(xlink:href='#fa-link')
44+
v-btn(icon).mx-0
45+
svg.icons.is-18(role='img')
46+
title Inline Code
47+
use(xlink:href='#fa-terminal')
48+
v-btn(icon).mx-0
49+
svg.icons.is-18(role='img')
50+
title Code Block
51+
use(xlink:href='#fa-code')
52+
v-btn(icon).mx-0
53+
svg.icons.is-18(role='img')
54+
title Horizontal Bar
55+
use(xlink:href='#fa-minus')
5956

6057
.editor-code-main
6158
.editor-code-editor
6259
.editor-code-editor-title(v-if='previewShown', @click='previewShown = false') Editor
63-
.editor-code-editor-title(v-else='previewShown', @click='previewShown = true'): v-icon(dark) search
60+
.editor-code-editor-title(v-else='previewShown', @click='previewShown = true'): v-icon(dark) drag_indicator
6461
codemirror(ref='cm', v-model='code', :options='cmOptions', @ready='onCmReady', @input='onCmInput')
6562
transition(name='editor-code-preview')
6663
.editor-code-preview(v-if='previewShown')
6764
.editor-code-preview-title(@click='previewShown = false') Preview
6865
.editor-code-preview-content.markdown-content(ref='editorPreview', v-html='previewHTML')
6966

70-
v-speed-dial(v-model='fabInsertMenu', :open-on-hover='true', direction='top', transition='slide-y-reverse-transition', fixed, right, bottom)
67+
v-speed-dial(v-model='fabInsertMenu', :open-on-hover='true', direction='top', transition='slide-y-reverse-transition', fixed, left, bottom)
7168
v-btn(color='blue', fab, dark, v-model='fabInsertMenu', slot='activator')
7269
v-icon add_circle
7370
v-icon close
@@ -276,7 +273,7 @@ export default {
276273
background-color: darken(mc('grey', '900'), 4.5%);
277274
flex: 1 1 50%;
278275
display: block;
279-
height: calc(100vh - 100px);
276+
height: calc(100vh - 96px);
280277
position: relative;
281278
282279
&-title {
@@ -361,48 +358,12 @@ export default {
361358
&-toolbar {
362359
background-color: mc('blue', '700');
363360
background-image: linear-gradient(to bottom, mc('blue', '700') 0%, mc('blue','800') 100%);
364-
height: 50px;
365361
color: #FFF;
366-
display: flex;
367362
368363
@include until($tablet) {
369364
justify-content: center;
370365
}
371366
372-
&-group {
373-
display: flex;
374-
375-
+ .editor-code-toolbar-group {
376-
border-left: 1px solid rgba(mc('blue', '600'), .5);
377-
}
378-
}
379-
380-
&-item {
381-
width: 40px;
382-
height: 50px;
383-
display: flex;
384-
justify-content: center;
385-
align-items: center;
386-
transition: all .4s ease;
387-
cursor: pointer;
388-
389-
&:first-child {
390-
padding-left: .5rem;
391-
}
392-
393-
&:last-child {
394-
padding-right: .5rem;
395-
}
396-
397-
&:hover {
398-
background-color: mc('blue', '600');
399-
}
400-
401-
@include until($tablet) {
402-
width: 35px;
403-
}
404-
}
405-
406367
svg {
407368
use {
408369
color: #FFF;

client/components/nav-header.vue

+1-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@
3131
v-subheader Assets
3232
v-list-tile(avatar, @click='')
3333
v-list-tile-avatar: v-icon(color='blue-grey') burst_mode
34-
v-list-tile-content Images
35-
v-list-tile(avatar, @click='')
36-
v-list-tile-avatar: v-icon(color='blue-grey') description
37-
v-list-tile-content Files
34+
v-list-tile-content Images &amp; Files
3835
v-toolbar-title
3936
span.subheading Wiki.js
4037
v-spacer

server/db/migrations/2.0.0.js

+91-22
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,85 @@
11
exports.up = knex => {
22
return knex.schema
3-
// -------------------------------------
4-
// GROUPS
5-
// -------------------------------------
3+
// =====================================
4+
// MODEL TABLES
5+
// =====================================
6+
// ASSETS ------------------------------
7+
.createTable('assets', table => {
8+
table.increments('id').primary()
9+
table.string('filename').notNullable()
10+
table.string('basename').notNullable()
11+
table.string('ext').notNullable()
12+
table.enum('kind', ['binary', 'image']).notNullable().defaultTo('binary')
13+
table.string('mime').notNullable().defaultTo('application/octet-stream')
14+
table.integer('fileSize').unsigned().comment('In kilobytes')
15+
table.jsonb('metadata')
16+
table.string('createdAt').notNullable()
17+
table.string('updatedAt').notNullable()
18+
})
19+
// ASSET FOLDERS -----------------------
20+
.createTable('assetFolders', table => {
21+
table.increments('id').primary()
22+
table.string('name').notNullable()
23+
table.string('slug').notNullable()
24+
table.integer('parentId').unsigned().references('id').inTable('assetFolders')
25+
})
26+
// COMMENTS ----------------------------
27+
.createTable('comments', table => {
28+
table.increments('id').primary()
29+
table.text('content').notNullable()
30+
table.string('createdAt').notNullable()
31+
table.string('updatedAt').notNullable()
32+
})
33+
// GROUPS ------------------------------
634
.createTable('groups', table => {
735
table.increments('id').primary()
8-
936
table.string('name').notNullable()
1037
table.string('createdAt').notNullable()
1138
table.string('updatedAt').notNullable()
1239
})
13-
// -------------------------------------
14-
// LOCALES
15-
// -------------------------------------
40+
// LOCALES -----------------------------
1641
.createTable('locales', table => {
1742
table.increments('id').primary()
18-
1943
table.string('code', 2).notNullable().unique()
20-
table.json('strings')
44+
table.jsonb('strings')
2145
table.boolean('isRTL').notNullable().defaultTo(false)
2246
table.string('name').notNullable()
2347
table.string('nativeName').notNullable()
2448
table.string('createdAt').notNullable()
2549
table.string('updatedAt').notNullable()
2650
})
27-
// -------------------------------------
28-
// SETTINGS
29-
// -------------------------------------
51+
// PAGES -------------------------------
52+
.createTable('pages', table => {
53+
table.increments('id').primary()
54+
table.string('path').notNullable()
55+
table.string('title').notNullable()
56+
table.string('description')
57+
table.boolean('isPublished').notNullable().defaultTo(false)
58+
table.string('publishStartDate')
59+
table.string('publishEndDate')
60+
table.text('content')
61+
table.string('createdAt').notNullable()
62+
table.string('updatedAt').notNullable()
63+
})
64+
// SETTINGS ----------------------------
3065
.createTable('settings', table => {
3166
table.increments('id').primary()
32-
3367
table.string('key').notNullable().unique()
34-
table.json('value')
68+
table.jsonb('value')
69+
table.string('createdAt').notNullable()
70+
table.string('updatedAt').notNullable()
71+
})
72+
// TAGS --------------------------------
73+
.createTable('tags', table => {
74+
table.increments('id').primary()
75+
table.string('tag').notNullable().unique()
76+
table.string('title')
3577
table.string('createdAt').notNullable()
3678
table.string('updatedAt').notNullable()
3779
})
38-
// -------------------------------------
39-
// USERS
40-
// -------------------------------------
80+
// USERS -------------------------------
4181
.createTable('users', table => {
4282
table.increments('id').primary()
43-
4483
table.string('email').notNullable()
4584
table.string('name').notNullable()
4685
table.string('provider').notNullable().defaultTo('local')
@@ -54,22 +93,52 @@ exports.up = knex => {
5493

5594
table.unique(['provider', 'email'])
5695
})
57-
// -------------------------------------
58-
// USER GROUPS
59-
// -------------------------------------
96+
// =====================================
97+
// RELATION TABLES
98+
// =====================================
99+
// PAGE TAGS ---------------------------
100+
.createTable('pageTags', table => {
101+
table.increments('id').primary()
102+
table.integer('pageId').unsigned().references('id').inTable('pages')
103+
table.integer('tagId').unsigned().references('id').inTable('tags')
104+
})
105+
// USER GROUPS -------------------------
60106
.createTable('userGroups', table => {
61107
table.increments('id').primary()
62-
63108
table.integer('userId').unsigned().references('id').inTable('users')
64109
table.integer('groupId').unsigned().references('id').inTable('groups')
65110
})
111+
// =====================================
112+
// REFERENCES
113+
// =====================================
114+
.table('assets', table => {
115+
table.integer('folderId').unsigned().references('id').inTable('assetFolders')
116+
table.integer('authorId').unsigned().references('id').inTable('users')
117+
})
118+
.table('comments', table => {
119+
table.integer('pageId').unsigned().references('id').inTable('pages')
120+
table.integer('authorId').unsigned().references('id').inTable('users')
121+
})
122+
.table('pages', table => {
123+
table.string('locale', 2).references('code').inTable('locales')
124+
table.integer('authorId').unsigned().references('id').inTable('users')
125+
})
126+
.table('users', table => {
127+
table.string('locale', 2).references('code').inTable('locales')
128+
})
66129
}
67130

68131
exports.down = knex => {
69132
return knex.schema
70133
.dropTableIfExists('userGroups')
134+
.dropTableIfExists('pageTags')
135+
.dropTableIfExists('assets')
136+
.dropTableIfExists('assetFolders')
137+
.dropTableIfExists('comments')
71138
.dropTableIfExists('groups')
72139
.dropTableIfExists('locales')
140+
.dropTableIfExists('pages')
73141
.dropTableIfExists('settings')
142+
.dropTableIfExists('tags')
74143
.dropTableIfExists('users')
75144
}

0 commit comments

Comments
 (0)