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
405e23f0
Commit
405e23f0
authored
Sep 17, 2016
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added uploads handler
parent
1dcd1157
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
78 additions
and
3 deletions
+78
-3
app.js
assets/js/app.js
+0
-0
editor-image.js
client/js/components/editor-image.js
+25
-0
editor.js
client/js/components/editor.js
+5
-1
uploads.js
controllers/uploads.js
+34
-0
git.js
models/git.js
+11
-0
server.js
server.js
+2
-1
editor-image.pug
views/modals/editor-image.pug
+1
-1
No files found.
assets/js/app.js
View file @
405e23f0
This diff is collapsed.
Click to expand it.
client/js/components/editor-image.js
0 → 100644
View file @
405e23f0
let
vueImage
=
new
Vue
({
el
:
'#modal-editor-image'
,
data
:
{
modeSelected
:
'text'
},
methods
:
{
cancel
:
(
ev
)
=>
{
mdeModalOpenState
=
false
;
$
(
'#modal-editor-image'
).
slideUp
();
},
insertImage
:
(
ev
)
=>
{
if
(
mde
.
codemirror
.
doc
.
somethingSelected
())
{
mde
.
codemirror
.
execCommand
(
'singleSelection'
);
}
let
codeBlockText
=
'
\
n```'
+
vueCodeBlock
.
modeSelected
+
'
\
n'
+
codeEditor
.
getValue
()
+
'
\
n```
\
n'
;
mde
.
codemirror
.
doc
.
replaceSelection
(
codeBlockText
);
vueCodeBlock
.
cancel
();
}
}
});
\ No newline at end of file
client/js/components/editor.js
View file @
405e23f0
...
...
@@ -8,6 +8,7 @@ if($('#mk-editor').length === 1) {
let
mdeModalOpenState
=
false
;
let
mdeCurrentEditor
=
null
;
//=include editor-image.js
//=include editor-codeblock.js
var
mde
=
new
SimpleMDE
({
...
...
@@ -88,7 +89,10 @@ if($('#mk-editor').length === 1) {
{
name
:
"image"
,
action
:
(
editor
)
=>
{
$
(
'#modal-editor-image'
).
slideDown
();
if
(
!
mdeModalOpenState
)
{
mdeModalOpenState
=
true
;
$
(
'#modal-editor-image'
).
slideDown
();
}
},
className
:
"fa fa-image"
,
title
:
"Insert Image"
,
...
...
controllers/uploads.js
0 → 100644
View file @
405e23f0
"use strict"
;
var
express
=
require
(
'express'
);
var
router
=
express
.
Router
();
var
_
=
require
(
'lodash'
);
var
validPathRe
=
new
RegExp
(
"^([a-z0-9
\\
/-]+
\\
.[a-z0-9]+)$"
);
// ==========================================
// SERVE UPLOADS FILES
// ==========================================
router
.
get
(
'/*'
,
(
req
,
res
,
next
)
=>
{
let
fileName
=
req
.
params
[
0
];
if
(
!
validPathRe
.
test
(
fileName
))
{
return
res
.
sendStatus
(
404
).
end
();
}
//todo: Authentication-based access
res
.
sendFile
(
fileName
,
{
root
:
git
.
getRepoPath
()
+
'/uploads/'
,
dotfiles
:
'deny'
},
(
err
)
=>
{
if
(
err
)
{
res
.
status
(
err
.
status
).
end
();
}
});
});
module
.
exports
=
router
;
\ No newline at end of file
models/git.js
View file @
405e23f0
...
...
@@ -126,6 +126,17 @@ module.exports = {
},
/**
* Gets the repo path.
*
* @return {String} The repo path.
*/
getRepoPath
()
{
return
this
.
_repo
.
path
||
path
.
join
(
ROOTPATH
,
'repo'
);
},
/**
* Sync with the remote repository
*
* @return {Promise} Resolve on sync success
...
...
server.js
View file @
405e23f0
...
...
@@ -145,8 +145,9 @@ app.use(mw.flash);
app
.
use
(
'/'
,
ctrl
.
auth
);
app
.
use
(
'/
'
,
ctrl
.
page
s
);
app
.
use
(
'/
uploads'
,
ctrl
.
upload
s
);
app
.
use
(
'/admin'
,
mw
.
auth
,
ctrl
.
admin
);
app
.
use
(
'/'
,
ctrl
.
pages
);
// ----------------------------------------
// Error handling
...
...
views/modals/editor-image.pug
View file @
405e23f0
...
...
@@ -23,7 +23,7 @@
p.control
a.button.is-warning.is-outlined(v-on:click="cancel") Cancel
p.control
a.button.is-primary.is-outlined(v-on:click="insert
Cod
e") Insert Image
a.button.is-primary.is-outlined(v-on:click="insert
Imag
e") Insert Image
.columns
.column.is-one-quarter(style={'max-width':'350px'})
...
...
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