Commit 23a6be12 authored by NGPixel's avatar NGPixel

refactor: removed 1.x client files

parent 30ce9c86
{ {
"comments": true, "comments": true,
"plugins": [
"lodash",
"graphql-tag"
],
"presets": [ "presets": [
["env"], ["env"],
"stage-2" "stage-2"
......
...@@ -13,12 +13,14 @@ import { ApolloLink } from 'apollo-link' ...@@ -13,12 +13,14 @@ import { ApolloLink } from 'apollo-link'
import { createApolloFetch } from 'apollo-fetch' import { createApolloFetch } from 'apollo-fetch'
import { BatchHttpLink } from 'apollo-link-batch-http' import { BatchHttpLink } from 'apollo-link-batch-http'
import { InMemoryCache } from 'apollo-cache-inmemory' import { InMemoryCache } from 'apollo-cache-inmemory'
import Hammer from 'hammerjs'
import store from './store' import store from './store'
// ==================================== // ====================================
// Load Modules // Load Modules
// ==================================== // ====================================
import boot from './modules/boot'
import localization from './modules/localization' import localization from './modules/localization'
// ==================================== // ====================================
...@@ -28,46 +30,13 @@ import localization from './modules/localization' ...@@ -28,46 +30,13 @@ import localization from './modules/localization'
import helpers from './helpers' import helpers from './helpers'
// ==================================== // ====================================
// Load Vue Components
// ====================================
import alertComponent from './components/alert.vue'
import anchorComponent from './components/anchor.vue'
import colorPickerComponent from './components/color-picker.vue'
import editorCodeblockComponent from './components/editor-codeblock.vue'
import editorFileComponent from './components/editor-file.vue'
import editorVideoComponent from './components/editor-video.vue'
import historyComponent from './components/history.vue'
import loadingSpinnerComponent from './components/loading-spinner.vue'
import loginComponent from './components/login.vue'
import modalCreatePageComponent from './components/modal-create-page.vue'
import modalCreateUserComponent from './components/modal-create-user.vue'
import modalDeletePageComponent from './components/modal-delete-page.vue'
import modalDeleteUserComponent from './components/modal-delete-user.vue'
import modalDiscardPageComponent from './components/modal-discard-page.vue'
import modalMovePageComponent from './components/modal-move-page.vue'
import modalProfile2faComponent from './components/modal-profile-2fa.vue'
import modalUpgradeSystemComponent from './components/modal-upgrade-system.vue'
import navigatorComponent from './components/navigator.vue'
import pageLoaderComponent from './components/page-loader.vue'
import searchComponent from './components/search.vue'
import toggleComponent from './components/toggle.vue'
import treeComponent from './components/tree.vue'
import adminEditUserComponent from './pages/admin-edit-user.component.js'
import adminProfileComponent from './pages/admin-profile.component.js'
import adminSettingsComponent from './pages/admin-settings.component.js'
import adminThemeComponent from './pages/admin-theme.component.js'
import contentViewComponent from './pages/content-view.component.js'
import editorComponent from './components/editor.component.js'
import sourceViewComponent from './pages/source-view.component.js'
// ====================================
// Initialize Global Vars // Initialize Global Vars
// ==================================== // ====================================
window.wiki = null window.wiki = null
window.boot = boot
window.CONSTANTS = CONSTANTS window.CONSTANTS = CONSTANTS
window.Hammer = Hammer
// ==================================== // ====================================
// Initialize Apollo Client (GraphQL) // Initialize Apollo Client (GraphQL)
...@@ -128,38 +97,12 @@ Vue.use(VeeValidate, { ...@@ -128,38 +97,12 @@ Vue.use(VeeValidate, {
// Register Vue Components // Register Vue Components
// ==================================== // ====================================
Vue.component('alert', alertComponent) Vue.component('login', () => import(/* webpackMode: "eager" */ './components/login.vue'))
Vue.component('adminEditUser', adminEditUserComponent) Vue.component('navigator', () => import(/* webpackMode: "eager" */ './components/navigator.vue'))
Vue.component('adminProfile', adminProfileComponent)
Vue.component('adminSettings', adminSettingsComponent)
Vue.component('adminTheme', adminThemeComponent)
Vue.component('anchor', anchorComponent)
Vue.component('colorPicker', colorPickerComponent)
Vue.component('contentView', contentViewComponent)
Vue.component('editor', editorComponent)
Vue.component('editorCodeblock', editorCodeblockComponent)
Vue.component('editorFile', editorFileComponent)
Vue.component('editorVideo', editorVideoComponent)
Vue.component('history', historyComponent)
Vue.component('loadingSpinner', loadingSpinnerComponent)
Vue.component('login', loginComponent)
Vue.component('modalCreatePage', modalCreatePageComponent)
Vue.component('modalCreateUser', modalCreateUserComponent)
Vue.component('modalDeletePage', modalDeletePageComponent)
Vue.component('modalDeleteUser', modalDeleteUserComponent)
Vue.component('modalDiscardPage', modalDiscardPageComponent)
Vue.component('modalMovePage', modalMovePageComponent)
Vue.component('modalProfile2fa', modalProfile2faComponent)
Vue.component('modalUpgradeSystem', modalUpgradeSystemComponent)
Vue.component('navigator', navigatorComponent)
Vue.component('pageLoader', pageLoaderComponent)
Vue.component('search', searchComponent)
Vue.component('setup', () => import(/* webpackChunkName: "setup" */ './components/setup.vue')) Vue.component('setup', () => import(/* webpackChunkName: "setup" */ './components/setup.vue'))
Vue.component('sourceView', sourceViewComponent) Vue.component('toggle', () => import(/* webpackMode: "eager" */ './components/toggle.vue'))
Vue.component('toggle', toggleComponent)
Vue.component('tree', treeComponent)
document.addEventListener('DOMContentLoaded', ev => { let bootstrap = () => {
// ==================================== // ====================================
// Notifications // Notifications
// ==================================== // ====================================
...@@ -178,16 +121,15 @@ document.addEventListener('DOMContentLoaded', ev => { ...@@ -178,16 +121,15 @@ document.addEventListener('DOMContentLoaded', ev => {
components: {}, components: {},
mixins: [helpers], mixins: [helpers],
store, store,
i18n, i18n
methods: {
changeTheme(opts) {
this.$el.className = `has-stickynav is-primary-${opts.primary} is-alternate-${opts.alt}`
this.$refs.header.className = `nav is-${opts.primary}`
this.$refs.footer.className = `footer is-${opts.footer}`
}
}
}) })
// ----------------------------------
// Dispatch boot ready
// ----------------------------------
window.boot.notify('vue')
// ==================================== // ====================================
// Load Icons // Load Icons
// ==================================== // ====================================
...@@ -195,4 +137,6 @@ document.addEventListener('DOMContentLoaded', ev => { ...@@ -195,4 +137,6 @@ document.addEventListener('DOMContentLoaded', ev => {
import(/* webpackChunkName: "icons" */ '../svg/icons.svg').then(icons => { import(/* webpackChunkName: "icons" */ '../svg/icons.svg').then(icons => {
document.body.insertAdjacentHTML('beforeend', icons) document.body.insertAdjacentHTML('beforeend', icons)
}) })
}) }
window.boot.onDOMReady(bootstrap)
// ======================================= // =======================================
// Intl polyfill
// =======================================
// Requirement: Safari 9 and below
if (!global.Intl) {
require('intl')
require('intl/locale-data/jsonp/en')
require('intl/locale-data/jsonp/fr')
}
// =======================================
// Promise polyfill // Promise polyfill
// ======================================= // =======================================
// Requirement: IE 11 and below // Requirement: IE 11 and below
......
<template lang="pug">
transition(name='alert', enter-active-class="animated zoomIn", leave-active-class="animated fadeOutRight")
.alert(v-if='shown', v-bind:class='style')
.alert-icon: i(v-bind:class='icon')
.alert-msg {{ msg }}
</template>
<script>
export default {
name: 'alert',
data () {
return {}
},
computed: {
shown() { return this.$store.state.alert.shown },
style() { return 'is-' + this.$store.state.alert.style },
icon() { return 'nc-icon-outline ' + this.$store.state.alert.icon },
msg() { return this.$store.state.alert.msg }
}
}
</script>
<template lang="pug">
transition(:duration="400")
.modal(v-show='isShown', v-cloak)
transition(name='modal-background')
.modal-background(v-show='isShown')
.modal-container
transition(name='modal-content')
.modal-content(v-show='isShown')
header.is-blue
span {{ $t('modal.anchortitle') }}
section
p.control.is-fullwidth
input.input(type='text', ref='anchorURLinput', v-model='anchorURL')
footer
a.button.is-grey.is-outlined(v-on:click='cancel') {{ $t('modal.discard') }}
a.button.is-blue(v-clipboard='anchorURL', @success="clipboardSuccess", @error="clipboardError") {{ $t('modal.copyclipboard') }}
</template>
<script>
export default {
name: 'anchor',
data () {
return {}
},
computed: {
anchorURL () {
return window.location.href.split('#')[0] + '#' + this.$store.state.anchor.hash
},
isShown () {
return this.$store.state.anchor.shown
}
},
methods: {
cancel () {
this.$store.dispatch('anchor/close')
},
clipboardSuccess () {
this.$store.dispatch('alert', {
style: 'blue',
icon: 'business_notes',
msg: this.$t('modal.anchorsuccess')
})
this.$store.dispatch('anchor/close')
},
clipboardError () {
this.$store.dispatch('alert', {
style: 'red',
icon: 'business_notes',
msg: this.$t('modal.anchorerror')
})
this.$refs.anchorURLinput.select()
}
}
}
</script>
<template lang="pug">
.colorpicker
.colorpicker-choice(v-for='color in colors', :class='["is-" + color, color === value ? "is-active" : ""]', @click='setColor(color)')
</template>
<script>
export default {
name: 'color-picker',
props: ['value'],
data () {
return {
colors: [
'red',
'pink',
'purple',
'deep-purple',
'indigo',
'blue',
'light-blue',
'cyan',
'teal',
'green',
'light-green',
'lime',
'yellow',
'amber',
'orange',
'deep-orange',
'brown',
'grey',
'blue-grey'
]
}
},
methods: {
setColor(color) {
this.$emit('input', color)
}
}
}
</script>
<template lang="pug">
transition(:duration="400")
.modal(v-show='isShown', v-cloak)
transition(name='modal-background')
.modal-background(v-show='isShown')
.modal-container
transition(name='modal-content')
.modal-content.is-expanded(v-show='isShown')
header.is-green
span {{ $t('editor.codeblocktitle') }}
p.modal-notify(v-bind:class='{ "is-active": isLoading }')
span {{ $t('editor.codeblockloading', { name: modeSelected }) }}
i
section.is-gapless
.columns.is-stretched
.column.is-one-quarter.modal-sidebar.is-green(style={'max-width':'350px'})
.model-sidebar-header {{ $t('editor.codeblocklanguage') }}
.model-sidebar-content
p.control.is-fullwidth
select(v-model='modeSelected')
option(v-for='mode in modes', v-bind:value='mode.name') {{ mode.caption }}
.column.ace-container
#codeblock-editor
footer
a.button.is-grey.is-outlined(v-on:click='cancel') {{ $t('editor.discard') }}
a.button.is-green(v-on:click='insertCode') {{ $t('editor.codeblockinsert') }}
</template>
<script>
let codeEditor
let ace
export default {
name: 'editor-codeblock',
data() {
return {
modes: [],
modeSelected: 'text',
modelistLoaded: [],
isLoading: false
}
},
computed: {
content() {
return this.$store.state.editorCodeblock.content
},
isShown() {
return this.$store.state.editorCodeblock.shown
}
},
watch: {
modeSelected(val, oldVal) {
this.loadMode(val)
}
},
methods: {
init() {
let self = this
self._.delay(() => {
codeEditor = ace.edit('codeblock-editor')
codeEditor.setTheme('ace/theme/tomorrow_night')
codeEditor.getSession().setMode('ace/mode/' + self.modeSelected)
codeEditor.setOption('fontSize', '14px')
codeEditor.setOption('hScrollBarAlwaysVisible', false)
codeEditor.setOption('wrap', true)
codeEditor.setOption('useSoftTabs', true)
codeEditor.setOption('tabSize', 2)
codeEditor.setOption('showPrintMargin', false)
codeEditor.setValue(self.content)
codeEditor.focus()
codeEditor.renderer.updateFull()
}, 100)
},
loadMode(m) {
let self = this
if (self._.includes(self.modelistLoaded, m)) {
codeEditor.getSession().setMode('ace/mode/' + m)
} else {
self.isLoading = true
self.$http.get('/js/ace/mode-' + m + '.js').then(resp => {
if (resp.ok) {
eval(resp.bodyText) // eslint-disable-line no-eval
self.modelistLoaded.push(m)
ace.acequire('ace/mode/' + m)
codeEditor.getSession().setMode('ace/mode/' + m)
self._.delay(() => { self.isLoading = false }, 500)
} else {
this.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: self.$t('editor.codeblockloadingerror')
})
}
}).catch(err => {
this.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: 'Error: ' + err.body.msg
})
})
}
},
cancel() {
codeEditor.destroy()
this.$store.dispatch('editorCodeblock/close')
},
insertCode() {
let codeBlockText = '\n```' + this.modeSelected + '\n' + codeEditor.getValue() + '\n```\n'
this.$store.dispatch('editor/insert', codeBlockText)
this.$store.dispatch('alert', {
style: 'blue',
icon: 'files_archive-3d-check',
msg: this.$t('editor.codeblocksuccess')
})
this.cancel()
}
},
mounted() {
FuseBox.import('/js/ace/ace.js', (acePkg) => {
ace = acePkg
this.modes = ace.acequire('ace/ext/modelist').modesByName
})
this.$root.$on('editorCodeblock/init', this.init)
}
}
</script>
<template lang="pug">
transition(:duration="400")
.modal(v-show='isShown', v-cloak)
transition(name='modal-background')
.modal-background(v-show='isShown')
.modal-container
transition(name='modal-content')
.modal-content(v-show='isShown')
header.is-green
span {{ $t('editor.videotitle') }}
section
label.label
p.control.is-fullwidth
input.input(type='text', placeholder='https://www.youtube.com/watch?v=xxxxxxxxxxx', v-model='link', ref='editorVideoInput', @keyup.enter='insertVideo', @keyup.esc='cancel')
span.help.is-red(v-show='isInvalid') {{ $t('editor.videonotsupported') }}
.note {{ $t('editor.videosupportedtitle') }}
ul
li
i.icon-youtube-play
span Youtube
li
i.icon-vimeo
span Vimeo
li
i.nc-icon-outline.media-1_play-69
span Dailymotion
li
i.icon-video
span {{ $t('editor.videoanymp4file') }}
footer
a.button.is-grey.is-outlined(v-on:click='cancel') {{ $t('editor.discard') }}
a.button.is-green(v-on:click='insertVideo') {{ $t('editor.videoinsert') }}
</template>
<script>
const videoRules = {
'youtube': new RegExp('/(?:(?:youtu\\.be\\/|v\\/|vi\\/|u\\/\\w\\/|embed\\/)|(?:(?:watch)?\\?v(?:i)?=|&v(?:i)?=))([^#&?]*).*/', 'i'),
'vimeo': new RegExp('/vimeo.com\\/(?:channels\\/(?:\\w+\\/)?|groups\\/(?:[^/]*)\\/videos\\/|album\\/(?:\\d+)\\/video\\/|)(\\d+)(?:$|\\/|\\?)/', 'i'),
'dailymotion': new RegExp('/(?:dailymotion\\.com(?:\\/embed)?(?:\\/video|\\/hub)|dai\\.ly)\\/([0-9a-z]+)(?:[-_0-9a-zA-Z]+(?:#video=)?([a-z0-9]+)?)?/', 'i')
}
export default {
name: 'editor-video',
data () {
return {
link: '',
isInvalid: false
}
},
computed: {
isShown () {
return this.$store.state.editorVideo.shown
}
},
methods: {
init () {
let self = this
self.isInvalid = false
self._.delay(() => {
self.$refs.editorVideoInput.focus()
}, 100)
},
cancel () {
this.$store.dispatch('editorVideo/close')
},
insertVideo () {
let self = this
if (this._.isEmpty(self.link) || self.link.length < 5) {
this.isInvalid = true
return
}
let videoType = this._.findKey(videoRules, (vr) => {
return vr.test(self.link)
})
if (this._.isNil(videoType)) {
videoType = 'video'
}
let videoText = '[video](' + this.link + '){.' + videoType + '}\n'
this.$store.dispatch('editor/insert', videoText)
this.$store.dispatch('alert', {
style: 'blue',
icon: 'media-1_action-74',
msg: self.$t('editor.videosuccess')
})
this.cancel()
}
},
mounted () {
this.$root.$on('editorVideo/init', this.init)
}
}
</script>
/* global $, siteRoot */
let mde
export default {
name: 'editor',
props: ['currentPath'],
data() {
return {}
},
computed: {
insertContent() {
return this.$store.state.editor.insertContent
}
},
methods: {
insert(content) {
if (mde.codemirror.doc.somethingSelected()) {
mde.codemirror.execCommand('singleSelection')
}
mde.codemirror.doc.replaceSelection(this.insertContent)
},
save() {
let self = this
this.$http.put(window.location.href, {
markdown: mde.value()
}).then(resp => {
return resp.json()
}).then(resp => {
if (resp.ok) {
window.location.assign(siteRoot + '/' + self.currentPath)
} else {
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: resp.msg
})
}
}).catch(err => {
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: 'Error: ' + err.body.msg
})
})
}
},
mounted() {
let self = this
FuseBox.import('/js/simplemde/simplemde.min.js', (SimpleMDE) => {
mde = new SimpleMDE({
autofocus: true,
autoDownloadFontAwesome: false,
element: this.$refs.editorTextArea,
placeholder: 'Enter Markdown formatted content here...',
spellChecker: false,
status: false,
toolbar: [
{
name: 'bold',
action: SimpleMDE.toggleBold,
className: 'icon-bold',
title: 'Bold'
},
{
name: 'italic',
action: SimpleMDE.toggleItalic,
className: 'icon-italic',
title: 'Italic'
},
{
name: 'strikethrough',
action: SimpleMDE.toggleStrikethrough,
className: 'icon-strikethrough',
title: 'Strikethrough'
},
'|',
{
name: 'heading-1',
action: SimpleMDE.toggleHeading1,
className: 'icon-header fa-header-x fa-header-1',
title: 'Header (Level 1)'
},
{
name: 'heading-2',
action: SimpleMDE.toggleHeading2,
className: 'icon-header fa-header-x fa-header-2',
title: 'Header (Level 2)'
},
{
name: 'heading-3',
action: SimpleMDE.toggleHeading3,
className: 'icon-header fa-header-x fa-header-3',
title: 'Header (Level 3)'
},
{
name: 'quote',
action: SimpleMDE.toggleBlockquote,
className: 'nc-icon-outline text_quote',
title: 'Quote'
},
'|',
{
name: 'unordered-list',
action: SimpleMDE.toggleUnorderedList,
className: 'nc-icon-outline text_list-bullet',
title: 'Bullet List'
},
{
name: 'ordered-list',
action: SimpleMDE.toggleOrderedList,
className: 'nc-icon-outline text_list-numbers',
title: 'Numbered List'
},
'|',
{
name: 'link',
action: (editor) => {
window.alert('Coming soon!')
// todo
},
className: 'nc-icon-outline ui-2_link-68',
title: 'Insert Link'
},
{
name: 'image',
action: (editor) => {
self.$store.dispatch('editorFile/open', { mode: 'image' })
},
className: 'nc-icon-outline design_image',
title: 'Insert Image'
},
{
name: 'file',
action: (editor) => {
self.$store.dispatch('editorFile/open', { mode: 'file' })
},
className: 'nc-icon-outline files_zip-54',
title: 'Insert File'
},
{
name: 'video',
action: (editor) => {
self.$store.dispatch('editorVideo/open')
},
className: 'nc-icon-outline media-1_video-64',
title: 'Insert Video Player'
},
'|',
{
name: 'inline-code',
action: (editor) => {
if (!editor.codemirror.doc.somethingSelected()) {
return self.$store.dispatch('alert', {
style: 'orange',
icon: 'design_drag',
msg: 'Invalid selection. Select at least 1 character.'
})
}
let curSel = editor.codemirror.doc.getSelections()
curSel = self._.map(curSel, (s) => {
return '`' + s + '`'
})
editor.codemirror.doc.replaceSelections(curSel)
},
className: 'nc-icon-outline arrows-4_enlarge-46',
title: 'Inline Code'
},
{
name: 'code-block',
action: (editor) => {
self.$store.dispatch('editorCodeblock/open', {
initialContent: (mde.codemirror.doc.somethingSelected()) ? mde.codemirror.doc.getSelection() : ''
})
},
className: 'nc-icon-outline design_code',
title: 'Code Block'
},
'|',
{
name: 'table',
action: (editor) => {
window.alert('Coming soon!')
// todo
},
className: 'nc-icon-outline ui-2_grid-square',
title: 'Insert Table'
},
{
name: 'horizontal-rule',
action: SimpleMDE.drawHorizontalRule,
className: 'nc-icon-outline design_distribute-vertical',
title: 'Horizontal Rule'
}
],
shortcuts: {
'toggleBlockquote': null,
'toggleFullScreen': null
}
})
// Save
$(window).bind('keydown', (ev) => {
if (ev.ctrlKey || ev.metaKey) {
switch (String.fromCharCode(ev.which).toLowerCase()) {
case 's':
ev.preventDefault()
self.save()
break
}
}
})
// Listeners
this.$root.$on('editor/save', this.save)
this.$root.$on('editor/insert', this.insert)
this.$store.dispatch('pageLoader/complete')
})
}
}
<template lang="pug">
.container.is-fluid
.columns.is-gapless
.column.is-narrow.is-hidden-touch.sidebar
aside.stickyscroll
.sidebar-label
span {{ $t('history.pastversions') }}
ul.sidebar-menu
li(v-for='item in versions')
a.is-multiline(:title='item.dateFull', @click='changeCommit(item)', :class='{ "is-active": item.commit === current.commit }')
span {{ item.dateCalendar }}
span.is-small {{ item.commitAbbr }}
.column
.history
.history-title {{ currentPath }}
.history-info
.columns
.column.history-info-meta
p
i.nc-icon-outline.ui-1_calendar-check-62
span {{ $t('history.timestamp') }}: #[strong {{ current.dateFull }}]
p
i.nc-icon-outline.i.nc-icon-outline.users_man-23
span {{ $t('history.author') }}: #[strong {{ current.name }} &lt;{{ current.email }}&gt;]
p
i.nc-icon-outline.media-1_flash-21
span {{ $t('history.commit') }}: #[strong {{ current.commit }}]
.column.history-info-actions
.button-group
button.button.is-blue-grey(@click='compareWith')
i.nc-icon-outline.design_path-intersect
span {{ $t('history.comparewith') }}
button.button.is-blue-grey(@click='view')
i.nc-icon-outline.ui-1_eye-17
span {{ $t('history.view') }}
button.button.is-blue-grey(@click='revertToVersion')
i.nc-icon-outline.arrows-4_undo-29
span {{ $t('history.reverttoversion') }}
toggle.is-dark(v-model='sidebyside', :desc='$t("history.sidebyside")')
.history-diff#diff
</template>
<script>
/* global wiki, Diff2HtmlUI */
let diffui
let diffuiIsReady = false
export default {
name: 'history',
props: ['currentPath', 'historyData'],
data() {
return {
versions: [],
current: {},
diffui: {},
sidebyside: true
}
},
watch: {
sidebyside() {
this.draw()
}
},
methods: {
compareWith() {
this.$store.dispatch('alert', {
style: 'purple',
icon: 'objects_astronaut',
msg: 'Sorry, this function is not available. Coming soon!'
})
},
view() {
this.$store.dispatch('alert', {
style: 'purple',
icon: 'objects_astronaut',
msg: 'Sorry, this function is not available. Coming soon!'
})
},
revertToVersion() {
this.$store.dispatch('alert', {
style: 'purple',
icon: 'objects_astronaut',
msg: 'Sorry, this function is not available. Coming soon!'
})
},
draw() {
if (diffuiIsReady) {
diffui.draw('#diff', {
inputFormat: 'diff',
outputFormat: this.sidebyside ? 'side-by-side' : 'line-by-line',
matching: 'words',
synchronisedScroll: true
})
}
},
changeCommit(cm) {
let self = this
diffuiIsReady = false
self.current = cm
self.$http.post(wiki.siteRoot + '/hist', {
path: self.currentPath,
commit: cm.commit
}).then(resp => {
return resp.json()
}).then(resp => {
diffui = new Diff2HtmlUI({ diff: resp.diff })
diffuiIsReady = true
self.draw()
}).catch(err => {
console.log(err)
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: 'Error: ' + err.body.error
})
})
}
},
mounted() {
this.versions = JSON.parse(this.historyData)
this.changeCommit(this.versions[0])
}
}
</script>
<template lang="pug">
i.nav-item#notifload(v-bind:class='{ "is-active": loading }')
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'loading-spinner',
computed: mapState(['loading'])
}
</script>
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
/* global CONSTANTS, graphQL, siteConfig */ /* global CONSTANTS, graphQL, siteConfig */
export default { export default {
name: 'login',
data () { data () {
return { return {
error: false, error: false,
...@@ -50,6 +49,11 @@ export default { ...@@ -50,6 +49,11 @@ export default {
return siteConfig.title return siteConfig.title
} }
}, },
mounted () {
this.$store.commit('navigator/subtitleStatic', 'Login')
this.refreshStrategies()
this.$refs.iptEmail.focus()
},
methods: { methods: {
selectStrategy (key, useForm) { selectStrategy (key, useForm) {
this.selectedStrategy = key this.selectedStrategy = key
...@@ -188,11 +192,6 @@ export default { ...@@ -188,11 +192,6 @@ export default {
}) })
} }
} }
},
mounted () {
this.$store.commit('navigator/subtitleStatic', 'Login')
this.refreshStrategies()
this.$refs.iptEmail.focus()
} }
} }
</script> </script>
......
<template lang="pug">
transition(:duration="400")
.modal(v-show='isShown', v-cloak)
transition(name='modal-background')
.modal-background(v-show='isShown')
.modal-container
transition(name='modal-content')
.modal-content(v-show='isShown')
header.is-light-blue {{ $t('modal.createpagetitle') }}
section
label.label {{ $t('modal.createpagepath') }}
p.control.is-fullwidth(v-bind:class='{ "is-loading": isLoading }')
input.input(type='text', placeholder='page-name', v-model='userPath', ref='createPageInput', @keyup.enter='create', @keyup.esc='cancel')
span.help.is-red(v-show='isInvalid') {{ $t('modal.createpageinvalid') }}
footer
a.button.is-grey.is-outlined(v-on:click='cancel') {{ $t('modal.discard') }}
a.button.is-light-blue(v-on:click='create') {{ $t('modal.create') }}
</template>
<script>
export default {
name: 'modal-create-page',
props: ['basepath'],
data () {
return {
currentPath: '',
userPath: '',
isLoading: false,
isInvalid: false
}
},
computed: {
isShown () {
if (this.$store.state.modalCreatePage.shown) {
this.makeSelection()
}
return this.$store.state.modalCreatePage.shown
}
},
methods: {
makeSelection: function () {
let self = this
self._.delay(() => {
let startPos = (self.currentPath.length > 0) ? self.currentPath.length + 1 : 0
self.$helpers.form.setInputSelection(self.$refs.createPageInput, startPos, self.userPath.length)
}, 100)
},
cancel: function () {
this.$store.dispatch('modalCreatePage/close')
},
create: function () {
this.isInvalid = false
let newDocPath = this.$helpers.pages.makeSafePath(this.userPath)
if (this._.isEmpty(newDocPath)) {
this.isInvalid = true
} else {
this.isLoading = true
window.location.assign('/create/' + newDocPath)
}
}
},
mounted () {
this.currentPath = (this.basepath === 'home') ? '' : this.basepath
this.userPath = (this._.isEmpty(this.currentPath)) ? 'new-page' : this.currentPath + '/new-page'
}
}
</script>
<template lang="pug">
transition(:duration="400")
.modal(v-show='isShown', v-cloak)
transition(name='modal-background')
.modal-background(v-show='isShown')
.modal-container
transition(name='modal-content')
.modal-content(v-show='isShown')
header.is-blue
span {{ $t('modal.createusertitle') }}
p.modal-notify(:class='{ "is-active": isLoading }'): i
section
label.label {{ $t('modal.createuseremail') }}
p.control.is-fullwidth
input.input(type='text', :placeholder='$t("modal.createuseremailplaceholder")', v-model='email', ref='createUserEmailInput')
section
label.label {{ $t('modal.createuserprovider') }}
p.control.is-fullwidth
select(v-model='provider')
option(value='local') Local Database
option(value='windowslive') Microsoft Account
option(value='google') Google ID
option(value='facebook') Facebook
option(value='github') GitHub
option(value='slack') Slack
section(v-if='provider=="local"')
label.label {{ $t('modal.createuserpassword') }}
p.control.is-fullwidth
input.input(type='password', placeholder='', v-model='password')
section(v-if='provider=="local"')
label.label {{ $t('modal.createusername') }}
p.control.is-fullwidth
input.input(type='text', :placeholder='$t("modal.createusernameplaceholder")', v-model='name')
footer
a.button.is-grey.is-outlined(@click='cancel') {{ $t('modal.discard') }}
a.button(@click='create', v-if='provider=="local"', :disabled='isLoading', :class='{ "is-disabled": isLoading, "is-blue": !loading }') {{ $t('modal.createuser') }}
a.button(@click='create', v-if='provider!="local"', :disabled='isLoading', :class='{ "is-disabled": isLoading, "is-blue": !loading }') {{ $t('modal.createuserauthorize') }}
</template>
<script>
export default {
name: 'modal-create-user',
data() {
return {
email: '',
provider: 'local',
password: '',
name: '',
isLoading: false
}
},
computed: {
isShown() {
return this.$store.state.modalCreateUser.shown
}
},
methods: {
init() {
let self = this
self._.delay(() => {
self.$refs.createUserEmailInput.focus()
}, 100)
},
cancel() {
this.$store.dispatch('modalCreateUser/close')
this.email = ''
this.provider = 'local'
},
create() {
let self = this
this.isLoading = true
this.$http.post('/admin/users/create', {
email: this.email,
provider: this.provider,
password: this.password,
name: this.name
}).then(resp => {
return resp.json()
}).then(resp => {
this.isLoading = false
if (resp.ok) {
this.cancel()
window.location.reload(true)
} else {
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: resp.msg
})
}
}).catch(err => {
this.isLoading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: 'Error: ' + err.body.msg
})
})
}
},
mounted() {
this.$root.$on('modalCreateUser/init', this.init)
}
}
</script>
<template lang="pug">
transition(:duration="400")
.modal(v-show='isShown', v-cloak)
transition(name='modal-background')
.modal-background(v-show='isShown')
.modal-container
transition(name='modal-content')
.modal-content(v-show='isShown')
header.is-red
span {{ $t('modal.deletepagetitle') }}
p.modal-notify(v-bind:class='{ "is-active": isLoading }'): i
section
span {{ $t('modal.deletepagewarning') }}
footer
a.button.is-grey.is-outlined(v-on:click='discard') {{ $t('modal.discard') }}
a.button.is-red(v-on:click='deletePage') {{ $t('modal.delete') }}
</template>
<script>
export default {
name: 'modal-delete-page',
props: ['currentPath'],
data () {
return {
isLoading: false
}
},
computed: {
isShown () {
return this.$store.state.modalDeletePage.shown
}
},
methods: {
discard () {
this.isLoading = false
this.$store.dispatch('modalDeletePage/close')
},
deletePage () {
let self = this
this.isLoading = true
this.$http.delete(window.location.href).then(resp => {
return resp.json()
}).then(resp => {
if (resp.ok) {
window.location.assign('/')
} else {
self.isLoading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: resp.msg
})
}
}).catch(err => {
self.isLoading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: 'Error: ' + err.body.msg
})
})
}
}
}
</script>
<template lang="pug">
transition(:duration="400")
.modal(v-show='isShown', v-cloak)
transition(name='modal-background')
.modal-background(v-show='isShown')
.modal-container
transition(name='modal-content')
.modal-content(v-show='isShown')
header.is-red
span {{ $t('modal.deleteusertitle') }}
p.modal-notify(v-bind:class='{ "is-active": isLoading }'): i
section
span {{ $t('modal.deleteuserwarning') }}
footer
a.button.is-grey.is-outlined(@click='cancel') {{ $t('modal.abort') }}
a.button.is-red(@click='deleteUser') {{ $t('modal.delete') }}
</template>
<script>
export default {
name: 'modal-delete-user',
props: ['currentUser'],
data() {
return {
isLoading: false
}
},
computed: {
isShown() {
return this.$store.state.modalDeleteUser.shown
}
},
methods: {
cancel: function () {
this.isLoading = false
this.$store.dispatch('modalDeleteUser/close')
},
deleteUser: function () {
let self = this
this.isLoading = true
this.$http.delete('/admin/users/' + this.currentUser).then(resp => {
return resp.json()
}).then(resp => {
if (resp.ok) {
window.location.assign('/admin/users')
} else {
self.isLoading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: resp.msg
})
}
}).catch(err => {
self.isLoading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: 'Error: ' + err.body.msg
})
})
}
}
}
</script>
<template lang="pug">
transition(:duration="400")
.modal(v-show='isShown', v-cloak)
transition(name='modal-background')
.modal-background(v-show='isShown')
.modal-container
transition(name='modal-content')
.modal-content(v-show='isShown')
header.is-orange {{ $t('modal.discardpagetitle') }}
section
span(v-if='mode === "create"') {{ $t('modal.discardpagecreate') }}
span(v-else) {{ $t('modal.discardpageedit') }}
footer
a.button.is-grey.is-outlined(v-on:click='stay') {{ $t('modal.discardpagestay') }}
a.button.is-orange(v-on:click='discard') {{ $t('modal.discard') }}
</template>
<script>
export default {
name: 'modal-discard-page',
props: ['mode', 'currentPath'],
data () {
return {}
},
computed: {
isShown () {
return this.$store.state.modalDiscardPage.shown
}
},
methods: {
stay: function () {
this.$store.dispatch('modalDiscardPage/close')
},
discard: function () {
if (this.mode === 'create') {
window.location.assign('/')
} else {
window.location.assign('/' + this.currentPath)
}
}
}
}
</script>
<template lang="pug">
transition(:duration="400")
.modal(v-show='isShown', v-cloak)
transition(name='modal-background')
.modal-background(v-show='isShown')
.modal-container
transition(name='modal-content')
.modal-content(v-show='isShown')
header.is-indigo {{ $t('modal.movepagetitle') }}
section
label.label {{ $t('modal.movepagepath') }}
p.control.is-fullwidth(v-bind:class='{ "is-loading": isLoading }')
input.input(type='text', v-bind:placeholder='$t("modal.movepageplaceholder")', v-model='movePath', ref='movePageInput', @keyup.enter='move', @keyup.esc='cancel')
span.help.is-red(v-show='isInvalid') {{ $t('modal.movepageinvalid') }}
span.note {{ $t('modal.movepagewarning') }}
footer
a.button.is-grey.is-outlined(v-on:click='cancel') {{ $t('modal.discard') }}
a.button.is-indigo(v-on:click='move') {{ $t('modal.move') }}
</template>
<script>
export default {
name: 'modal-move-page',
props: ['currentPath'],
data () {
return {
movePath: '',
isLoading: false,
isInvalid: false
}
},
computed: {
isShown () {
if (this.$store.state.modalMovePage.shown) {
this.movePath = this.currentPath
this.makeSelection()
}
return this.$store.state.modalMovePage.shown
}
},
methods: {
makeSelection() {
let self = this
self._.delay(() => {
let startPos = (self._.includes(self.currentPath, '/')) ? self._.lastIndexOf(self.movePath, '/') + 1 : 0
self.$helpers.form.setInputSelection(self.$refs.movePageInput, startPos, self.movePath.length)
}, 100)
},
cancel() {
this.$store.dispatch('modalMovePage/close')
},
move () {
this.isInvalid = false
let newDocPath = this.$helpers.pages.makeSafePath(this.movePath)
if (this._.isEmpty(newDocPath) || newDocPath === this.currentPath || newDocPath === 'home') {
this.isInvalid = true
} else {
this.isLoading = true
this.$http.put(window.location.href, {
move: newDocPath
}).then(resp => {
return resp.json()
}).then(resp => {
if (resp.ok) {
window.location.assign('/' + newDocPath)
} else {
this.loading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: resp.msg
})
}
}).catch(err => {
this.loading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: 'Error: ' + err.body.msg
})
})
}
}
}
}
</script>
<template lang="pug">
transition(:duration="400")
.modal(v-show='isShown', v-cloak)
transition(name='modal-background')
.modal-background(v-show='isShown')
.modal-container
transition(name='modal-content')
.modal-content(v-show='isShown')
template(v-if='step === "qr"')
header.is-blue Setup your 2FA app
section.modal-loading
i
span Wiki.js {{ mode }} in progress...
em Please wait
template(v-if='step === "error"')
header.is-red Error
section.modal-loading
span {{ error }}
footer
a.button.is-grey.is-outlined(@click='cancel') Discard
template(v-if='step === "confirm"')
header.is-blue Two-Factor Authentication
section
label.label Do you want to enable 2FA?
span.note Two-Factor Authentication (2FA) provides an extra layer of security for your account. Upon login, you will be prompted to enter a token generated by a 2FA app (e.g. Authy, Google Authenticator, etc.).
footer
a.button.is-grey.is-outlined(@click='cancel') Discard
a.button.is-blue(@click='confirm') Setup
</template>
<script>
export default {
name: 'modal-profile-2fa',
data() {
return {
isLoading: false,
error: ''
}
},
computed: {
isShown() {
return this.$store.state.modalProfile2fa.shown
},
step() {
return this.$store.state.modalProfile2fa.step
}
},
methods: {
cancel() {
this.isLoading = false
this.$store.dispatch('modalProfile2fa/close')
},
confirm() {
this.$http.post('/admin/profile/2fa', {
action: 'setup'
}).then(resp => {
this.$store.commit('modalProfile2fa/stepChange', 'qr')
}).catch(err => {
this.$store.commit('modalProfile2fa/stepChange', 'error')
this.error = err.body.msg
})
}
}
}
</script>
<template lang="pug">
transition(:duration="400")
.modal(v-show='isShown', v-cloak)
transition(name='modal-background')
.modal-background(v-show='isShown')
.modal-container
transition(name='modal-content')
.modal-content(v-show='isShown')
template(v-if='step === "running"')
header.is-blue Install
section.modal-loading
i
span Wiki.js {{ mode }} in progress...
em Please wait
template(v-if='step === "error"')
header.is-red Installation Error
section.modal-loading
span {{ error }}
footer
a.button.is-grey.is-outlined(@click='upgradeCancel') Abort
a.button.is-deep-orange(@click='upgradeStart') Try Again
template(v-if='step === "confirm"')
header.is-deep-orange Are you sure?
section
label.label You are about to {{ mode }} Wiki.js.
span.note You will not be able to access your wiki during the operation. Content will not be affected. However, it is your responsability to ensure you have a backup in the unexpected event content gets lost or corrupted.
footer
a.button.is-grey.is-outlined(@click='upgradeCancel') Abort
a.button.is-deep-orange(@click='upgradeStart') Start
</template>
<script>
export default {
name: 'modal-upgrade-system',
data() {
return {
isLoading: false
}
},
computed: {
isShown() {
return this.$store.state.modalUpgradeSystem.shown
},
mode() {
return this.$store.state.modalUpgradeSystem.mode
},
step() {
return this.$store.state.modalUpgradeSystem.step
}
},
methods: {
upgradeCancel() {
this.isLoading = false
this.$store.dispatch('modalUpgradeSystem/close')
},
upgradeStart() {
this.$store.commit('modalUpgradeSystem/stepChange', 'running')
this.$http.post('/admin/system/install', {
mode: this.mode
}).then(resp => {
// todo
}).catch(err => {
this.$store.commit('modalUpgradeSystem/stepChange', 'error')
this.error = err.body
})
}
}
}
</script>
<template lang="pug">
transition(name='page-loader')
.page-loader(v-if='isShown')
i
span {{ msg }}
</template>
<script type='js'>
export default {
name: 'page-loader',
props: ['text'],
data () {
return {}
},
computed: {
msg () { return this.$store.state.pageLoader.msg },
isShown () { return this.$store.state.pageLoader.shown }
},
mounted() {
this.$store.commit('pageLoader/msgChange', this.text)
}
}
</script>
<template lang="pug">
.nav-item
p.control(v-bind:class='{ "is-loading": searchload > 0 }')
input.input#search-input(type='text', v-model='searchq', autofocus, @keyup.esc='closeSearch', @keyup.down='moveDownSearch', @keyup.up='moveUpSearch', @keyup.enter='moveSelectSearch', debounce='400', v-bind:placeholder='$t("search.placeholder")')
transition(name='searchresults')
.searchresults(v-show='searchactive', v-cloak)
p.searchresults-label {{ $t('search.results') }}
ul.searchresults-list
li(v-if='searchres.length === 0')
a: em {{ $t('search.nomatch') }}
li(v-for='sres in searchres', v-bind:class='{ "is-active": searchmovekey === "res." + sres.entryPath }')
a(v-bind:href='sres.entryPath') {{ sres.title }}
p.searchresults-label(v-if='searchsuggest.length > 0') {{ $t('search.didyoumean') }}
ul.searchresults-list(v-if='searchsuggest.length > 0')
li(v-for='sug in searchsuggest', v-bind:class='{ "is-active": searchmovekey === "sug." + sug }')
a(v-on:click='useSuggestion(sug)') {{ sug }}
</template>
<script>
/* global siteRoot, socket, $ */
export default {
data() {
return {
searchq: '',
searchres: [],
searchsuggest: [],
searchload: 0,
searchactive: false,
searchmoveidx: 0,
searchmovekey: '',
searchmovearr: []
}
},
watch: {
searchq: function (val, oldVal) {
let self = this
self.searchmoveidx = 0
if (val.length >= 3) {
self.searchactive = true
self.searchload++
socket.emit('search', { terms: val }, (data) => {
self.searchres = self._.map(data.match, m => {
m.entryPath = `${siteRoot}/${m.entryPath}`
return m
})
self.searchsuggest = data.suggest
self.searchmovearr = self._.concat([], self.searchres, self.searchsuggest)
if (self.searchload > 0) { self.searchload-- }
})
} else {
self.searchactive = false
self.searchres = []
self.searchsuggest = []
self.searchmovearr = []
self.searchload = 0
}
},
searchmoveidx: function (val, oldVal) {
if (val > 0) {
this.searchmovekey = (this.searchmovearr[val - 1]) ?
'res.' + this.searchmovearr[val - 1].entryPath :
'sug.' + this.searchmovearr[val - 1]
} else {
this.searchmovekey = ''
}
}
},
methods: {
useSuggestion: function (sug) {
this.searchq = sug
},
closeSearch: function () {
this.searchq = ''
},
moveSelectSearch: function () {
if (this.searchmoveidx < 1) { return }
let i = this.searchmoveidx - 1
if (this.searchmovearr[i]) {
window.location.assign(this.searchmovearr[i].entryPath)
} else {
this.searchq = this.searchmovearr[i]
}
},
moveDownSearch: function () {
if (this.searchmoveidx < this.searchmovearr.length) {
this.searchmoveidx++
}
},
moveUpSearch: function () {
if (this.searchmoveidx > 0) {
this.searchmoveidx--
}
}
},
mounted: function () {
let self = this
$('main').on('click', self.closeSearch)
}
}
</script>
<template lang="pug">
.has-collapsable-nav
ul.collapsable-nav(v-for='treeItem in tree', :class='{ "has-children": treeItem.hasChildren }', v-cloak)
li(v-for='page in treeItem.pages', :class='{ "is-active": page.isActive }')
a(v-on:click='mainAction(page)')
template(v-if='page._id !== "home"')
i(:class='{ "icon-folder2": page.isDirectory, "icon-file-text-o": !page.isDirectory }')
span {{ page.title }}
template(v-else)
i.icon-home
span {{ $t('nav.home') }}
a.is-pagelink(v-if='page.isDirectory && page.isEntry', v-on:click='goto(page._id)')
i.icon-file-text-o
i.icon-arrow-right2
</template>
<script>
/* global socket, siteRoot */
export default {
name: 'tree',
data () {
return {
tree: []
}
},
methods: {
fetch (basePath) {
let self = this
self.$store.dispatch('startLoading')
self.$nextTick(() => {
socket.emit('treeFetch', { basePath }, (data) => {
if (self.tree.length > 0) {
let branch = self._.last(self.tree)
branch.hasChildren = true
self._.find(branch.pages, { _id: basePath }).isActive = true
}
self.tree.push({
hasChildren: false,
pages: data
})
self.$store.dispatch('stopLoading')
})
})
},
goto (entryPath) {
window.location.assign(siteRoot + '/' + entryPath)
},
unfold (entryPath) {
let self = this
let lastIndex = 0
self._.forEach(self.tree, branch => {
lastIndex++
if (self._.find(branch.pages, { _id: entryPath }) !== undefined) {
return false
}
})
self.tree = self._.slice(self.tree, 0, lastIndex)
let branch = self._.last(self.tree)
branch.hasChildren = false
branch.pages.forEach(page => {
page.isActive = false
})
},
mainAction (page) {
let self = this
if (page.isActive) {
self.unfold(page._id)
} else if (page.isDirectory) {
self.fetch(page._id)
} else {
self.goto(page._id)
}
}
},
mounted () {
let basePath = window.location.pathname.slice(0, -4)
if (basePath.length > 1) {
basePath = basePath.slice(1)
}
this.fetch(basePath)
}
}
</script>
import filesize from 'filesize.js' import filesize from 'filesize.js'
import _ from 'lodash'
/* global siteConfig */ /* global siteConfig */
const _ = require('./lodash')
const helpers = { const helpers = {
/** /**
* Minimal set of lodash functions
*/
_,
/**
* Convert bytes to humanized form * Convert bytes to humanized form
* @param {number} rawSize Size in bytes * @param {number} rawSize Size in bytes
* @returns {string} Humanized file size * @returns {string} Humanized file size
......
// ====================================
// Load minimal lodash
// ====================================
import cloneDeep from 'lodash/cloneDeep'
import concat from 'lodash/concat'
import debounce from 'lodash/debounce'
import deburr from 'lodash/deburr'
import delay from 'lodash/delay'
import filter from 'lodash/filter'
import find from 'lodash/find'
import findKey from 'lodash/findKey'
import forEach from 'lodash/forEach'
import includes from 'lodash/includes'
import isBoolean from 'lodash/isBoolean'
import isEmpty from 'lodash/isEmpty'
import isNil from 'lodash/isNil'
import join from 'lodash/join'
import kebabCase from 'lodash/kebabCase'
import last from 'lodash/last'
import map from 'lodash/map'
import nth from 'lodash/nth'
import pullAt from 'lodash/pullAt'
import reject from 'lodash/reject'
import slice from 'lodash/slice'
import split from 'lodash/split'
import startCase from 'lodash/startCase'
import startsWith from 'lodash/startsWith'
import toString from 'lodash/toString'
import toUpper from 'lodash/toUpper'
import trim from 'lodash/trim'
// ====================================
// Build lodash object
// ====================================
module.exports = {
deburr,
concat,
cloneDeep,
debounce,
delay,
filter,
find,
findKey,
forEach,
includes,
isBoolean,
isEmpty,
isNil,
join,
kebabCase,
last,
map,
nth,
pullAt,
reject,
slice,
split,
startCase,
startsWith,
toString,
toUpper,
trim
}
export default {
readyStates: [],
callbacks: [],
/**
* Check if event has been sent
*
* @param {String} evt Event name
* @returns {Boolean} True if fired
*/
isReady (evt) {
return this.readyStates.indexOf(evt) >= 0
},
/**
* Register a callback to be executed when event is sent
*
* @param {String} evt Event name to register to
* @param {Function} clb Callback function
* @param {Boolean} once If the callback should be called only once
*/
register (evt, clb, once) {
if (this.isReady(evt)) {
clb()
} else {
this.callbacks.push({
event: evt,
callback: clb,
once: false,
called: false
})
}
},
/**
* Register a callback to be executed only once when event is sent
*
* @param {String} evt Event name to register to
* @param {Function} clb Callback function
*/
registerOnce (evt, clb) {
this.register(evt, clb, true)
},
/**
* Set ready state and execute callbacks
*/
notify (evt) {
this.readyStates.push(evt)
this.callbacks.forEach(clb => {
if (clb.event === evt) {
if (clb.once && clb.called) {
return
}
clb.called = true
clb.callback()
}
})
},
/**
* Execute callback on DOM ready
*
* @param {Function} clb Callback function
*/
onDOMReady (clb) {
if (document.readyState === 'interactive' || document.readyState === 'complete' || document.readyState === 'loaded') {
clb()
} else {
document.addEventListener('DOMContentLoaded', clb)
}
}
}
export default {
name: 'admin-edit-user',
props: ['usrdata'],
data() {
return {
id: '',
email: '',
password: '********',
name: '',
rights: [],
roleoverride: 'none'
}
},
methods: {
addRightsRow() {
this.rights.push({
role: 'write',
path: '/',
exact: false,
deny: false
})
},
removeRightsRow(idx) {
this._.pullAt(this.rights, idx)
this.$forceUpdate()
},
saveUser() {
let self = this
let formattedRights = this._.cloneDeep(this.rights)
switch (this.roleoverride) {
case 'admin':
formattedRights.push({
role: 'admin',
path: '/',
exact: false,
deny: false
})
break
}
this.$http.post(window.location.href, {
password: this.password,
name: this.name,
rights: JSON.stringify(formattedRights)
}).then(resp => {
self.$store.dispatch('alert', {
style: 'green',
icon: 'check',
msg: 'Changes have been applied successfully.'
})
}).catch(err => {
self.$store.dispatch('alert', {
style: 'red',
icon: 'square-cross',
msg: 'Error: ' + err.body.msg
})
})
}
},
mounted() {
let usr = JSON.parse(this.usrdata)
this.id = usr._id
this.email = usr.email
this.name = usr.name
if (this._.find(usr.rights, { role: 'admin' })) {
this.rights = this._.reject(usr.rights, ['role', 'admin'])
this.roleoverride = 'admin'
} else {
this.rights = usr.rights
}
}
}
export default {
name: 'admin-profile',
props: ['email', 'name', 'provider', 'tfaIsActive'],
data() {
return {
password: '********',
passwordVerify: '********'
}
},
computed: {
tfaStatus() {
return this.tfaIsActive ? this.$t('profile.tfaenabled') : this.$t('profile.tfadisabled')
}
},
methods: {
saveUser() {
let self = this
if (this.password !== this.passwordVerify) {
return self.$store.dispatch('alert', {
style: 'red',
icon: 'square-cross',
msg: 'The passwords don\'t match. Try again.'
})
}
this.$http.post(window.location.href, {
password: this.password,
name: this.name
}).then(resp => {
self.$store.dispatch('alert', {
style: 'green',
icon: 'check',
msg: 'Changes have been applied successfully.'
})
}).catch(err => {
self.$store.dispatch('alert', {
style: 'red',
icon: 'square-cross',
msg: 'Error: ' + err.body.msg
})
})
}
}
}
export default {
name: 'admin-settings',
data() {
return {}
},
methods: {
flushcache() {
window.alert('Coming soon!')
},
resetaccounts() {
window.alert('Coming soon!')
},
flushsessions() {
window.alert('Coming soon!')
}
}
}
export default {
name: 'admin-theme',
props: ['themedata'],
data() {
return {
primary: 'indigo',
alt: 'blue-grey',
footer: 'blue-grey',
codedark: 'true',
codecolorize: 'true'
}
},
watch: {
primary(val) {
this.$root.changeTheme(this.$data)
},
alt(val) {
this.$root.changeTheme(this.$data)
},
footer(val) {
this.$root.changeTheme(this.$data)
}
},
methods: {
saveTheme() {
let self = this
this.$http.post(window.location.href, self.$data).then(resp => {
self.$store.dispatch('alert', {
style: 'green',
icon: 'check',
msg: 'Theme settings have been applied successfully.'
})
}).catch(err => {
self.$store.dispatch('alert', {
style: 'red',
icon: 'square-cross',
msg: 'Error: ' + err.body.msg
})
})
},
resetTheme() {
this.primary = 'indigo'
this.alt = 'blue-grey'
this.footer = 'blue-grey'
this.codedark = 'true'
this.codecolorize = 'true'
}
},
mounted() {
let theme = JSON.parse(this.themedata)
this.primary = theme.primary
this.alt = theme.alt
this.footer = theme.footer
this.codedark = theme.code.dark.toString()
this.codecolorize = theme.code.colorize.toString()
}
}
/* global $ */
export default {
name: 'content-view',
data() {
return {}
},
mounted() {
let self = this
$('a.toc-anchor').each((i, elm) => {
let hashText = $(elm).attr('href').slice(1)
$(elm).on('click', (ev) => {
ev.stopImmediatePropagation()
self.$store.dispatch('anchor/open', hashText)
return false
})
})
}
}
export default {
name: 'source-view',
data() {
return {}
},
mounted() {
let self = this
FuseBox.import('/js/ace/ace.js', (ace) => {
let scEditor = ace.edit('source-display')
scEditor.setTheme('ace/theme/dawn')
scEditor.getSession().setMode('ace/mode/markdown')
scEditor.setOption('fontSize', '14px')
scEditor.setOption('hScrollBarAlwaysVisible', false)
scEditor.setOption('wrap', true)
scEditor.setOption('showPrintMargin', false)
scEditor.setReadOnly(true)
scEditor.renderer.updateFull()
scEditor.renderer.on('afterRender', () => {
self.$store.dispatch('pageLoader/complete')
})
})
}
}
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
import anchor from './modules/anchor'
import editor from './modules/editor'
import editorCodeblock from './modules/editor-codeblock'
import editorFile from './modules/editor-file'
import editorVideo from './modules/editor-video'
import modalCreatePage from './modules/modal-create-page'
import modalCreateUser from './modules/modal-create-user'
import modalDeleteUser from './modules/modal-delete-user'
import modalDeletePage from './modules/modal-delete-page'
import modalDiscardPage from './modules/modal-discard-page'
import modalMovePage from './modules/modal-move-page'
import modalProfile2fa from './modules/modal-profile-2fa'
import modalUpgradeSystem from './modules/modal-upgrade-system'
import navigator from './modules/navigator' import navigator from './modules/navigator'
import pageLoader from './modules/page-loader'
Vue.use(Vuex) Vue.use(Vuex)
...@@ -33,20 +19,6 @@ export default new Vuex.Store({ ...@@ -33,20 +19,6 @@ export default new Vuex.Store({
}, },
getters: {}, getters: {},
modules: { modules: {
anchor, navigator
editor,
editorCodeblock,
editorFile,
editorVideo,
modalCreatePage,
modalCreateUser,
modalDeletePage,
modalDeleteUser,
modalDiscardPage,
modalMovePage,
modalProfile2fa,
modalUpgradeSystem,
navigator,
pageLoader
} }
}) })
export default {
namespaced: true,
state: {
shown: false,
hash: ''
},
getters: {},
mutations: {
anchorChange: (state, opts) => {
state.shown = (opts.shown === true)
state.hash = opts.hash || ''
}
},
actions: {
open({ commit }, hash) {
commit('anchorChange', { shown: true, hash })
},
close({ commit }) {
commit('anchorChange', { shown: false })
}
}
}
/* global wikijs */
export default {
namespaced: true,
state: {
shown: false,
content: ''
},
getters: {},
mutations: {
shownChange: (state, shownState) => { state.shown = shownState },
contentChange: (state, newContent) => { state.content = newContent }
},
actions: {
open({ commit }, opts) {
commit('shownChange', true)
commit('contentChange', opts.initialContent || '')
wikijs.$emit('editorCodeblock/init')
},
close({ commit }) { commit('shownChange', false) }
}
}
/* global wikijs */
export default {
namespaced: true,
state: {
shown: false,
mode: 'image'
},
getters: {},
mutations: {
shownChange: (state, shownState) => { state.shown = shownState },
modeChange: (state, modeState) => { state.mode = modeState }
},
actions: {
open({ commit }, opts) {
commit('shownChange', true)
commit('modeChange', opts.mode)
wikijs.$emit('editorFile/init')
},
close({ commit }) { commit('shownChange', false) }
}
}
/* global wikijs */
export default {
namespaced: true,
state: {
shown: false
},
getters: {},
mutations: {
shownChange: (state, shownState) => { state.shown = shownState }
},
actions: {
open({ commit }) {
commit('shownChange', true)
wikijs.$emit('editorVideo/init')
},
close({ commit }) { commit('shownChange', false) }
}
}
/* global wikijs */
export default {
namespaced: true,
state: {
busy: false,
insertContent: ''
},
getters: {},
mutations: {
busyChange: (state, busyState) => { state.shown = busyState },
insertContentChange: (state, newContent) => { state.insertContent = newContent }
},
actions: {
busyStart({ commit }) { commit('busyChange', true) },
busyStop({ commit }) { commit('busyChange', false) },
insert({ commit }, content) {
commit('insertContentChange', content)
wikijs.$emit('editor/insert')
}
}
}
export default {
namespaced: true,
state: {
shown: false
},
getters: {},
mutations: {
shownChange: (state, shownState) => { state.shown = shownState }
},
actions: {
open({ commit }) { commit('shownChange', true) },
close({ commit }) { commit('shownChange', false) }
}
}
/* global wikijs */
export default {
namespaced: true,
state: {
shown: false
},
getters: {},
mutations: {
shownChange: (state, shownState) => { state.shown = shownState }
},
actions: {
open({ commit }) {
commit('shownChange', true)
wikijs.$emit('modalCreateUser/init')
},
close({ commit }) { commit('shownChange', false) }
}
}
export default {
namespaced: true,
state: {
shown: false
},
getters: {},
mutations: {
shownChange: (state, shownState) => { state.shown = shownState }
},
actions: {
open({ commit }) { commit('shownChange', true) },
close({ commit }) { commit('shownChange', false) }
}
}
export default {
namespaced: true,
state: {
shown: false
},
getters: {},
mutations: {
shownChange: (state, shownState) => { state.shown = shownState }
},
actions: {
open({ commit }) { commit('shownChange', true) },
close({ commit }) { commit('shownChange', false) }
}
}
export default {
namespaced: true,
state: {
shown: false
},
getters: {},
mutations: {
shownChange: (state, shownState) => { state.shown = shownState }
},
actions: {
open({ commit }) { commit('shownChange', true) },
close({ commit }) { commit('shownChange', false) }
}
}
export default {
namespaced: true,
state: {
shown: false
},
getters: {},
mutations: {
shownChange: (state, shownState) => { state.shown = shownState }
},
actions: {
open({ commit }) { commit('shownChange', true) },
close({ commit }) { commit('shownChange', false) }
}
}
export default {
namespaced: true,
state: {
shown: false,
step: 'confirm'
},
getters: {},
mutations: {
shownChange: (state, shownState) => { state.shown = shownState },
stepChange: (state, stepState) => { state.step = stepState }
},
actions: {
open({ commit }, opts) {
commit('shownChange', true)
commit('stepChange', 'confirm')
},
close({ commit }) { commit('shownChange', false) }
}
}
export default {
namespaced: true,
state: {
shown: false,
mode: 'upgrade',
step: 'confirm'
},
getters: {},
mutations: {
shownChange: (state, shownState) => { state.shown = shownState },
modeChange: (state, modeState) => { state.mode = modeState },
stepChange: (state, stepState) => { state.step = stepState }
},
actions: {
open({ commit }, opts) {
commit('shownChange', true)
commit('modeChange', opts.mode)
commit('stepChange', 'confirm')
},
close({ commit }) { commit('shownChange', false) }
}
}
export default {
namespaced: true,
state: {
shown: true,
msg: 'Loading...'
},
getters: {},
mutations: {
shownChange: (state, shownState) => { state.shown = shownState },
msgChange: (state, newText) => { state.msg = newText }
},
actions: {
complete({ commit }) { commit('shownChange', false) }
}
}
...@@ -7,6 +7,8 @@ module.exports = { ...@@ -7,6 +7,8 @@ module.exports = {
removeAll: true removeAll: true
} }
}] }]
} },
'postcss-flexbugs-fixes': {},
'postcss-flexibility': {}
} }
} }
...@@ -3,16 +3,20 @@ const fs = require('fs-extra') ...@@ -3,16 +3,20 @@ const fs = require('fs-extra')
const webpack = require('webpack') const webpack = require('webpack')
const CopyWebpackPlugin = require('copy-webpack-plugin') const CopyWebpackPlugin = require('copy-webpack-plugin')
const ProgressBarPlugin = require('progress-bar-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin') const ExtractTextPlugin = require('extract-text-webpack-plugin')
const NameAllModulesPlugin = require('name-all-modules-plugin') const NameAllModulesPlugin = require('name-all-modules-plugin')
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
const babelConfig = fs.readJsonSync(path.join(process.cwd(), '.babelrc')) const babelConfig = fs.readJsonSync(path.join(process.cwd(), '.babelrc'))
const postCSSConfig = { const postCSSConfig = {
config: { config: {
path: path.join(process.cwd(), 'dev/webpack/postcss.config.js') path: path.join(process.cwd(), 'dev/config/postcss.config.js')
} }
} }
const cacheDir = '.webpack-cache/cache'
const babelDir = path.join(process.cwd(), '.webpack-cache/babel')
process.noDeprecation = true
module.exports = { module.exports = {
entry: { entry: {
...@@ -32,14 +36,14 @@ module.exports = { ...@@ -32,14 +36,14 @@ module.exports = {
{ {
loader: 'cache-loader', loader: 'cache-loader',
options: { options: {
cacheDirectory: '.webpack-cache' cacheDirectory: cacheDir
} }
}, },
{ {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
...babelConfig, ...babelConfig,
cacheDirectory: true cacheDirectory: babelDir
} }
} }
] ]
...@@ -65,6 +69,12 @@ module.exports = { ...@@ -65,6 +69,12 @@ module.exports = {
fallback: 'style-loader', fallback: 'style-loader',
use: [ use: [
{ {
loader: 'cache-loader',
options: {
cacheDirectory: cacheDir
}
},
{
loader: 'css-loader' loader: 'css-loader'
}, },
{ {
...@@ -119,14 +129,14 @@ module.exports = { ...@@ -119,14 +129,14 @@ module.exports = {
{ {
loader: 'cache-loader', loader: 'cache-loader',
options: { options: {
cacheDirectory: '.webpack-cache' cacheDirectory: cacheDir
} }
}, },
{ {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
babelrc: path.join(process.cwd(), '.babelrc'), babelrc: path.join(process.cwd(), '.babelrc'),
cacheDirectory: true cacheDirectory: babelDir
} }
} }
] ]
...@@ -173,17 +183,13 @@ module.exports = { ...@@ -173,17 +183,13 @@ module.exports = {
] ]
}, },
plugins: [ plugins: [
new ProgressBarPlugin({
width: 72,
complete: '▇',
incomplete: '-'
}),
new webpack.BannerPlugin('Wiki.js - wiki.js.org - Licensed under AGPL'), new webpack.BannerPlugin('Wiki.js - wiki.js.org - Licensed under AGPL'),
new CopyWebpackPlugin([ new CopyWebpackPlugin([
{ from: 'client/static' } { from: 'client/static' }
], { ], {
}), }),
new LodashModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(), new webpack.NamedModulesPlugin(),
new webpack.NamedChunksPlugin((chunk) => { new webpack.NamedChunksPlugin((chunk) => {
if (chunk.name) { if (chunk.name) {
...@@ -207,7 +213,10 @@ module.exports = { ...@@ -207,7 +213,10 @@ module.exports = {
symlinks: true, symlinks: true,
alias: { alias: {
'@': path.join(process.cwd(), 'client'), '@': path.join(process.cwd(), 'client'),
'vue$': 'vue/dist/vue.common.js' 'vue$': 'vue/dist/vue.common.js',
// Duplicates fixes:
'apollo-link': path.join(process.cwd(), 'node_modules/apollo-link'),
'apollo-utilities': path.join(process.cwd(), 'node_modules/apollo-utilities')
}, },
extensions: [ extensions: [
'.js', '.js',
......
...@@ -3,6 +3,7 @@ const merge = require('webpack-merge') ...@@ -3,6 +3,7 @@ const merge = require('webpack-merge')
const ExtractTextPlugin = require('extract-text-webpack-plugin') const ExtractTextPlugin = require('extract-text-webpack-plugin')
const WriteFilePlugin = require('write-file-webpack-plugin') const WriteFilePlugin = require('write-file-webpack-plugin')
const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin')
const common = require('./webpack.common.js') const common = require('./webpack.common.js')
...@@ -15,6 +16,9 @@ module.exports = merge(common, { ...@@ -15,6 +16,9 @@ module.exports = merge(common, {
publicPath: '/' publicPath: '/'
}, },
plugins: [ plugins: [
new SimpleProgressWebpackPlugin({
format: 'compact'
}),
new webpack.DefinePlugin({ new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development') 'process.env.NODE_ENV': JSON.stringify('development')
}), }),
......
const webpack = require('webpack') const webpack = require('webpack')
const merge = require('webpack-merge') const merge = require('webpack-merge')
const path = require('path')
const CleanWebpackPlugin = require('clean-webpack-plugin') const CleanWebpackPlugin = require('clean-webpack-plugin')
const UglifyJSPlugin = require('uglifyjs-webpack-plugin') const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin') const ExtractTextPlugin = require('extract-text-webpack-plugin')
const OfflinePlugin = require('offline-plugin') const OfflinePlugin = require('offline-plugin')
const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin') const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin')
const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin')
const common = require('./webpack.common.js') const common = require('./webpack.common.js')
...@@ -14,6 +16,9 @@ module.exports = merge(common, { ...@@ -14,6 +16,9 @@ module.exports = merge(common, {
rules: [] rules: []
}, },
plugins: [ plugins: [
new SimpleProgressWebpackPlugin({
format: 'expanded'
}),
new CleanWebpackPlugin([ new CleanWebpackPlugin([
'assets/js/*.*', 'assets/js/*.*',
'assets/css/*.*', 'assets/css/*.*',
...@@ -23,22 +28,44 @@ module.exports = merge(common, { ...@@ -23,22 +28,44 @@ module.exports = merge(common, {
root: process.cwd(), root: process.cwd(),
verbose: false verbose: false
}), }),
new UglifyJSPlugin(), new UglifyJSPlugin({
cache: path.join(process.cwd(), '.webpack-cache/uglify'),
parallel: true
}),
new webpack.DefinePlugin({ new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production') 'process.env.NODE_ENV': JSON.stringify('production')
}), }),
new ExtractTextPlugin('css/bundle.css'), new ExtractTextPlugin('css/bundle.css'),
new OfflinePlugin({ new OfflinePlugin({
publicPath: '/',
externals: ['/'],
caches: { caches: {
main: [ main: [
'js/runtime.js', 'js/runtime.js',
'js/vendor.js', 'js/vendor.js',
'js/client.js' 'js/client.js'
], ],
additional: [':externals:'], additional: [
optional: ['*.chunk.js'] ':externals:'
} ],
optional: [
'js/*.chunk.js'
]
},
safeToUseOptionalCaches: true
}), }),
new DuplicatePackageCheckerPlugin() new DuplicatePackageCheckerPlugin(),
// Disable Extract Text Plugin stats:
{
apply(compiler) {
compiler.plugin('done', stats => {
if (Array.isArray(stats.compilation.children)) {
stats.compilation.children = stats.compilation.children.filter(child => {
return child.name.indexOf('extract-text-webpack-plugin') !== 0
})
}
})
}
}
] ]
}) })
...@@ -148,6 +148,8 @@ ...@@ -148,6 +148,8 @@
"babel-eslint": "8.2.1", "babel-eslint": "8.2.1",
"babel-jest": "22.1.0", "babel-jest": "22.1.0",
"babel-loader": "7.1.2", "babel-loader": "7.1.2",
"babel-plugin-graphql-tag": "1.3.1",
"babel-plugin-lodash": "3.3.2",
"babel-preset-env": "1.6.1", "babel-preset-env": "1.6.1",
"babel-preset-es2015": "6.24.1", "babel-preset-es2015": "6.24.1",
"babel-preset-stage-2": "6.24.1", "babel-preset-stage-2": "6.24.1",
...@@ -171,22 +173,25 @@ ...@@ -171,22 +173,25 @@
"extract-text-webpack-plugin": "3.0.2", "extract-text-webpack-plugin": "3.0.2",
"file-loader": "1.1.6", "file-loader": "1.1.6",
"graphql-tag": "^2.6.1", "graphql-tag": "^2.6.1",
"hammerjs": "2.0.8",
"i18next-xhr-backend": "1.5.1", "i18next-xhr-backend": "1.5.1",
"intl": "1.2.5",
"jest": "22.1.4", "jest": "22.1.4",
"jest-junit": "3.4.1", "jest-junit": "3.4.1",
"js-cookie": "2.2.0", "js-cookie": "2.2.0",
"lodash-webpack-plugin": "0.11.4",
"name-all-modules-plugin": "1.0.1", "name-all-modules-plugin": "1.0.1",
"node-dev": "3.1.3", "node-dev": "3.1.3",
"node-sass": "4.7.2", "node-sass": "4.7.2",
"offline-plugin": "4.9.0", "offline-plugin": "4.9.0",
"postcss-flexbugs-fixes": "3.3.0",
"postcss-flexibility": "2.0.0",
"postcss-loader": "2.0.10", "postcss-loader": "2.0.10",
"postcss-selector-parser": "3.1.1", "postcss-selector-parser": "3.1.1",
"progress-bar-webpack-plugin": "1.10.0",
"pug-lint": "2.5.0", "pug-lint": "2.5.0",
"raw-loader": "0.5.1", "raw-loader": "0.5.1",
"sass-loader": "6.0.6", "sass-loader": "6.0.6",
"sass-resources-loader": "1.3.1", "sass-resources-loader": "1.3.1",
"simple-progress-webpack-plugin": "1.0.4",
"style-loader": "0.20.1", "style-loader": "0.20.1",
"svg-sprite-loader": "3.6.2", "svg-sprite-loader": "3.6.2",
"twemoji-awesome": "1.0.6", "twemoji-awesome": "1.0.6",
......
...@@ -115,13 +115,8 @@ module.exports = async () => { ...@@ -115,13 +115,8 @@ module.exports = async () => {
// ---------------------------------------- // ----------------------------------------
if (global.DEV) { if (global.DEV) {
const webpackDevMiddleware = require('webpack-dev-middleware') app.use(global.WP_DEV.devMiddleware)
const webpackHotMiddleware = require('webpack-hot-middleware') app.use(global.WP_DEV.hotMiddleware)
app.use(webpackDevMiddleware(global.WP, {
publicPath: global.WPCONFIG.output.publicPath,
logger: wiki.logger
}))
app.use(webpackHotMiddleware(global.WP))
} }
// ---------------------------------------- // ----------------------------------------
......
...@@ -71,26 +71,35 @@ const init = { ...@@ -71,26 +71,35 @@ const init = {
const webpack = require('webpack') const webpack = require('webpack')
const chokidar = require('chokidar') const chokidar = require('chokidar')
global.WPCONFIG = require('./dev/webpack/webpack.dev.js')
global.DEV = true global.DEV = true
global.WP = webpack(global.WPCONFIG) global.WP_CONFIG = require('./dev/webpack/webpack.dev.js')
require('./server') global.WP = webpack(global.WP_CONFIG)
global.WP_DEV = {
devMiddleware: require('webpack-dev-middleware')(global.WP, {
publicPath: global.WP_CONFIG.output.publicPath
}),
hotMiddleware: require('webpack-hot-middleware')(global.WP)
}
global.WP_DEV.devMiddleware.waitUntilValid(() => {
console.info('>>> Starting Wiki.js in DEVELOPER mode...')
require('./server')
const devWatcher = chokidar.watch('./server') const devWatcher = chokidar.watch('./server')
devWatcher.on('ready', () => { devWatcher.on('ready', () => {
devWatcher.on('all', () => { devWatcher.on('all', () => {
console.warn('--- >>>>>>>>>>>>>>>>>>>>>>>>>>>> ---') console.warn('--- >>>>>>>>>>>>>>>>>>>>>>>>>>>> ---')
console.warn('--- Changes detected: Restarting ---') console.warn('--- Changes detected: Restarting ---')
console.warn('--- <<<<<<<<<<<<<<<<<<<<<<<<<<<< ---') console.warn('--- <<<<<<<<<<<<<<<<<<<<<<<<<<<< ---')
global.wiki.server.destroy(() => { global.wiki.server.destroy(() => {
global.wiki = {} global.wiki = {}
for (const workerId in cluster.workers) { for (const workerId in cluster.workers) {
cluster.workers[workerId].kill() cluster.workers[workerId].kill()
} }
Object.keys(require.cache).forEach(function(id) { Object.keys(require.cache).forEach(function(id) {
if (/[/\\]server[/\\]/.test(id)) delete require.cache[id] if (/[/\\]server[/\\]/.test(id)) delete require.cache[id]
})
require('./server')
}) })
require('./server')
}) })
}) })
}) })
......
This diff was suppressed by a .gitattributes entry.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment