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
965f0ad2
Commit
965f0ad2
authored
May 18, 2019
by
Nick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: serve asset from db + editor mobile improvements
parent
d27ffe7c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
168 additions
and
88 deletions
+168
-88
editor-markdown.vue
client/components/editor/editor-markdown.vue
+44
-28
editor-modal-media.vue
client/components/editor/editor-modal-media.vue
+88
-46
editor-modal-properties.vue
client/components/editor/editor-modal-properties.vue
+1
-0
help.vue
client/components/editor/markdown/help.vue
+3
-3
v-dialog.scss
client/scss/components/v-dialog.scss
+6
-0
asset.js
server/graph/resolvers/asset.js
+7
-4
asset.graphql
server/graph/schemas/asset.graphql
+1
-0
assets.js
server/models/assets.js
+18
-7
No files found.
client/components/editor/editor-markdown.vue
View file @
965f0ad2
<
template
lang=
'pug'
>
.editor-markdown
v-toolbar.editor-markdown-toolbar(dense, color='primary', dark, flat)
v-toolbar.editor-markdown-toolbar(dense, color='primary', dark, flat
, style='overflow-x: hidden;'
)
v-btn.animated.fadeInLeft(v-if='isModalShown', flat, @click='closeAllModal')
v-icon(left) c
hevron_left
span Back
v-icon(left) c
lose
span Back
to Editor
template(v-else)
v-tooltip(bottom, color='primary')
v-btn.animated.fadeIn(icon, slot='activator', @click='toggleMarkup({ start: `**` })').mx-0
...
...
@@ -92,45 +92,42 @@
span Insert Link
v-tooltip(right, color='teal')
v-btn.animated.fadeInLeft.wait-p1s(icon, slot='activator', dark, @click='toggleModal(`editorModalMedia`)').mx-0
v-icon(:color='activeModal === `editorModalMedia` ? `teal` : ``')
imag
e
span Insert
Image
v-icon(:color='activeModal === `editorModalMedia` ? `teal` : ``')
burst_mod
e
span Insert
Assets
v-tooltip(right, color='teal')
v-btn.animated.fadeInLeft.wait-p2s(icon, slot='activator', dark, @click='toggleModal(`editorModalBlocks`)').mx-0
v-icon(:color='activeModal === `editorModalBlocks` ? `teal` : ``') dashboard
span Insert Block
v-tooltip(right, color='teal')
v-btn.animated.fadeInLeft.wait-p3s(icon, slot='activator', dark, disabled).mx-0
v-icon insert_drive_file
span Insert File
v-tooltip(right, color='teal')
v-btn.animated.fadeInLeft.wait-p4s(icon, slot='activator', dark, disabled).mx-0
v-icon code
span Insert Code Block
v-tooltip(right, color='teal')
v-btn.animated.fadeInLeft.wait-p
5
s(icon, slot='activator', dark, disabled).mx-0
v-btn.animated.fadeInLeft.wait-p
4
s(icon, slot='activator', dark, disabled).mx-0
v-icon play_circle_outline
span Insert Video / Audio
v-tooltip(right, color='teal')
v-btn.animated.fadeInLeft.wait-p
6
s(icon, slot='activator', dark, disabled).mx-0
v-btn.animated.fadeInLeft.wait-p
5
s(icon, slot='activator', dark, disabled).mx-0
v-icon multiline_chart
span Insert Diagram
v-tooltip(right, color='teal')
v-btn.animated.fadeInLeft.wait-p
7
s(icon, slot='activator', dark, disabled).mx-0
v-btn.animated.fadeInLeft.wait-p
6
s(icon, slot='activator', dark, disabled).mx-0
v-icon functions
span Insert Math Expression
v-tooltip(right, color='teal')
v-btn.animated.fadeInLeft.wait-p
8
s(icon, slot='activator', dark, disabled).mx-0
v-btn.animated.fadeInLeft.wait-p
7
s(icon, slot='activator', dark, disabled).mx-0
v-icon border_outer
span Table Helper
v-spacer
v-tooltip(right, color='teal')
v-btn.animated.fadeInLeft.wait-p9s(icon, slot='activator', dark, @click='toggleFullscreen').mx-0
v-icon crop_free
span Distraction Free Mode
v-tooltip(right, color='teal')
v-btn.animated.fadeInLeft.wait-p10s(icon, slot='activator', dark, @click='toggleHelp').mx-0
v-icon(:color='helpShown ? `teal` : ``') help
span Markdown Formatting Help
template(v-if='$vuetify.breakpoint.mdAndUp')
v-spacer
v-tooltip(right, color='teal')
v-btn.animated.fadeInLeft.wait-p8s(icon, slot='activator', dark, @click='toggleFullscreen').mx-0
v-icon crop_free
span Distraction Free Mode
v-tooltip(right, color='teal')
v-btn.animated.fadeInLeft.wait-p9s(icon, slot='activator', dark, @click='toggleHelp').mx-0
v-icon(:color='helpShown ? `teal` : ``') help
span Markdown Formatting Help
.editor-markdown-editor
.editor-markdown-editor-title(v-if='previewShown', @click='previewShown = false') Editor
.editor-markdown-editor-title(v-else='previewShown', @click='previewShown = true'): v-icon(dark) drag_indicator
...
...
@@ -143,10 +140,11 @@
v-system-bar.editor-markdown-sysbar(dark, status, color='grey darken-3')
.caption.editor-markdown-sysbar-locale
{{
locale
.
toUpperCase
()
}}
.caption.px-3 /
{{
path
}}
v-spacer
.caption Markdown
v-spacer
.caption Ln
{{
cursorPos
.
line
+
1
}}
, Col
{{
cursorPos
.
ch
+
1
}}
template(v-if='$vuetify.breakpoint.mdAndUp')
v-spacer
.caption Markdown
v-spacer
.caption Ln
{{
cursorPos
.
line
+
1
}}
, Col
{{
cursorPos
.
ch
+
1
}}
markdown-help(v-if='helpShown')
</
template
>
...
...
@@ -329,7 +327,11 @@ export default {
return
false
})
cm
.
setSize
(
null
,
'calc(100vh - 112px - 24px)'
)
if
(
this
.
$vuetify
.
breakpoint
.
mdAndUp
)
{
cm
.
setSize
(
null
,
'calc(100vh - 112px - 24px)'
)
}
else
{
cm
.
setSize
(
null
,
'calc(100vh - 112px - 16px)'
)
}
cm
.
setOption
(
'extraKeys'
,
keyBindings
)
cm
.
on
(
'cursorActivity'
,
cm
=>
{
this
.
positionSync
(
cm
)
...
...
@@ -462,6 +464,7 @@ export default {
<
style
lang=
'scss'
>
$editor-height
:
calc
(
100vh
-
112px
-
24px
);
$editor-height-mobile
:
calc
(
100vh
-
112px
-
16px
);
.editor-markdown
{
&
-main
{
...
...
@@ -476,6 +479,10 @@ $editor-height: calc(100vh - 112px - 24px);
height
:
$editor-height
;
position
:
relative
;
@include
until
(
$tablet
)
{
height
:
$editor-height-mobile
;
}
&
-title
{
background-color
:
mc
(
'grey'
,
'800'
);
border-bottom-left-radius
:
5px
;
...
...
@@ -531,13 +538,17 @@ $editor-height: calc(100vh - 112px - 24px);
height
:
$editor-height
;
overflow-y
:
scroll
;
padding
:
1rem
1rem
1rem
0
;
width
:
calc
(
100%
+
1rem
+
17px
)
width
:
calc
(
100%
+
1rem
+
17px
)
;
// -ms-overflow-style: none;
// &::-webkit-scrollbar {
// width: 0px;
// background: transparent;
// }
@include
until
(
$tablet
)
{
height
:
$editor-height-mobile
;
}
}
&
-title
{
...
...
@@ -588,6 +599,11 @@ $editor-height: calc(100vh - 112px - 24px);
justify-content
:
flex-start
;
align-items
:
center
;
padding
:
24px
0
;
@include
until
(
$tablet
)
{
padding
:
12px
0
;
width
:
40px
;
}
}
&
-sysbar
{
...
...
client/components/editor/editor-modal-media.vue
View file @
965f0ad2
This diff is collapsed.
Click to expand it.
client/components/editor/editor-modal-properties.vue
View file @
965f0ad2
...
...
@@ -4,6 +4,7 @@
persistent
lazy
width='1100'
:fullscreen='$vuetify.breakpoint.smAndDown'
)
.dialog-header
v-icon(color='white') sort_by_alpha
...
...
client/components/editor/markdown/help.vue
View file @
965f0ad2
...
...
@@ -2,7 +2,7 @@
v-card.editor-markdown-help.animated.fadeInLeft(flat, tile)
v-container.pa-3(grid-list-lg, fluid)
v-layout(row, wrap)
v-flex(xs4)
v-flex(xs
12, lg6, xl
4)
v-card.radius-7.animated.fadeInUp(light)
v-card-text
.d-flex
...
...
@@ -98,7 +98,7 @@
li Unordered List Item 2
li Unordered List Item 3
v-flex(xs4)
v-flex(xs
12, lg6, xl
4)
v-card.radius-7.animated.fadeInUp.wait-p1s(light)
v-card-text
.d-flex
...
...
@@ -196,7 +196,7 @@
v-card-text
blockquote(style='border: 1px solid #263238; border-radius: .5rem; padding: 1rem 24px;') Lorem ipsum#[br]dolor sit amet#[br]consectetur adipiscing elit
v-flex(xs4)
v-flex(xs
12, xl
4)
v-card.radius-7.animated.fadeInUp.wait-p2s(light)
v-card-text
v-toolbar.radius-7(color='teal lighten-5', dense, flat)
...
...
client/scss/components/v-dialog.scss
View file @
965f0ad2
...
...
@@ -27,3 +27,9 @@
radial-gradient
(
ellipse
at
bottom
,
mc
(
'grey'
,
'800'
)
,
mc
(
'grey'
,
'900'
));
}
}
.v-dialog--fullscreen
{
@include
until
(
$tablet
)
{
padding-top
:
56px
;
}
}
server/graph/resolvers/asset.js
View file @
965f0ad2
...
...
@@ -12,10 +12,13 @@ module.exports = {
},
AssetQuery
:
{
async
list
(
obj
,
args
,
context
)
{
const
result
=
await
WIKI
.
models
.
assets
.
query
().
where
({
folderId
:
null
,
kind
:
args
.
kind
.
toLowerCase
()
})
let
cond
=
{
folderId
:
null
}
if
(
args
.
kind
!==
'ALL'
)
{
cond
.
kind
=
args
.
kind
.
toLowerCase
()
}
const
result
=
await
WIKI
.
models
.
assets
.
query
().
where
(
cond
)
return
result
.
map
(
a
=>
({
...
a
,
kind
:
a
.
kind
.
toUpperCase
()
...
...
server/graph/schemas/asset.graphql
View file @
965f0ad2
...
...
@@ -56,4 +56,5 @@ type AssetFolder {
enum
AssetKind
{
IMAGE
BINARY
ALL
}
server/models/assets.js
View file @
965f0ad2
...
...
@@ -96,13 +96,9 @@ module.exports = class Asset extends Model {
}
static
async
getAsset
(
assetPath
,
res
)
{
let
asset
=
await
WIKI
.
models
.
assets
.
getAssetFromCache
(
assetPath
,
res
)
if
(
!
asset
)
{
// asset = await WIKI.models.assets.getAssetFromDb(assetPath, res)
// if (asset) {
// await WIKI.models.assets.saveAssetToCache(asset)
// }
res
.
sendStatus
(
404
)
let
assetExists
=
await
WIKI
.
models
.
assets
.
getAssetFromCache
(
assetPath
,
res
)
if
(
!
assetExists
)
{
await
WIKI
.
models
.
assets
.
getAssetFromDb
(
assetPath
,
res
)
}
}
...
...
@@ -121,4 +117,19 @@ module.exports = class Asset extends Model {
})
})
}
static
async
getAssetFromDb
(
assetPath
,
res
)
{
const
fileHash
=
assetHelper
.
generateHash
(
assetPath
)
const
cachePath
=
path
.
join
(
process
.
cwd
(),
`data/cache/
${
fileHash
}
.dat`
)
const
asset
=
await
WIKI
.
models
.
assets
.
query
().
where
(
'hash'
,
fileHash
).
first
()
if
(
asset
)
{
const
assetData
=
await
WIKI
.
models
.
knex
(
'assetData'
).
where
(
'id'
,
asset
.
id
).
first
()
res
.
type
(
asset
.
ext
)
res
.
send
(
assetData
.
data
)
await
fs
.
outputFile
(
cachePath
,
assetData
.
data
)
}
else
{
res
.
sendStatus
(
404
)
}
}
}
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