mirror of https://github.com/requarks/wiki
parent
a508b2a7f4
commit
414dc386d6
@ -0,0 +1,24 @@
|
||||
# Change Log
|
||||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
- Change log
|
||||
|
||||
### Fixed
|
||||
- Fixed issue with social accounts with empty name
|
||||
|
||||
### Changed
|
||||
- Updated dependencies + snyk policy
|
||||
- Conversion to Standard JS compliant code
|
||||
|
||||
## [v1.0-beta.2] - 2017-01-30
|
||||
### Added
|
||||
- Save own profile under My Account
|
||||
|
||||
### Changed
|
||||
- Updated dependencies + snyk policy
|
||||
|
||||
[Unreleased]: https://github.com/Requarks/wiki/compare/v1.0-beta.2...HEAD
|
||||
[v1.0-beta.2]: https://github.com/Requarks/wiki/releases/tag/v1.0-beta.2
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,16 +1,16 @@
|
||||
|
||||
function setInputSelection(input, startPos, endPos) {
|
||||
input.focus();
|
||||
if (typeof input.selectionStart != "undefined") {
|
||||
input.selectionStart = startPos;
|
||||
input.selectionEnd = endPos;
|
||||
function setInputSelection (input, startPos, endPos) {
|
||||
input.focus()
|
||||
if (typeof input.selectionStart !== 'undefined') {
|
||||
input.selectionStart = startPos
|
||||
input.selectionEnd = endPos
|
||||
} else if (document.selection && document.selection.createRange) {
|
||||
// IE branch
|
||||
input.select();
|
||||
var range = document.selection.createRange();
|
||||
range.collapse(true);
|
||||
range.moveEnd("character", endPos);
|
||||
range.moveStart("character", startPos);
|
||||
range.select();
|
||||
input.select()
|
||||
var range = document.selection.createRange()
|
||||
range.collapse(true)
|
||||
range.moveEnd('character', endPos)
|
||||
range.moveStart('character', startPos)
|
||||
range.select()
|
||||
}
|
||||
}
|
@ -1,11 +1,9 @@
|
||||
|
||||
function makeSafePath(rawPath) {
|
||||
|
||||
let rawParts = _.split(_.trim(rawPath), '/');
|
||||
function makeSafePath (rawPath) {
|
||||
let rawParts = _.split(_.trim(rawPath), '/')
|
||||
rawParts = _.map(rawParts, (r) => {
|
||||
return _.kebabCase(_.deburr(_.trim(r)));
|
||||
});
|
||||
|
||||
return _.join(_.filter(rawParts, (r) => { return !_.isEmpty(r); }), '/');
|
||||
return _.kebabCase(_.deburr(_.trim(r)))
|
||||
})
|
||||
|
||||
return _.join(_.filter(rawParts, (r) => { return !_.isEmpty(r) }), '/')
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
"use strict";
|
||||
'use strict'
|
||||
|
||||
jQuery( document ).ready(function( $ ) {
|
||||
|
||||
$('#login-user').focus();
|
||||
|
||||
});
|
||||
jQuery(document).ready(function ($) {
|
||||
$('#login-user').focus()
|
||||
})
|
||||
|
@ -1,29 +1,27 @@
|
||||
|
||||
//-> Create New Document
|
||||
// -> Create New Document
|
||||
|
||||
let suggestedCreatePath = currentBasePath + '/new-page';
|
||||
let suggestedCreatePath = currentBasePath + '/new-page'
|
||||
|
||||
$('.btn-create-prompt').on('click', (ev) => {
|
||||
$('#txt-create-prompt').val(suggestedCreatePath);
|
||||
$('#modal-create-prompt').toggleClass('is-active');
|
||||
setInputSelection($('#txt-create-prompt').get(0), currentBasePath.length + 1, suggestedCreatePath.length);
|
||||
$('#txt-create-prompt').removeClass('is-danger').next().addClass('is-hidden');
|
||||
});
|
||||
$('#txt-create-prompt').val(suggestedCreatePath)
|
||||
$('#modal-create-prompt').toggleClass('is-active')
|
||||
setInputSelection($('#txt-create-prompt').get(0), currentBasePath.length + 1, suggestedCreatePath.length)
|
||||
$('#txt-create-prompt').removeClass('is-danger').next().addClass('is-hidden')
|
||||
})
|
||||
|
||||
$('#txt-create-prompt').on('keypress', (ev) => {
|
||||
if(ev.which === 13) {
|
||||
$('.btn-create-go').trigger('click');
|
||||
if (ev.which === 13) {
|
||||
$('.btn-create-go').trigger('click')
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$('.btn-create-go').on('click', (ev) => {
|
||||
|
||||
let newDocPath = makeSafePath($('#txt-create-prompt').val());
|
||||
if(_.isEmpty(newDocPath)) {
|
||||
$('#txt-create-prompt').addClass('is-danger').next().removeClass('is-hidden');
|
||||
let newDocPath = makeSafePath($('#txt-create-prompt').val())
|
||||
if (_.isEmpty(newDocPath)) {
|
||||
$('#txt-create-prompt').addClass('is-danger').next().removeClass('is-hidden')
|
||||
} else {
|
||||
$('#txt-create-prompt').parent().addClass('is-loading');
|
||||
window.location.assign('/create/' + newDocPath);
|
||||
$('#txt-create-prompt').parent().addClass('is-loading')
|
||||
window.location.assign('/create/' + newDocPath)
|
||||
}
|
||||
|
||||
});
|
||||
})
|
||||
|
@ -1,14 +1,12 @@
|
||||
|
||||
if($('#page-type-create').length) {
|
||||
if ($('#page-type-create').length) {
|
||||
let pageEntryPath = $('#page-type-create').data('entrypath')
|
||||
|
||||
let pageEntryPath = $('#page-type-create').data('entrypath');
|
||||
|
||||
//-> Discard
|
||||
// -> Discard
|
||||
|
||||
$('.btn-create-discard').on('click', (ev) => {
|
||||
$('#modal-create-discard').toggleClass('is-active');
|
||||
});
|
||||
|
||||
//=include ../components/editor.js
|
||||
$('#modal-create-discard').toggleClass('is-active')
|
||||
})
|
||||
|
||||
// =include ../components/editor.js
|
||||
}
|
@ -1,14 +1,12 @@
|
||||
|
||||
if($('#page-type-edit').length) {
|
||||
if ($('#page-type-edit').length) {
|
||||
let pageEntryPath = $('#page-type-edit').data('entrypath')
|
||||
|
||||
let pageEntryPath = $('#page-type-edit').data('entrypath');
|
||||
|
||||
//-> Discard
|
||||
// -> Discard
|
||||
|
||||
$('.btn-edit-discard').on('click', (ev) => {
|
||||
$('#modal-edit-discard').toggleClass('is-active');
|
||||
});
|
||||
|
||||
//=include ../components/editor.js
|
||||
$('#modal-edit-discard').toggleClass('is-active')
|
||||
})
|
||||
|
||||
// =include ../components/editor.js
|
||||
}
|
@ -1,18 +1,16 @@
|
||||
|
||||
if($('#page-type-source').length) {
|
||||
if ($('#page-type-source').length) {
|
||||
var scEditor = ace.edit('source-display')
|
||||
scEditor.setTheme('ace/theme/tomorrow_night')
|
||||
scEditor.getSession().setMode('ace/mode/markdown')
|
||||
scEditor.setOption('fontSize', '14px')
|
||||
scEditor.setOption('hScrollBarAlwaysVisible', false)
|
||||
scEditor.setOption('wrap', true)
|
||||
scEditor.setReadOnly(true)
|
||||
scEditor.renderer.updateFull()
|
||||
|
||||
var scEditor = ace.edit("source-display");
|
||||
scEditor.setTheme("ace/theme/tomorrow_night");
|
||||
scEditor.getSession().setMode("ace/mode/markdown");
|
||||
scEditor.setOption('fontSize', '14px');
|
||||
scEditor.setOption('hScrollBarAlwaysVisible', false);
|
||||
scEditor.setOption('wrap', true);
|
||||
scEditor.setReadOnly(true);
|
||||
scEditor.renderer.updateFull();
|
||||
|
||||
let currentBasePath = ($('#page-type-source').data('entrypath') !== 'home') ? $('#page-type-source').data('entrypath') : '';
|
||||
|
||||
//=include ../modals/create.js
|
||||
//=include ../modals/move.js
|
||||
let currentBasePath = ($('#page-type-source').data('entrypath') !== 'home') ? $('#page-type-source').data('entrypath') : ''
|
||||
|
||||
// =include ../modals/create.js
|
||||
// =include ../modals/move.js
|
||||
}
|
@ -1,9 +1,7 @@
|
||||
|
||||
if($('#page-type-view').length) {
|
||||
|
||||
let currentBasePath = ($('#page-type-view').data('entrypath') !== 'home') ? $('#page-type-view').data('entrypath') : '';
|
||||
|
||||
//=include ../modals/create.js
|
||||
//=include ../modals/move.js
|
||||
if ($('#page-type-view').length) {
|
||||
let currentBasePath = ($('#page-type-view').data('entrypath') !== 'home') ? $('#page-type-view').data('entrypath') : ''
|
||||
|
||||
// =include ../modals/create.js
|
||||
// =include ../modals/move.js
|
||||
}
|
@ -1,80 +1,80 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
var passport = require('passport');
|
||||
var ExpressBrute = require('express-brute');
|
||||
var ExpressBruteMongooseStore = require('express-brute-mongoose');
|
||||
var moment = require('moment');
|
||||
'use strict'
|
||||
|
||||
const express = require('express')
|
||||
const router = express.Router()
|
||||
const passport = require('passport')
|
||||
const ExpressBrute = require('express-brute')
|
||||
const ExpressBruteMongooseStore = require('express-brute-mongoose')
|
||||
const moment = require('moment')
|
||||
|
||||
/**
|
||||
* Setup Express-Brute
|
||||
*/
|
||||
var EBstore = new ExpressBruteMongooseStore(db.Bruteforce);
|
||||
var bruteforce = new ExpressBrute(EBstore, {
|
||||
const EBstore = new ExpressBruteMongooseStore(db.Bruteforce)
|
||||
const bruteforce = new ExpressBrute(EBstore, {
|
||||
freeRetries: 5,
|
||||
minWait: 60 * 1000,
|
||||
maxWait: 5 * 60 * 1000,
|
||||
refreshTimeoutOnRequest: false,
|
||||
failCallback(req, res, next, nextValidRequestDate) {
|
||||
failCallback (req, res, next, nextValidRequestDate) {
|
||||
req.flash('alert', {
|
||||
class: 'error',
|
||||
title: 'Too many attempts!',
|
||||
message: "You've made too many failed attempts in a short period of time, please try again " + moment(nextValidRequestDate).fromNow() + '.',
|
||||
iconClass: 'fa-times'
|
||||
});
|
||||
res.redirect('/login');
|
||||
})
|
||||
res.redirect('/login')
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
/**
|
||||
* Login form
|
||||
*/
|
||||
router.get('/login', function(req, res, next) {
|
||||
router.get('/login', function (req, res, next) {
|
||||
res.render('auth/login', {
|
||||
usr: res.locals.usr
|
||||
});
|
||||
});
|
||||
|
||||
router.post('/login', bruteforce.prevent, function(req, res, next) {
|
||||
passport.authenticate('local', function(err, user, info) {
|
||||
})
|
||||
})
|
||||
|
||||
if (err) { return next(err); }
|
||||
router.post('/login', bruteforce.prevent, function (req, res, next) {
|
||||
passport.authenticate('local', function (err, user, info) {
|
||||
if (err) { return next(err) }
|
||||
|
||||
if (!user) {
|
||||
req.flash('alert', {
|
||||
title: 'Invalid login',
|
||||
message: "The email or password is invalid."
|
||||
});
|
||||
return res.redirect('/login');
|
||||
message: 'The email or password is invalid.'
|
||||
})
|
||||
return res.redirect('/login')
|
||||
}
|
||||
|
||||
req.logIn(user, function(err) {
|
||||
if (err) { return next(err); }
|
||||
req.logIn(user, function (err) {
|
||||
if (err) { return next(err) }
|
||||
req.brute.reset(function () {
|
||||
return res.redirect('/');
|
||||
});
|
||||
});
|
||||
|
||||
})(req, res, next);
|
||||
});
|
||||
return res.redirect('/')
|
||||
})
|
||||
})
|
||||
})(req, res, next)
|
||||
})
|
||||
|
||||
/**
|
||||
* Social Login
|
||||
*/
|
||||
|
||||
router.get('/login/ms', passport.authenticate('windowslive', { scope: ['wl.signin', 'wl.basic', 'wl.emails'] }));
|
||||
router.get('/login/google', passport.authenticate('google', { scope: ['profile', 'email'] }));
|
||||
router.get('/login/facebook', passport.authenticate('facebook', { scope: ['public_profile', 'email'] }));
|
||||
router.get('/login/ms', passport.authenticate('windowslive', { scope: ['wl.signin', 'wl.basic', 'wl.emails'] }))
|
||||
router.get('/login/google', passport.authenticate('google', { scope: ['profile', 'email'] }))
|
||||
router.get('/login/facebook', passport.authenticate('facebook', { scope: ['public_profile', 'email'] }))
|
||||
|
||||
router.get('/login/ms/callback', passport.authenticate('windowslive', { failureRedirect: '/login', successRedirect: '/' }));
|
||||
router.get('/login/google/callback', passport.authenticate('google', { failureRedirect: '/login', successRedirect: '/' }));
|
||||
router.get('/login/facebook/callback', passport.authenticate('facebook', { failureRedirect: '/login', successRedirect: '/' }));
|
||||
router.get('/login/ms/callback', passport.authenticate('windowslive', { failureRedirect: '/login', successRedirect: '/' }))
|
||||
router.get('/login/google/callback', passport.authenticate('google', { failureRedirect: '/login', successRedirect: '/' }))
|
||||
router.get('/login/facebook/callback', passport.authenticate('facebook', { failureRedirect: '/login', successRedirect: '/' }))
|
||||
|
||||
/**
|
||||
* Logout
|
||||
*/
|
||||
router.get('/logout', function(req, res) {
|
||||
req.logout();
|
||||
res.redirect('/');
|
||||
});
|
||||
router.get('/logout', function (req, res) {
|
||||
req.logout()
|
||||
res.redirect('/')
|
||||
})
|
||||
|
||||
module.exports = router;
|
||||
module.exports = router
|
||||
|
@ -1,184 +1,160 @@
|
||||
"use strict";
|
||||
'use strict'
|
||||
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
const express = require('express')
|
||||
const router = express.Router()
|
||||
|
||||
var readChunk = require('read-chunk'),
|
||||
fileType = require('file-type'),
|
||||
Promise = require('bluebird'),
|
||||
fs = Promise.promisifyAll(require('fs-extra')),
|
||||
path = require('path'),
|
||||
_ = require('lodash');
|
||||
const readChunk = require('read-chunk')
|
||||
const fileType = require('file-type')
|
||||
const Promise = require('bluebird')
|
||||
const fs = Promise.promisifyAll(require('fs-extra'))
|
||||
const path = require('path')
|
||||
const _ = require('lodash')
|
||||
|
||||
var validPathRe = new RegExp("^([a-z0-9\\/-]+\\.[a-z0-9]+)$");
|
||||
var validPathThumbsRe = new RegExp("^([0-9]+\\.png)$");
|
||||
const validPathRe = new RegExp('^([a-z0-9\\/-]+\\.[a-z0-9]+)$')
|
||||
const validPathThumbsRe = new RegExp('^([0-9]+\\.png)$')
|
||||
|
||||
// ==========================================
|
||||
// SERVE UPLOADS FILES
|
||||
// ==========================================
|
||||
|
||||
router.get('/t/*', (req, res, next) => {
|
||||
|
||||
let fileName = req.params[0];
|
||||
if(!validPathThumbsRe.test(fileName)) {
|
||||
return res.sendStatus(404).end();
|
||||
let fileName = req.params[0]
|
||||
if (!validPathThumbsRe.test(fileName)) {
|
||||
return res.sendStatus(404).end()
|
||||
}
|
||||
|
||||
//todo: Authentication-based access
|
||||
// todo: Authentication-based access
|
||||
|
||||
res.sendFile(fileName, {
|
||||
root: lcdata.getThumbsPath(),
|
||||
dotfiles: 'deny'
|
||||
}, (err) => {
|
||||
if (err) {
|
||||
res.status(err.status).end();
|
||||
res.status(err.status).end()
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
router.post('/img', lcdata.uploadImgHandler, (req, res, next) => {
|
||||
|
||||
let destFolder = _.chain(req.body.folder).trim().toLower().value();
|
||||
let destFolder = _.chain(req.body.folder).trim().toLower().value()
|
||||
|
||||
upl.validateUploadsFolder(destFolder).then((destFolderPath) => {
|
||||
|
||||
if(!destFolderPath) {
|
||||
res.json({ ok: false, msg: 'Invalid Folder' });
|
||||
return true;
|
||||
if (!destFolderPath) {
|
||||
res.json({ ok: false, msg: 'Invalid Folder' })
|
||||
return true
|
||||
}
|
||||
|
||||
Promise.map(req.files, (f) => {
|
||||
|
||||
let destFilename = '';
|
||||
let destFilePath = '';
|
||||
let destFilename = ''
|
||||
let destFilePath = ''
|
||||
|
||||
return lcdata.validateUploadsFilename(f.originalname, destFolder, true).then((fname) => {
|
||||
destFilename = fname
|
||||
destFilePath = path.resolve(destFolderPath, destFilename)
|
||||
|
||||
destFilename = fname;
|
||||
destFilePath = path.resolve(destFolderPath, destFilename);
|
||||
|
||||
return readChunk(f.path, 0, 262);
|
||||
|
||||
return readChunk(f.path, 0, 262)
|
||||
}).then((buf) => {
|
||||
// -> Check MIME type by magic number
|
||||
|
||||
//-> Check MIME type by magic number
|
||||
|
||||
let mimeInfo = fileType(buf);
|
||||
if(!_.includes(['image/png', 'image/jpeg', 'image/gif', 'image/webp'], mimeInfo.mime)) {
|
||||
return Promise.reject(new Error('Invalid file type.'));
|
||||
let mimeInfo = fileType(buf)
|
||||
if (!_.includes(['image/png', 'image/jpeg', 'image/gif', 'image/webp'], mimeInfo.mime)) {
|
||||
return Promise.reject(new Error('Invalid file type.'))
|
||||
}
|
||||
return true;
|
||||
|
||||
return true
|
||||
}).then(() => {
|
||||
// -> Move file to final destination
|
||||
|
||||
//-> Move file to final destination
|
||||
|
||||
return fs.moveAsync(f.path, destFilePath, { clobber: false });
|
||||
|
||||
return fs.moveAsync(f.path, destFilePath, { clobber: false })
|
||||
}).then(() => {
|
||||
return {
|
||||
ok: true,
|
||||
filename: destFilename,
|
||||
filesize: f.size
|
||||
};
|
||||
}).reflect();
|
||||
|
||||
}
|
||||
}).reflect()
|
||||
}, {concurrency: 3}).then((results) => {
|
||||
let uplResults = _.map(results, (r) => {
|
||||
if(r.isFulfilled()) {
|
||||
return r.value();
|
||||
if (r.isFulfilled()) {
|
||||
return r.value()
|
||||
} else {
|
||||
return {
|
||||
ok: false,
|
||||
msg: r.reason().message
|
||||
};
|
||||
}
|
||||
});
|
||||
res.json({ ok: true, results: uplResults });
|
||||
return true;
|
||||
}
|
||||
})
|
||||
res.json({ ok: true, results: uplResults })
|
||||
return true
|
||||
}).catch((err) => {
|
||||
res.json({ ok: false, msg: err.message });
|
||||
return true;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
res.json({ ok: false, msg: err.message })
|
||||
return true
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
router.post('/file', lcdata.uploadFileHandler, (req, res, next) => {
|
||||
|
||||
let destFolder = _.chain(req.body.folder).trim().toLower().value();
|
||||
let destFolder = _.chain(req.body.folder).trim().toLower().value()
|
||||
|
||||
upl.validateUploadsFolder(destFolder).then((destFolderPath) => {
|
||||
|
||||
if(!destFolderPath) {
|
||||
res.json({ ok: false, msg: 'Invalid Folder' });
|
||||
return true;
|
||||
if (!destFolderPath) {
|
||||
res.json({ ok: false, msg: 'Invalid Folder' })
|
||||
return true
|
||||
}
|
||||
|
||||
Promise.map(req.files, (f) => {
|
||||
|
||||
let destFilename = '';
|
||||
let destFilePath = '';
|
||||
let destFilename = ''
|
||||
let destFilePath = ''
|
||||
|
||||
return lcdata.validateUploadsFilename(f.originalname, destFolder, false).then((fname) => {
|
||||
destFilename = fname
|
||||
destFilePath = path.resolve(destFolderPath, destFilename)
|
||||
|
||||
destFilename = fname;
|
||||
destFilePath = path.resolve(destFolderPath, destFilename);
|
||||
|
||||
//-> Move file to final destination
|
||||
|
||||
return fs.moveAsync(f.path, destFilePath, { clobber: false });
|
||||
// -> Move file to final destination
|
||||
|
||||
return fs.moveAsync(f.path, destFilePath, { clobber: false })
|
||||
}).then(() => {
|
||||
return {
|
||||
ok: true,
|
||||
filename: destFilename,
|
||||
filesize: f.size
|
||||
};
|
||||
}).reflect();
|
||||
|
||||
}
|
||||
}).reflect()
|
||||
}, {concurrency: 3}).then((results) => {
|
||||
let uplResults = _.map(results, (r) => {
|
||||
if(r.isFulfilled()) {
|
||||
return r.value();
|
||||
if (r.isFulfilled()) {
|
||||
return r.value()
|
||||
} else {
|
||||
return {
|
||||
ok: false,
|
||||
msg: r.reason().message
|
||||
};
|
||||
}
|
||||
});
|
||||
res.json({ ok: true, results: uplResults });
|
||||
return true;
|
||||
}
|
||||
})
|
||||
res.json({ ok: true, results: uplResults })
|
||||
return true
|
||||
}).catch((err) => {
|
||||
res.json({ ok: false, msg: err.message });
|
||||
return true;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
res.json({ ok: false, msg: err.message })
|
||||
return true
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
router.get('/*', (req, res, next) => {
|
||||
|
||||
let fileName = req.params[0];
|
||||
if(!validPathRe.test(fileName)) {
|
||||
return res.sendStatus(404).end();
|
||||
let fileName = req.params[0]
|
||||
if (!validPathRe.test(fileName)) {
|
||||
return res.sendStatus(404).end()
|
||||
}
|
||||
|
||||
//todo: Authentication-based access
|
||||
// todo: Authentication-based access
|
||||
|
||||
res.sendFile(fileName, {
|
||||
root: git.getRepoPath() + '/uploads/',
|
||||
dotfiles: 'deny'
|
||||
}, (err) => {
|
||||
if (err) {
|
||||
res.status(err.status).end();
|
||||
res.status(err.status).end()
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
module.exports = router;
|
||||
module.exports = router
|
||||
|
@ -1,95 +1,95 @@
|
||||
"use strict";
|
||||
'use strict'
|
||||
|
||||
module.exports = (socket) => {
|
||||
const _ = require('lodash')
|
||||
|
||||
if(!socket.request.user.logged_in) {
|
||||
return;
|
||||
module.exports = (socket) => {
|
||||
if (!socket.request.user.logged_in) {
|
||||
return
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// -----------------------------------------
|
||||
// SEARCH
|
||||
//-----------------------------------------
|
||||
// -----------------------------------------
|
||||
|
||||
socket.on('search', (data, cb) => {
|
||||
cb = cb || _.noop;
|
||||
cb = cb || _.noop
|
||||
entries.search(data.terms).then((results) => {
|
||||
return cb(results) || true;
|
||||
});
|
||||
});
|
||||
return cb(results) || true
|
||||
})
|
||||
})
|
||||
|
||||
//-----------------------------------------
|
||||
// -----------------------------------------
|
||||
// UPLOADS
|
||||
//-----------------------------------------
|
||||
// -----------------------------------------
|
||||
|
||||
socket.on('uploadsGetFolders', (data, cb) => {
|
||||
cb = cb || _.noop;
|
||||
cb = cb || _.noop
|
||||
upl.getUploadsFolders().then((f) => {
|
||||
return cb(f) || true;
|
||||
});
|
||||
});
|
||||
return cb(f) || true
|
||||
})
|
||||
})
|
||||
|
||||
socket.on('uploadsCreateFolder', (data, cb) => {
|
||||
cb = cb || _.noop;
|
||||
cb = cb || _.noop
|
||||
upl.createUploadsFolder(data.foldername).then((f) => {
|
||||
return cb(f) || true;
|
||||
});
|
||||
});
|
||||
return cb(f) || true
|
||||
})
|
||||
})
|
||||
|
||||
socket.on('uploadsGetImages', (data, cb) => {
|
||||
cb = cb || _.noop;
|
||||
cb = cb || _.noop
|
||||
upl.getUploadsFiles('image', data.folder).then((f) => {
|
||||
return cb(f) || true;
|
||||
});
|
||||
});
|
||||
return cb(f) || true
|
||||
})
|
||||
})
|
||||
|
||||
socket.on('uploadsGetFiles', (data, cb) => {
|
||||
cb = cb || _.noop;
|
||||
cb = cb || _.noop
|
||||
upl.getUploadsFiles('binary', data.folder).then((f) => {
|
||||
return cb(f) || true;
|
||||
});
|
||||
});
|
||||
return cb(f) || true
|
||||
})
|
||||
})
|
||||
|
||||
socket.on('uploadsDeleteFile', (data, cb) => {
|
||||
cb = cb || _.noop;
|
||||
cb = cb || _.noop
|
||||
upl.deleteUploadsFile(data.uid).then((f) => {
|
||||
return cb(f) || true;
|
||||
});
|
||||
});
|
||||
return cb(f) || true
|
||||
})
|
||||
})
|
||||
|
||||
socket.on('uploadsFetchFileFromURL', (data, cb) => {
|
||||
cb = cb || _.noop;
|
||||
cb = cb || _.noop
|
||||
upl.downloadFromUrl(data.folder, data.fetchUrl).then((f) => {
|
||||
return cb({ ok: true }) || true;
|
||||
return cb({ ok: true }) || true
|
||||
}).catch((err) => {
|
||||
return cb({
|
||||
ok: false,
|
||||
msg: err.message
|
||||
}) || true;
|
||||
});
|
||||
});
|
||||
}) || true
|
||||
})
|
||||
})
|
||||
|
||||
socket.on('uploadsRenameFile', (data, cb) => {
|
||||
cb = cb || _.noop;
|
||||
cb = cb || _.noop
|
||||
upl.moveUploadsFile(data.uid, data.folder, data.filename).then((f) => {
|
||||
return cb({ ok: true }) || true;
|
||||
return cb({ ok: true }) || true
|
||||
}).catch((err) => {
|
||||
return cb({
|
||||
ok: false,
|
||||
msg: err.message
|
||||
}) || true;
|
||||
});
|
||||
});
|
||||
}) || true
|
||||
})
|
||||
})
|
||||
|
||||
socket.on('uploadsMoveFile', (data, cb) => {
|
||||
cb = cb || _.noop;
|
||||
cb = cb || _.noop
|
||||
upl.moveUploadsFile(data.uid, data.folder).then((f) => {
|
||||
return cb({ ok: true }) || true;
|
||||
return cb({ ok: true }) || true
|
||||
}).catch((err) => {
|
||||
return cb({
|
||||
ok: false,
|
||||
msg: err.message
|
||||
}) || true;
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
}) || true
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -0,0 +1,3 @@
|
||||
'use strict'
|
||||
|
||||
// TODO
|
@ -1,11 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
let path = require('path'),
|
||||
fs = require('fs');
|
||||
|
||||
// ========================================
|
||||
// Load global modules
|
||||
// ========================================
|
||||
|
||||
global._ = require('lodash');
|
||||
global.winston = require('winston');
|
Loading…
Reference in new issue