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
90afe796
You need to sign in or sign up before continuing.
Commit
90afe796
authored
Sep 28, 2016
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added New Folder feature in Image Editor + Winston init refactor
parent
99315307
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
112 additions
and
71 deletions
+112
-71
agent.js
agent.js
+2
-10
app.js
assets/js/app.js
+0
-0
editor-image.js
client/js/components/editor-image.js
+28
-0
winston.js
lib/winston.js
+19
-0
config.js
models/config.js
+1
-0
git.js
models/git.js
+11
-11
localdata.js
models/localdata.js
+38
-26
server.js
server.js
+2
-12
editor-image.pug
views/modals/editor-image.pug
+3
-2
ws-server.js
ws-server.js
+8
-10
No files found.
agent.js
View file @
90afe796
...
...
@@ -5,22 +5,14 @@
// ===========================================
global
.
ROOTPATH
=
__dirname
;
global
.
PROCNAME
=
'AGENT'
;
// ----------------------------------------
// Load Winston
// ----------------------------------------
var
_isDebug
=
process
.
env
.
NODE_ENV
===
'development'
;
global
.
winston
=
require
(
'winston'
);
winston
.
remove
(
winston
.
transports
.
Console
)
winston
.
add
(
winston
.
transports
.
Console
,
{
level
:
(
_isDebug
)
?
'info'
:
'warn'
,
prettyPrint
:
true
,
colorize
:
true
,
silent
:
false
,
timestamp
:
true
});
global
.
winston
=
require
(
'./lib/winston'
)(
_isDebug
);
// ----------------------------------------
// Fetch internal handshake key
...
...
assets/js/app.js
View file @
90afe796
This diff is collapsed.
Click to expand it.
client/js/components/editor-image.js
View file @
90afe796
...
...
@@ -6,6 +6,7 @@ let vueImage = new Vue({
isLoadingText
:
''
,
newFolderName
:
''
,
newFolderShow
:
false
,
newFolderError
:
false
,
fetchFromUrlURL
:
''
,
fetchFromUrlShow
:
false
,
folders
:
[],
...
...
@@ -52,11 +53,38 @@ let vueImage = new Vue({
},
newFolder
:
(
ev
)
=>
{
vueImage
.
newFolderName
=
''
;
vueImage
.
newFolderError
=
false
;
vueImage
.
newFolderShow
=
true
;
_
.
delay
(()
=>
{
$
(
'#txt-editor-newfoldername'
).
focus
();
},
400
);
},
newFolderDiscard
:
(
ev
)
=>
{
vueImage
.
newFolderShow
=
false
;
},
newFolderCreate
:
(
ev
)
=>
{
let
regFolderName
=
new
RegExp
(
"^[a-z0-9][a-z0-9
\
-]*[a-z0-9]$"
);
vueImage
.
newFolderName
=
_
.
kebabCase
(
_
.
trim
(
vueImage
.
newFolderName
));
if
(
_
.
isEmpty
(
vueImage
.
newFolderName
)
||
!
regFolderName
.
test
(
vueImage
.
newFolderName
))
{
vueImage
.
newFolderError
=
true
;
return
;
}
vueImage
.
newFolderDiscard
();
vueImage
.
isLoading
=
true
;
vueImage
.
isLoadingText
=
'Creating new folder...'
;
Vue
.
nextTick
(()
=>
{
socket
.
emit
(
'uploadsCreateFolder'
,
{
foldername
:
vueImage
.
newFolderName
},
(
data
)
=>
{
vueImage
.
folders
=
data
;
vueImage
.
currentFolder
=
vueImage
.
newFolderName
;
vueImage
.
images
=
[];
vueImage
.
isLoading
=
false
;
});
});
},
fetchFromUrl
:
(
ev
)
=>
{
vueImage
.
fetchFromUrlShow
=
true
;
},
...
...
lib/winston.js
0 → 100644
View file @
90afe796
"use strict"
;
var
winston
=
require
(
'winston'
);
module
.
exports
=
(
isDebug
)
=>
{
winston
.
remove
(
winston
.
transports
.
Console
)
winston
.
add
(
winston
.
transports
.
Console
,
{
level
:
(
isDebug
)
?
'info'
:
'warn'
,
prettyPrint
:
true
,
colorize
:
true
,
silent
:
false
,
timestamp
:
true
});
return
winston
;
};
\ No newline at end of file
models/config.js
View file @
90afe796
...
...
@@ -25,6 +25,7 @@ module.exports = (confPath) => {
title
:
"Requarks Wiki"
,
host
:
"http://localhost"
,
port
:
process
.
env
.
PORT
,
wsPort
:
8080
,
db
:
"mongodb://localhost/wiki"
,
redis
:
null
,
sessionSecret
:
null
,
...
...
models/git.js
View file @
90afe796
...
...
@@ -72,13 +72,13 @@ module.exports = {
let
self
=
this
;
winston
.
info
(
'[GIT] Checking Git repository...'
);
winston
.
info
(
'[
'
+
PROCNAME
+
'][
GIT] Checking Git repository...'
);
//-> Check if path is accessible
return
fs
.
mkdirAsync
(
self
.
_repo
.
path
).
catch
((
err
)
=>
{
if
(
err
.
code
!==
'EEXIST'
)
{
winston
.
error
(
'Invalid Git repository path or missing permissions.'
);
winston
.
error
(
'
['
+
PROCNAME
+
'][GIT]
Invalid Git repository path or missing permissions.'
);
}
}).
then
(()
=>
{
...
...
@@ -116,10 +116,10 @@ module.exports = {
});
}).
catch
((
err
)
=>
{
winston
.
error
(
'Git remote error!'
);
winston
.
error
(
'
['
+
PROCNAME
+
'][GIT]
Git remote error!'
);
throw
err
;
}).
then
(()
=>
{
winston
.
info
(
'[GIT] Git repository is OK.'
);
winston
.
info
(
'[
'
+
PROCNAME
+
'][
GIT] Git repository is OK.'
);
return
true
;
});
...
...
@@ -147,12 +147,12 @@ module.exports = {
// Fetch
winston
.
info
(
'[GIT] Performing pull from remote repository...'
);
winston
.
info
(
'[
'
+
PROCNAME
+
'][
GIT] Performing pull from remote repository...'
);
return
self
.
_git
.
pull
(
'origin'
,
self
.
_repo
.
branch
).
then
((
cProc
)
=>
{
winston
.
info
(
'[GIT] Pull completed.'
);
winston
.
info
(
'[
'
+
PROCNAME
+
'][
GIT] Pull completed.'
);
})
.
catch
((
err
)
=>
{
winston
.
error
(
'Unable to fetch from git origin!'
);
winston
.
error
(
'
['
+
PROCNAME
+
'][GIT]
Unable to fetch from git origin!'
);
throw
err
;
})
.
then
(()
=>
{
...
...
@@ -164,14 +164,14 @@ module.exports = {
if
(
_
.
includes
(
out
,
'commit'
))
{
winston
.
info
(
'[GIT] Performing push to remote repository...'
);
winston
.
info
(
'[
'
+
PROCNAME
+
'][
GIT] Performing push to remote repository...'
);
return
self
.
_git
.
push
(
'origin'
,
self
.
_repo
.
branch
).
then
(()
=>
{
return
winston
.
info
(
'[GIT] Push completed.'
);
return
winston
.
info
(
'[
'
+
PROCNAME
+
'][
GIT] Push completed.'
);
});
}
else
{
winston
.
info
(
'[GIT] Push skipped. Repository is already in sync.'
);
winston
.
info
(
'[
'
+
PROCNAME
+
'][
GIT] Push skipped. Repository is already in sync.'
);
}
...
...
@@ -181,7 +181,7 @@ module.exports = {
})
.
catch
((
err
)
=>
{
winston
.
error
(
'Unable to push changes to remote!'
);
winston
.
error
(
'
['
+
PROCNAME
+
'][GIT]
Unable to push changes to remote!'
);
throw
err
;
});
...
...
models/localdata.js
View file @
90afe796
"use strict"
;
var
fs
=
require
(
'fs'
),
path
=
require
(
'path'
),
var
path
=
require
(
'path'
),
loki
=
require
(
'lokijs'
),
Promise
=
require
(
'bluebird'
),
fs
=
Promise
.
promisifyAll
(
require
(
'fs-extra'
)),
_
=
require
(
'lodash'
);
var
regFolderName
=
new
RegExp
(
"^[a-z0-9][a-z0-9
\
-]*[a-z0-9]$"
);
/**
* Local Data Storage
*
...
...
@@ -114,36 +116,20 @@ module.exports = {
*/
createBaseDirectories
(
appconfig
)
{
winston
.
info
(
'[SERVER] C
reate data directories if they don
\'
t exist
...'
);
winston
.
info
(
'[SERVER] C
hecking data directories
...'
);
try
{
fs
.
mkdirSync
(
appconfig
.
datadir
.
db
);
}
catch
(
err
)
{
if
(
err
.
code
!==
'EEXIST'
)
{
winston
.
error
(
err
);
process
.
exit
(
1
);
}
}
fs
.
ensureDirSync
(
path
.
resolve
(
ROOTPATH
,
appconfig
.
datadir
.
db
));
fs
.
ensureDirSync
(
path
.
resolve
(
ROOTPATH
,
appconfig
.
datadir
.
db
,
'./cache'
));
fs
.
ensureDirSync
(
path
.
resolve
(
ROOTPATH
,
appconfig
.
datadir
.
db
,
'./thumbs'
));
try
{
fs
.
mkdirSync
(
path
.
join
(
appconfig
.
datadir
.
db
,
'cache
'
));
fs
.
ensureDirSync
(
path
.
resolve
(
ROOTPATH
,
appconfig
.
datadir
.
repo
));
fs
.
ensureDirSync
(
path
.
resolve
(
ROOTPATH
,
appconfig
.
datadir
.
repo
,
'./uploads
'
));
}
catch
(
err
)
{
if
(
err
.
code
!==
'EEXIST'
)
{
winston
.
error
(
err
);
process
.
exit
(
1
);
}
winston
.
error
(
err
);
}
try
{
fs
.
mkdirSync
(
path
.
join
(
appconfig
.
datadir
.
db
,
'thumbs'
));
}
catch
(
err
)
{
if
(
err
.
code
!==
'EEXIST'
)
{
winston
.
error
(
err
);
process
.
exit
(
1
);
}
}
winston
.
info
(
'[SERVER] Data directories are OK.'
);
winston
.
info
(
'[SERVER] Data and Repository directories are OK.'
);
return
;
...
...
@@ -172,6 +158,32 @@ module.exports = {
},
/**
* Creates an uploads folder.
*
* @param {String} folderName The folder name
* @return {Promise} Promise of the operation
*/
createUploadsFolder
(
folderName
)
{
let
self
=
this
;
folderName
=
_
.
kebabCase
(
_
.
trim
(
folderName
));
if
(
_
.
isEmpty
(
folderName
)
||
!
regFolderName
.
test
(
folderName
))
{
return
Promise
.
resolve
(
self
.
getUploadsFolders
());
}
return
fs
.
ensureDirAsync
(
path
.
join
(
self
.
_uploadsPath
,
folderName
)).
then
(()
=>
{
if
(
!
_
.
includes
(
self
.
_uploadsFolders
,
folderName
))
{
self
.
_uploadsFolders
.
push
(
folderName
);
self
.
_uploadsFolders
=
_
.
sortBy
(
self
.
_uploadsFolders
);
}
return
self
.
getUploadsFolders
();
});
},
/**
* Sets the uploads files.
*
* @param {Array<Object>} arrFiles The uploads files
...
...
server.js
View file @
90afe796
...
...
@@ -5,23 +5,14 @@
// ===========================================
global
.
ROOTPATH
=
__dirname
;
global
.
PROCNAME
=
'SERVER'
;
// ----------------------------------------
// Load Winston
// ----------------------------------------
var
_isDebug
=
process
.
env
.
NODE_ENV
===
'development'
;
global
.
winston
=
require
(
'winston'
);
winston
.
remove
(
winston
.
transports
.
Console
)
winston
.
add
(
winston
.
transports
.
Console
,
{
level
:
(
_isDebug
)
?
'info'
:
'warn'
,
prettyPrint
:
true
,
colorize
:
true
,
silent
:
false
,
timestamp
:
true
});
global
.
winston
=
require
(
'./lib/winston'
)(
_isDebug
);
winston
.
info
(
'[SERVER] Requarks Wiki is initializing...'
);
// ----------------------------------------
...
...
@@ -66,7 +57,6 @@ var ctrl = autoload(path.join(ROOTPATH, '/controllers'));
// ----------------------------------------
global
.
app
=
express
();
var
_isDebug
=
(
app
.
get
(
'env'
)
===
'development'
);
// ----------------------------------------
// Security
...
...
views/modals/editor-image.pug
View file @
90afe796
...
...
@@ -60,6 +60,7 @@
img(v-bind:src="'/uploads/t/' + img.uid + '.png'")
span: strong {{ img.basename }}
span {{ img.filesize | filesize }}
em(v-show="images.length < 1") This folder is empty.
.modal(v-bind:class="{ 'is-active': newFolderShow }")
.modal-background
...
...
@@ -72,8 +73,8 @@
.content
label.label Enter the new folder name:
p.control
input.input
(type='text', placeholder='folder name', v-model='newFolderName'
)
span.help.is-danger
.is-hidden
This folder name is invalid!
input.input
#txt-editor-newfoldername(type='text', placeholder='folder name', v-model='newFolderName', v-on:keyup.enter="newFolderCreate", v-on:keyup.esc="newFolderDiscard"
)
span.help.is-danger
(v-show="newFolderError")
This folder name is invalid!
footer.card-footer
a.card-footer-item(v-on:click="newFolderDiscard") Discard
a.card-footer-item(v-on:click="newFolderCreate") Create
...
...
ws-server.js
View file @
90afe796
...
...
@@ -5,22 +5,14 @@
// ===========================================
global
.
ROOTPATH
=
__dirname
;
global
.
PROCNAME
=
'WS'
;
// ----------------------------------------
// Load Winston
// ----------------------------------------
var
_isDebug
=
process
.
env
.
NODE_ENV
===
'development'
;
global
.
winston
=
require
(
'winston'
);
winston
.
remove
(
winston
.
transports
.
Console
)
winston
.
add
(
winston
.
transports
.
Console
,
{
level
:
(
_isDebug
)
?
'info'
:
'warn'
,
prettyPrint
:
true
,
colorize
:
true
,
silent
:
false
,
timestamp
:
true
});
global
.
winston
=
require
(
'./lib/winston'
)(
_isDebug
);
// ----------------------------------------
// Fetch internal handshake key
...
...
@@ -141,6 +133,12 @@ io.on('connection', (socket) => {
cb
(
lcdata
.
getUploadsFolders
());
});
socket
.
on
(
'uploadsCreateFolder'
,
(
data
,
cb
)
=>
{
lcdata
.
createUploadsFolder
(
data
.
foldername
).
then
((
fldList
)
=>
{
cb
(
fldList
);
});
});
socket
.
on
(
'uploadsSetFiles'
,
(
data
,
cb
)
=>
{
if
(
internalAuth
.
validateKey
(
data
.
auth
))
{
lcdata
.
setUploadsFiles
(
data
.
content
);
...
...
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