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
ebe288a5
Commit
ebe288a5
authored
May 27, 2017
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: lazy-load simplemde + minimal lodash
parent
8eaa69ce
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
162 additions
and
9 deletions
+162
-9
.gitignore
.gitignore
+3
-0
settings.json
.vscode/settings.json
+2
-1
app.js
client/js/app.js
+58
-1
editor-codeblock.vue
client/js/components/editor-codeblock.vue
+51
-0
editor.component.js
client/js/components/editor.component.js
+0
-0
pages.js
client/js/helpers/pages.js
+12
-5
index.js
client/js/store/index.js
+2
-0
alert.js
client/js/store/modules/alert.js
+2
-2
editor-codeblock.js
client/js/store/modules/editor-codeblock.js
+16
-0
fuse.js
fuse.js
+16
-0
No files found.
.gitignore
View file @
ebe288a5
...
@@ -31,3 +31,6 @@ config.yml
...
@@ -31,3 +31,6 @@ config.yml
/repo
/repo
/data
/data
/uploads
/uploads
# IDE exclude
.idea
.vscode/settings.json
View file @
ebe288a5
...
@@ -2,5 +2,6 @@
...
@@ -2,5 +2,6 @@
"eslint.enable"
:
true
,
"eslint.enable"
:
true
,
"puglint.enable"
:
true
,
"puglint.enable"
:
true
,
"standard.enable"
:
false
,
"standard.enable"
:
false
,
"editor.formatOnSave"
:
true
"editor.formatOnSave"
:
true
,
"editor.tabSize"
:
2
}
}
client/js/app.js
View file @
ebe288a5
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
/* eslint-disable no-new */
/* eslint-disable no-new */
import
$
from
'jquery'
import
$
from
'jquery'
import
_
from
'lodash'
import
Vue
from
'vue'
import
Vue
from
'vue'
import
VueResource
from
'vue-resource'
import
VueResource
from
'vue-resource'
import
VueClipboards
from
'vue-clipboards'
import
VueClipboards
from
'vue-clipboards'
...
@@ -18,6 +17,33 @@ import 'jquery-smooth-scroll'
...
@@ -18,6 +17,33 @@ import 'jquery-smooth-scroll'
import
'jquery-sticky'
import
'jquery-sticky'
// ====================================
// ====================================
// Load minimal lodash
// ====================================
import
concat
from
'lodash/concat'
import
cloneDeep
from
'lodash/cloneDeep'
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
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
pullAt
from
'lodash/pullAt'
import
reject
from
'lodash/reject'
import
slice
from
'lodash/slice'
import
split
from
'lodash/split'
import
trim
from
'lodash/trim'
import
toUpper
from
'lodash/toUpper'
// ====================================
// Load Helpers
// Load Helpers
// ====================================
// ====================================
...
@@ -30,6 +56,7 @@ import helpers from './helpers'
...
@@ -30,6 +56,7 @@ import helpers from './helpers'
import
alertComponent
from
'./components/alert.vue'
import
alertComponent
from
'./components/alert.vue'
import
anchorComponent
from
'./components/anchor.vue'
import
anchorComponent
from
'./components/anchor.vue'
import
colorPickerComponent
from
'./components/color-picker.vue'
import
colorPickerComponent
from
'./components/color-picker.vue'
import
editorCodeblockComponent
from
'./components/editor-codeblock.vue'
import
loadingSpinnerComponent
from
'./components/loading-spinner.vue'
import
loadingSpinnerComponent
from
'./components/loading-spinner.vue'
import
modalCreatePageComponent
from
'./components/modal-create-page.vue'
import
modalCreatePageComponent
from
'./components/modal-create-page.vue'
import
modalCreateUserComponent
from
'./components/modal-create-user.vue'
import
modalCreateUserComponent
from
'./components/modal-create-user.vue'
...
@@ -46,6 +73,35 @@ import editorComponent from './components/editor.component.js'
...
@@ -46,6 +73,35 @@ import editorComponent from './components/editor.component.js'
import
sourceViewComponent
from
'./pages/source-view.component.js'
import
sourceViewComponent
from
'./pages/source-view.component.js'
// ====================================
// ====================================
// Build lodash object
// ====================================
const
_
=
{
deburr
,
concat
,
cloneDeep
,
debounce
,
delay
,
filter
,
find
,
findKey
,
forEach
,
includes
,
isEmpty
,
isNil
,
join
,
kebabCase
,
last
,
map
,
pullAt
,
reject
,
slice
,
split
,
toUpper
,
trim
}
// ====================================
// Initialize Vue Modules
// Initialize Vue Modules
// ====================================
// ====================================
...
@@ -101,6 +157,7 @@ $(() => {
...
@@ -101,6 +157,7 @@ $(() => {
colorPicker
:
colorPickerComponent
,
colorPicker
:
colorPickerComponent
,
contentView
:
contentViewComponent
,
contentView
:
contentViewComponent
,
editor
:
editorComponent
,
editor
:
editorComponent
,
editorCodeblock
:
editorCodeblockComponent
,
loadingSpinner
:
loadingSpinnerComponent
,
loadingSpinner
:
loadingSpinnerComponent
,
modalCreatePage
:
modalCreatePageComponent
,
modalCreatePage
:
modalCreatePageComponent
,
modalCreateUser
:
modalCreateUserComponent
,
modalCreateUser
:
modalCreateUserComponent
,
...
...
client/js/components/editor-codeblock.vue
0 → 100644
View file @
ebe288a5
<
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 Insert Code Block
section.is-gapless
.columns.is-stretched
.column.is-one-quarter.modal-sidebar.is-green(style={'max-width':'350px'})
.model-sidebar-header Language
.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') Discard
a.button.is-green(v-on:click='insertCode') Insert Code Block
</
template
>
<
script
>
export
default
{
name
:
'editor-codeblock'
,
data
()
{
return
{}
},
computed
:
{
isShown
()
{
return
this
.
$store
.
state
.
editorCodeblock
.
shown
}
},
methods
:
{
cancel
()
{
this
.
$store
.
dispatch
(
'editorCodeBlock/close'
)
},
insertCode
()
{
this
.
$store
.
dispatch
(
'alert'
,
{
style
:
'pink'
,
icon
:
'inbox'
,
msg
:
'Your code block has been inserted.'
})
this
.
cancel
()
}
}
}
</
script
>
client/js/components/editor.component.js
View file @
ebe288a5
This diff is collapsed.
Click to expand it.
client/js/helpers/pages.js
View file @
ebe288a5
'use strict'
'use strict'
import
_
from
'lodash'
import
deburr
from
'lodash/deburr'
import
filter
from
'lodash/filter'
import
isEmpty
from
'lodash/isEmpty'
import
join
from
'lodash/join'
import
kebabCase
from
'lodash/kebabCase'
import
map
from
'lodash/map'
import
split
from
'lodash/split'
import
trim
from
'lodash/trim'
module
.
exports
=
{
module
.
exports
=
{
/**
/**
...
@@ -9,11 +16,11 @@ module.exports = {
...
@@ -9,11 +16,11 @@ module.exports = {
* @returns {string} Safe path
* @returns {string} Safe path
*/
*/
makeSafePath
:
(
rawPath
)
=>
{
makeSafePath
:
(
rawPath
)
=>
{
let
rawParts
=
_
.
split
(
_
.
trim
(
rawPath
),
'/'
)
let
rawParts
=
split
(
trim
(
rawPath
),
'/'
)
rawParts
=
_
.
map
(
rawParts
,
(
r
)
=>
{
rawParts
=
map
(
rawParts
,
(
r
)
=>
{
return
_
.
kebabCase
(
_
.
deburr
(
_
.
trim
(
r
)))
return
kebabCase
(
deburr
(
trim
(
r
)))
})
})
return
_
.
join
(
_
.
filter
(
rawParts
,
(
r
)
=>
{
return
!
_
.
isEmpty
(
r
)
}),
'/'
)
return
join
(
filter
(
rawParts
,
(
r
)
=>
{
return
!
isEmpty
(
r
)
}),
'/'
)
}
}
}
}
client/js/store/index.js
View file @
ebe288a5
...
@@ -4,6 +4,7 @@ import Vuex from 'vuex'
...
@@ -4,6 +4,7 @@ import Vuex from 'vuex'
import
alert
from
'./modules/alert'
import
alert
from
'./modules/alert'
import
anchor
from
'./modules/anchor'
import
anchor
from
'./modules/anchor'
import
editor
from
'./modules/editor'
import
editor
from
'./modules/editor'
import
editorCodeblock
from
'./modules/editor-codeblock'
import
modalCreatePage
from
'./modules/modal-create-page'
import
modalCreatePage
from
'./modules/modal-create-page'
import
modalCreateUser
from
'./modules/modal-create-user'
import
modalCreateUser
from
'./modules/modal-create-user'
import
modalDiscardPage
from
'./modules/modal-discard-page'
import
modalDiscardPage
from
'./modules/modal-discard-page'
...
@@ -28,6 +29,7 @@ export default new Vuex.Store({
...
@@ -28,6 +29,7 @@ export default new Vuex.Store({
alert
,
alert
,
anchor
,
anchor
,
editor
,
editor
,
editorCodeblock
,
modalCreatePage
,
modalCreatePage
,
modalCreateUser
,
modalCreateUser
,
modalDiscardPage
,
modalDiscardPage
,
...
...
client/js/store/modules/alert.js
View file @
ebe288a5
'use strict'
'use strict'
import
_
from
'lodash
'
import
debounce
from
'lodash/debounce
'
export
default
{
export
default
{
state
:
{
state
:
{
...
@@ -24,7 +24,7 @@ export default {
...
@@ -24,7 +24,7 @@ export default {
commit
(
'alertChange'
,
opts
)
commit
(
'alertChange'
,
opts
)
dispatch
(
'alertDismiss'
)
dispatch
(
'alertDismiss'
)
},
},
alertDismiss
:
_
.
debounce
(({
commit
})
=>
{
alertDismiss
:
debounce
(({
commit
})
=>
{
let
opts
=
{
shown
:
false
}
let
opts
=
{
shown
:
false
}
commit
(
'alertChange'
,
opts
)
commit
(
'alertChange'
,
opts
)
},
3000
)
},
3000
)
...
...
client/js/store/modules/editor-codeblock.js
0 → 100644
View file @
ebe288a5
'use strict'
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
)
}
}
}
fuse.js
View file @
ebe288a5
...
@@ -80,6 +80,22 @@ console.info(colors.white('└── ') + colors.green('Running global tasks...'
...
@@ -80,6 +80,22 @@ console.info(colors.white('└── ') + colors.green('Running global tasks...'
let
globalTasks
=
Promise
.
mapSeries
([
let
globalTasks
=
Promise
.
mapSeries
([
/**
/**
* SimpleMDE
*/
()
=>
{
return
fs
.
accessAsync
(
'./assets/js/simplemde'
).
then
(()
=>
{
console
.
info
(
colors
.
white
(
' └── '
)
+
colors
.
magenta
(
'SimpleMDE directory already exists. Task aborted.'
))
return
true
}).
catch
(
err
=>
{
if
(
err
.
code
===
'ENOENT'
)
{
console
.
info
(
colors
.
white
(
' └── '
)
+
colors
.
green
(
'Copy + Minify SimpleMDE to assets...'
))
return
fs
.
copy
(
'./node_modules/simplemde/dist/simplemde.min.js'
,
'./assets/js/simplemde/simplemde.min.js'
)
}
else
{
throw
err
}
})
},
/**
* ACE Modes
* ACE Modes
*/
*/
()
=>
{
()
=>
{
...
...
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