Commit 567e1307 authored by NGPixel's avatar NGPixel

Insert Image model + Uploads Folders list

parent 405e23f0
......@@ -75,12 +75,15 @@ var job = new cron({
let jobs = [];
let repoPath = path.resolve(ROOTPATH, appconfig.datadir.repo);
let uploadsPath = path.join(repoPath, 'uploads');
// ----------------------------------------
// Compile Jobs
// ----------------------------------------
//*****************************************
//-> Resync with Git remote
//*****************************************
jobs.push(git.onReady.then(() => {
return git.resync().then(() => {
......@@ -140,6 +143,24 @@ var job = new cron({
});
}));
//*****************************************
//-> Refresh uploads data
//*****************************************
jobs.push(fs.readdirAsync(uploadsPath).then((ls) => {
return Promise.map(ls, (f) => {
return fs.statAsync(path.join(uploadsPath, f)).then((s) => { return { filename: f, stat: s }; });
}).filter((s) => { return s.stat.isDirectory(); }).then((arrStats) => {
ws.emit('uploadsSetFolders', {
auth: WSInternalKey,
content: _.map(arrStats, 'filename')
});
return true;
});
}));
// ----------------------------------------
// Run
// ----------------------------------------
......
This source diff could not be displayed because it is too large. You can view the blob instead.
"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function setInputSelection(e,t,a){if(e.focus(),"undefined"!=typeof e.selectionStart)e.selectionStart=t,e.selectionEnd=a;else if(document.selection&&document.selection.createRange){e.select();var o=document.selection.createRange();o.collapse(!0),o.moveEnd("character",a),o.moveStart("character",t),o.select()}}function makeSafePath(e){var t=_.split(_.trim(e),"/");return t=_.map(t,function(e){return _.kebabCase(_.deburr(_.trim(e)))}),_.join(_.filter(t,function(e){return!_.isEmpty(e)}),"/")}var _createClass=function(){function e(e,t){for(var a=0;a<t.length;a++){var o=t[a];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,a,o){return a&&e(t.prototype,a),o&&e(t,o),t}}();jQuery(document).ready(function(e){e("a").smoothScroll({speed:400,offset:-70});new Sticky(".stickyscroll");e(window).bind("beforeunload",function(){e("#notifload").addClass("active")}),e(document).ajaxSend(function(){e("#notifload").addClass("active")}).ajaxComplete(function(){e("#notifload").removeClass("active")});var t=new Alerts;alertsData&&_.forEach(alertsData,function(e){t.push(e)});var a=io(ioHost);if(jQuery(document).ready(function(e){if(e("#search-input").length){e("#search-input").focus(),Vue.transition("slide",{enterClass:"slideInDown",leaveClass:"fadeOutUp"}),e(".searchresults").css("display","block");var t=new Vue({el:"#header-container",data:{searchq:"",searchres:[],searchsuggest:[],searchload:0,searchactive:!1,searchmoveidx:0,searchmovekey:"",searchmovearr:[]},watch:{searchq:function(e,o){t.searchmoveidx=0,e.length>=3?(t.searchactive=!0,t.searchload++,a.emit("search",{terms:e},function(e){t.searchres=e.match,t.searchsuggest=e.suggest,t.searchmovearr=_.concat([],t.searchres,t.searchsuggest),t.searchload>0&&t.searchload--})):(t.searchactive=!1,t.searchres=[],t.searchsuggest=[],t.searchmovearr=[],t.searchload=0)},searchmoveidx:function(e,a){e>0?t.searchmovekey=t.searchmovearr[e-1].document?"res."+t.searchmovearr[e-1].document.entryPath:"sug."+t.searchmovearr[e-1]:t.searchmovekey=""}},methods:{useSuggestion:function(e){t.searchq=e},closeSearch:function(){t.searchq=""},moveSelectSearch:function(){if(!(t.searchmoveidx<1)){var e=t.searchmoveidx-1;t.searchmovearr[e].document?window.location.assign("/"+t.searchmovearr[e].document.entryPath):t.searchq=t.searchmovearr[e]}},moveDownSearch:function(){t.searchmoveidx<t.searchmovearr.length&&t.searchmoveidx++},moveUpSearch:function(){t.searchmoveidx>0&&t.searchmoveidx--}}});e("main").on("click",t.closeSearch)}}),e("#page-type-view").length&&!function(){var a="home"!==e("#page-type-view").data("entrypath")?e("#page-type-view").data("entrypath"):"",o=a+"/new-page";e(".btn-create-prompt").on("click",function(t){e("#txt-create-prompt").val(o),e("#modal-create-prompt").toggleClass("is-active"),setInputSelection(e("#txt-create-prompt").get(0),a.length+1,o.length),e("#txt-create-prompt").removeClass("is-danger").next().addClass("is-hidden")}),e("#txt-create-prompt").on("keypress",function(t){13===t.which&&e(".btn-create-go").trigger("click")}),e(".btn-create-go").on("click",function(t){var a=makeSafePath(e("#txt-create-prompt").val());_.isEmpty(a)?e("#txt-create-prompt").addClass("is-danger").next().removeClass("is-hidden"):(e("#txt-create-prompt").parent().addClass("is-loading"),window.location.assign("/create/"+a))}),""!==a&&e(".btn-move-prompt").removeClass("is-hidden");var n=_.lastIndexOf(a,"/")+1;e(".btn-move-prompt").on("click",function(t){e("#txt-move-prompt").val(a),e("#modal-move-prompt").toggleClass("is-active"),setInputSelection(e("#txt-move-prompt").get(0),n,a.length),e("#txt-move-prompt").removeClass("is-danger").next().addClass("is-hidden")}),e("#txt-move-prompt").on("keypress",function(t){13===t.which&&e(".btn-move-go").trigger("click")}),e(".btn-move-go").on("click",function(o){var n=makeSafePath(e("#txt-move-prompt").val());_.isEmpty(n)||n===a||"home"===n?e("#txt-move-prompt").addClass("is-danger").next().removeClass("is-hidden"):(e("#txt-move-prompt").parent().addClass("is-loading"),e.ajax(window.location.href,{data:{move:n},dataType:"json",method:"PUT"}).then(function(e,a,o){e.ok?window.location.assign("/"+n):t.pushError("Something went wrong",e.error)},function(e,a,o){t.pushError("Something went wrong","Save operation failed.")}))})}(),e("#page-type-create").length){var o;!function(){var a=e("#page-type-create").data("entrypath");e(".btn-create-discard").on("click",function(t){e("#modal-create-discard").toggleClass("is-active")}),1===e("#mk-editor").length&&!function(){var a=!1,n=(new Vue({el:"#modal-editor-image",data:{modeSelected:"text"},methods:{cancel:function(t){a=!1,e("#modal-editor-image").slideUp()},insertImage:function(e){o.codemirror.doc.somethingSelected()&&o.codemirror.execCommand("singleSelection");var t="\n```"+r.modeSelected+"\n"+n.getValue()+"\n```\n";o.codemirror.doc.replaceSelection(t),r.cancel()}}}),ace.edit("codeblock-editor"));n.setTheme("ace/theme/tomorrow_night"),n.getSession().setMode("ace/mode/markdown"),n.setOption("fontSize","14px"),n.setOption("hScrollBarAlwaysVisible",!1),n.setOption("wrap",!0);var i=ace.require("ace/ext/modelist"),r=new Vue({el:"#modal-editor-codeblock",data:{modes:i.modesByName,modeSelected:"text"},watch:{modeSelected:function(e,t){l(e).done(function(){ace.require("ace/mode/"+e),n.getSession().setMode("ace/mode/"+e)})}},methods:{cancel:function(t){a=!1,e("#modal-editor-codeblock").slideUp()},insertCode:function(e){o.codemirror.doc.somethingSelected()&&o.codemirror.execCommand("singleSelection");var t="\n```"+r.modeSelected+"\n"+n.getValue()+"\n```\n";o.codemirror.doc.replaceSelection(t),r.cancel()}}}),c=[],l=function(t){return e.ajax({url:"/js/ace/mode-"+t+".js",dataType:"script",cache:!0,beforeSend:function(){if(_.includes(c,t))return!1},success:function(){c.push(t)}})};o=new SimpleMDE({autofocus:!0,autoDownloadFontAwesome:!1,element:e("#mk-editor").get(0),placeholder:"Enter Markdown formatted content here...",spellChecker:!1,status:!1,toolbar:[{name:"bold",action:SimpleMDE.toggleBold,className:"fa fa-bold",title:"Bold"},{name:"italic",action:SimpleMDE.toggleItalic,className:"fa fa-italic",title:"Italic"},{name:"strikethrough",action:SimpleMDE.toggleStrikethrough,className:"fa fa-strikethrough",title:"Strikethrough"},"|",{name:"heading-1",action:SimpleMDE.toggleHeading1,className:"fa fa-header fa-header-x fa-header-1",title:"Big Heading"},{name:"heading-2",action:SimpleMDE.toggleHeading2,className:"fa fa-header fa-header-x fa-header-2",title:"Medium Heading"},{name:"heading-3",action:SimpleMDE.toggleHeading3,className:"fa fa-header fa-header-x fa-header-3",title:"Small Heading"},{name:"quote",action:SimpleMDE.toggleBlockquote,className:"fa fa-quote-left",title:"Quote"},"|",{name:"unordered-list",action:SimpleMDE.toggleUnorderedList,className:"fa fa-list-ul",title:"Bullet List"},{name:"ordered-list",action:SimpleMDE.toggleOrderedList,className:"fa fa-list-ol",title:"Numbered List"},"|",{name:"link",action:function(t){a||(a=!0,e("#modal-editor-link").slideToggle())},className:"fa fa-link",title:"Insert Link"},{name:"image",action:function(t){a||(a=!0,e("#modal-editor-image").slideDown())},className:"fa fa-image",title:"Insert Image"},{name:"file",action:function(e){},className:"fa fa-file-text-o",title:"Insert File"},"|",{name:"inline-code",action:function(e){if(!e.codemirror.doc.somethingSelected())return t.pushError("Invalid selection","You must select at least 1 character first.");var a=e.codemirror.doc.getSelections();a=_.map(a,function(e){return"`"+e+"`"}),e.codemirror.doc.replaceSelections(a)},className:"fa fa-terminal",title:"Inline Code"},{name:"code-block",action:function(t){a||(a=!0,o.codemirror.doc.somethingSelected()?n.setValue(o.codemirror.doc.getSelection()):n.setValue(""),e("#modal-editor-codeblock").slideDown(400,function(){n.resize(),n.focus()}))},className:"fa fa-code",title:"Code Block"},"|",{name:"table",action:function(e){},className:"fa fa-table",title:"Insert Table"},{name:"horizontal-rule",action:SimpleMDE.drawHorizontalRule,className:"fa fa-minus",title:"Horizontal Rule"}],shortcuts:{toggleBlockquote:null,toggleFullScreen:null}})}(),e(".btn-edit-save").on("click",function(n){e.ajax(window.location.href,{data:{markdown:o.value()},dataType:"json",method:"PUT"}).then(function(e,o,n){e.ok?window.location.assign("/"+a):t.pushError("Something went wrong",e.error)},function(e,a,o){t.pushError("Something went wrong","Save operation failed.")})})}()}if(e("#page-type-edit").length){var o;!function(){var a=e("#page-type-edit").data("entrypath");e(".btn-edit-discard").on("click",function(t){e("#modal-edit-discard").toggleClass("is-active")}),1===e("#mk-editor").length&&!function(){var a=!1,n=(new Vue({el:"#modal-editor-image",data:{modeSelected:"text"},methods:{cancel:function(t){a=!1,e("#modal-editor-image").slideUp()},insertImage:function(e){o.codemirror.doc.somethingSelected()&&o.codemirror.execCommand("singleSelection");var t="\n```"+r.modeSelected+"\n"+n.getValue()+"\n```\n";o.codemirror.doc.replaceSelection(t),r.cancel()}}}),ace.edit("codeblock-editor"));n.setTheme("ace/theme/tomorrow_night"),n.getSession().setMode("ace/mode/markdown"),n.setOption("fontSize","14px"),n.setOption("hScrollBarAlwaysVisible",!1),n.setOption("wrap",!0);var i=ace.require("ace/ext/modelist"),r=new Vue({el:"#modal-editor-codeblock",data:{modes:i.modesByName,modeSelected:"text"},watch:{modeSelected:function(e,t){l(e).done(function(){ace.require("ace/mode/"+e),n.getSession().setMode("ace/mode/"+e)})}},methods:{cancel:function(t){a=!1,e("#modal-editor-codeblock").slideUp()},insertCode:function(e){o.codemirror.doc.somethingSelected()&&o.codemirror.execCommand("singleSelection");var t="\n```"+r.modeSelected+"\n"+n.getValue()+"\n```\n";o.codemirror.doc.replaceSelection(t),r.cancel()}}}),c=[],l=function(t){return e.ajax({url:"/js/ace/mode-"+t+".js",dataType:"script",cache:!0,beforeSend:function(){if(_.includes(c,t))return!1},success:function(){c.push(t)}})};o=new SimpleMDE({autofocus:!0,autoDownloadFontAwesome:!1,element:e("#mk-editor").get(0),placeholder:"Enter Markdown formatted content here...",spellChecker:!1,status:!1,toolbar:[{name:"bold",action:SimpleMDE.toggleBold,className:"fa fa-bold",title:"Bold"},{name:"italic",action:SimpleMDE.toggleItalic,className:"fa fa-italic",title:"Italic"},{name:"strikethrough",action:SimpleMDE.toggleStrikethrough,className:"fa fa-strikethrough",title:"Strikethrough"},"|",{name:"heading-1",action:SimpleMDE.toggleHeading1,className:"fa fa-header fa-header-x fa-header-1",title:"Big Heading"},{name:"heading-2",action:SimpleMDE.toggleHeading2,className:"fa fa-header fa-header-x fa-header-2",title:"Medium Heading"},{name:"heading-3",action:SimpleMDE.toggleHeading3,className:"fa fa-header fa-header-x fa-header-3",title:"Small Heading"},{name:"quote",action:SimpleMDE.toggleBlockquote,className:"fa fa-quote-left",title:"Quote"},"|",{name:"unordered-list",action:SimpleMDE.toggleUnorderedList,className:"fa fa-list-ul",title:"Bullet List"},{name:"ordered-list",action:SimpleMDE.toggleOrderedList,className:"fa fa-list-ol",title:"Numbered List"},"|",{name:"link",action:function(t){a||(a=!0,e("#modal-editor-link").slideToggle())},className:"fa fa-link",title:"Insert Link"},{name:"image",action:function(t){a||(a=!0,e("#modal-editor-image").slideDown())},className:"fa fa-image",title:"Insert Image"},{name:"file",action:function(e){},className:"fa fa-file-text-o",title:"Insert File"},"|",{name:"inline-code",action:function(e){if(!e.codemirror.doc.somethingSelected())return t.pushError("Invalid selection","You must select at least 1 character first.");var a=e.codemirror.doc.getSelections();a=_.map(a,function(e){return"`"+e+"`"}),e.codemirror.doc.replaceSelections(a)},className:"fa fa-terminal",title:"Inline Code"},{name:"code-block",action:function(t){a||(a=!0,o.codemirror.doc.somethingSelected()?n.setValue(o.codemirror.doc.getSelection()):n.setValue(""),e("#modal-editor-codeblock").slideDown(400,function(){n.resize(),n.focus()}))},className:"fa fa-code",title:"Code Block"},"|",{name:"table",action:function(e){},className:"fa fa-table",title:"Insert Table"},{name:"horizontal-rule",action:SimpleMDE.drawHorizontalRule,className:"fa fa-minus",title:"Horizontal Rule"}],shortcuts:{toggleBlockquote:null,toggleFullScreen:null}})}(),e(".btn-edit-save").on("click",function(n){e.ajax(window.location.href,{data:{markdown:o.value()},dataType:"json",method:"PUT"}).then(function(e,o,n){e.ok?window.location.assign("/"+a):t.pushError("Something went wrong",e.error)},function(e,a,o){t.pushError("Something went wrong","Save operation failed.")})})}()}if(e("#page-type-source").length){var n;!function(){n=ace.edit("source-display"),n.setTheme("ace/theme/tomorrow_night"),n.getSession().setMode("ace/mode/markdown"),n.setReadOnly(!0),n.renderer.updateFull();var a="home"!==e("#page-type-source").data("entrypath")?e("#page-type-source").data("entrypath"):"",o=a+"/new-page";e(".btn-create-prompt").on("click",function(t){e("#txt-create-prompt").val(o),e("#modal-create-prompt").toggleClass("is-active"),setInputSelection(e("#txt-create-prompt").get(0),a.length+1,o.length),e("#txt-create-prompt").removeClass("is-danger").next().addClass("is-hidden")}),e("#txt-create-prompt").on("keypress",function(t){13===t.which&&e(".btn-create-go").trigger("click")}),e(".btn-create-go").on("click",function(t){var a=makeSafePath(e("#txt-create-prompt").val());_.isEmpty(a)?e("#txt-create-prompt").addClass("is-danger").next().removeClass("is-hidden"):(e("#txt-create-prompt").parent().addClass("is-loading"),window.location.assign("/create/"+a))}),""!==a&&e(".btn-move-prompt").removeClass("is-hidden");var i=_.lastIndexOf(a,"/")+1;e(".btn-move-prompt").on("click",function(t){e("#txt-move-prompt").val(a),e("#modal-move-prompt").toggleClass("is-active"),setInputSelection(e("#txt-move-prompt").get(0),i,a.length),e("#txt-move-prompt").removeClass("is-danger").next().addClass("is-hidden")}),e("#txt-move-prompt").on("keypress",function(t){13===t.which&&e(".btn-move-go").trigger("click")}),e(".btn-move-go").on("click",function(o){var n=makeSafePath(e("#txt-move-prompt").val());_.isEmpty(n)||n===a||"home"===n?e("#txt-move-prompt").addClass("is-danger").next().removeClass("is-hidden"):(e("#txt-move-prompt").parent().addClass("is-loading"),e.ajax(window.location.href,{data:{move:n},dataType:"json",method:"PUT"}).then(function(e,a,o){e.ok?window.location.assign("/"+n):t.pushError("Something went wrong",e.error)},function(e,a,o){t.pushError("Something went wrong","Save operation failed.")}))})}()}});var Alerts=function(){function e(){_classCallCheck(this,e);var t=this;t.mdl=new Vue({el:"#alerts",data:{children:[]},methods:{acknowledge:function(e){t.close(e)}}}),t.uidNext=1}return _createClass(e,[{key:"push",value:function(e){var t=this,a=_.defaults(e,{_uid:t.uidNext,class:"is-info",message:"---",sticky:!1,title:"---"});t.mdl.children.push(a),a.sticky||_.delay(function(){t.close(a._uid)},5e3),t.uidNext++}},{key:"pushError",value:function(e,t){this.push({class:"is-danger",message:t,sticky:!1,title:e})}},{key:"pushSuccess",value:function(e,t){this.push({class:"is-success",message:t,sticky:!1,title:e})}},{key:"close",value:function(e){var t=this,a=_.findIndex(t.mdl.children,["_uid",e]),o=_.nth(t.mdl.children,a);a>=0&&o&&(o.class+=" exit",t.mdl.children.$set(a,o),_.delay(function(){t.mdl.children.$remove(o)},500))}}]),e}();
\ No newline at end of file
"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function setInputSelection(e,t,a){if(e.focus(),"undefined"!=typeof e.selectionStart)e.selectionStart=t,e.selectionEnd=a;else if(document.selection&&document.selection.createRange){e.select();var o=document.selection.createRange();o.collapse(!0),o.moveEnd("character",a),o.moveStart("character",t),o.select()}}function makeSafePath(e){var t=_.split(_.trim(e),"/");return t=_.map(t,function(e){return _.kebabCase(_.deburr(_.trim(e)))}),_.join(_.filter(t,function(e){return!_.isEmpty(e)}),"/")}var _createClass=function(){function e(e,t){for(var a=0;a<t.length;a++){var o=t[a];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,a,o){return a&&e(t.prototype,a),o&&e(t,o),t}}();jQuery(document).ready(function(e){e("a").smoothScroll({speed:400,offset:-70});new Sticky(".stickyscroll");e(window).bind("beforeunload",function(){e("#notifload").addClass("active")}),e(document).ajaxSend(function(){e("#notifload").addClass("active")}).ajaxComplete(function(){e("#notifload").removeClass("active")});var t=new Alerts;alertsData&&_.forEach(alertsData,function(e){t.push(e)});var a=io(ioHost);if(jQuery(document).ready(function(e){if(e("#search-input").length){e("#search-input").focus(),Vue.transition("slide",{enterClass:"slideInDown",leaveClass:"fadeOutUp"}),e(".searchresults").css("display","block");var t=new Vue({el:"#header-container",data:{searchq:"",searchres:[],searchsuggest:[],searchload:0,searchactive:!1,searchmoveidx:0,searchmovekey:"",searchmovearr:[]},watch:{searchq:function(e,o){t.searchmoveidx=0,e.length>=3?(t.searchactive=!0,t.searchload++,a.emit("search",{terms:e},function(e){t.searchres=e.match,t.searchsuggest=e.suggest,t.searchmovearr=_.concat([],t.searchres,t.searchsuggest),t.searchload>0&&t.searchload--})):(t.searchactive=!1,t.searchres=[],t.searchsuggest=[],t.searchmovearr=[],t.searchload=0)},searchmoveidx:function(e,a){e>0?t.searchmovekey=t.searchmovearr[e-1].document?"res."+t.searchmovearr[e-1].document.entryPath:"sug."+t.searchmovearr[e-1]:t.searchmovekey=""}},methods:{useSuggestion:function(e){t.searchq=e},closeSearch:function(){t.searchq=""},moveSelectSearch:function(){if(!(t.searchmoveidx<1)){var e=t.searchmoveidx-1;t.searchmovearr[e].document?window.location.assign("/"+t.searchmovearr[e].document.entryPath):t.searchq=t.searchmovearr[e]}},moveDownSearch:function(){t.searchmoveidx<t.searchmovearr.length&&t.searchmoveidx++},moveUpSearch:function(){t.searchmoveidx>0&&t.searchmoveidx--}}});e("main").on("click",t.closeSearch)}}),e("#page-type-view").length&&!function(){var a="home"!==e("#page-type-view").data("entrypath")?e("#page-type-view").data("entrypath"):"",o=a+"/new-page";e(".btn-create-prompt").on("click",function(t){e("#txt-create-prompt").val(o),e("#modal-create-prompt").toggleClass("is-active"),setInputSelection(e("#txt-create-prompt").get(0),a.length+1,o.length),e("#txt-create-prompt").removeClass("is-danger").next().addClass("is-hidden")}),e("#txt-create-prompt").on("keypress",function(t){13===t.which&&e(".btn-create-go").trigger("click")}),e(".btn-create-go").on("click",function(t){var a=makeSafePath(e("#txt-create-prompt").val());_.isEmpty(a)?e("#txt-create-prompt").addClass("is-danger").next().removeClass("is-hidden"):(e("#txt-create-prompt").parent().addClass("is-loading"),window.location.assign("/create/"+a))}),""!==a&&e(".btn-move-prompt").removeClass("is-hidden");var n=_.lastIndexOf(a,"/")+1;e(".btn-move-prompt").on("click",function(t){e("#txt-move-prompt").val(a),e("#modal-move-prompt").toggleClass("is-active"),setInputSelection(e("#txt-move-prompt").get(0),n,a.length),e("#txt-move-prompt").removeClass("is-danger").next().addClass("is-hidden")}),e("#txt-move-prompt").on("keypress",function(t){13===t.which&&e(".btn-move-go").trigger("click")}),e(".btn-move-go").on("click",function(o){var n=makeSafePath(e("#txt-move-prompt").val());_.isEmpty(n)||n===a||"home"===n?e("#txt-move-prompt").addClass("is-danger").next().removeClass("is-hidden"):(e("#txt-move-prompt").parent().addClass("is-loading"),e.ajax(window.location.href,{data:{move:n},dataType:"json",method:"PUT"}).then(function(e,a,o){e.ok?window.location.assign("/"+n):t.pushError("Something went wrong",e.error)},function(e,a,o){t.pushError("Something went wrong","Save operation failed.")}))})}(),e("#page-type-create").length){var o;!function(){var n=e("#page-type-create").data("entrypath");e(".btn-create-discard").on("click",function(t){e("#modal-create-discard").toggleClass("is-active")}),1===e("#mk-editor").length&&!function(){var n=!1,i=new Vue({el:"#modal-editor-image",data:{isLoading:!1,isLoadingText:"",newFolderName:"",newFolderShow:!1,folders:[],currentFolder:"",images:[]},methods:{open:function(){n=!0,e("#modal-editor-image").slideDown(),i.refreshFolders()},cancel:function(t){n=!1,e("#modal-editor-image").slideUp()},newFolder:function(e){i.newFolderShow=!0},newFolderDiscard:function(e){i.newFolderShow=!1},selectFolder:function(e){i.currentFolder=e,i.loadImages()},refreshFolders:function(){i.isLoading=!0,i.isLoadingText="Fetching folders list...",i.currentFolder="",Vue.nextTick(function(){a.emit("uploadsGetFolders",{},function(e){i.folders=e,i.loadImages()})})},loadImages:function(){i.isLoading=!0,i.isLoadingText="Fetching images...",Vue.nextTick(function(){a.emit("uploadsGetImages",{folder:i.currentFolder},function(e){i.images=e,i.isLoading=!1})})}}}),r=ace.edit("codeblock-editor");r.setTheme("ace/theme/tomorrow_night"),r.getSession().setMode("ace/mode/markdown"),r.setOption("fontSize","14px"),r.setOption("hScrollBarAlwaysVisible",!1),r.setOption("wrap",!0);var c=ace.require("ace/ext/modelist"),l=new Vue({el:"#modal-editor-codeblock",data:{modes:c.modesByName,modeSelected:"text"},watch:{modeSelected:function(e,t){d(e).done(function(){ace.require("ace/mode/"+e),r.getSession().setMode("ace/mode/"+e)})}},methods:{cancel:function(t){n=!1,e("#modal-editor-codeblock").slideUp()},insertCode:function(e){o.codemirror.doc.somethingSelected()&&o.codemirror.execCommand("singleSelection");var t="\n```"+l.modeSelected+"\n"+r.getValue()+"\n```\n";o.codemirror.doc.replaceSelection(t),l.cancel()}}}),s=[],d=function(t){return e.ajax({url:"/js/ace/mode-"+t+".js",dataType:"script",cache:!0,beforeSend:function(){if(_.includes(s,t))return!1},success:function(){s.push(t)}})};o=new SimpleMDE({autofocus:!0,autoDownloadFontAwesome:!1,element:e("#mk-editor").get(0),placeholder:"Enter Markdown formatted content here...",spellChecker:!1,status:!1,toolbar:[{name:"bold",action:SimpleMDE.toggleBold,className:"fa fa-bold",title:"Bold"},{name:"italic",action:SimpleMDE.toggleItalic,className:"fa fa-italic",title:"Italic"},{name:"strikethrough",action:SimpleMDE.toggleStrikethrough,className:"fa fa-strikethrough",title:"Strikethrough"},"|",{name:"heading-1",action:SimpleMDE.toggleHeading1,className:"fa fa-header fa-header-x fa-header-1",title:"Big Heading"},{name:"heading-2",action:SimpleMDE.toggleHeading2,className:"fa fa-header fa-header-x fa-header-2",title:"Medium Heading"},{name:"heading-3",action:SimpleMDE.toggleHeading3,className:"fa fa-header fa-header-x fa-header-3",title:"Small Heading"},{name:"quote",action:SimpleMDE.toggleBlockquote,className:"fa fa-quote-left",title:"Quote"},"|",{name:"unordered-list",action:SimpleMDE.toggleUnorderedList,className:"fa fa-list-ul",title:"Bullet List"},{name:"ordered-list",action:SimpleMDE.toggleOrderedList,className:"fa fa-list-ol",title:"Numbered List"},"|",{name:"link",action:function(t){n||(n=!0,e("#modal-editor-link").slideToggle())},className:"fa fa-link",title:"Insert Link"},{name:"image",action:function(e){n||i.open()},className:"fa fa-image",title:"Insert Image"},{name:"file",action:function(e){},className:"fa fa-file-text-o",title:"Insert File"},"|",{name:"inline-code",action:function(e){if(!e.codemirror.doc.somethingSelected())return t.pushError("Invalid selection","You must select at least 1 character first.");var a=e.codemirror.doc.getSelections();a=_.map(a,function(e){return"`"+e+"`"}),e.codemirror.doc.replaceSelections(a)},className:"fa fa-terminal",title:"Inline Code"},{name:"code-block",action:function(t){n||(n=!0,o.codemirror.doc.somethingSelected()?r.setValue(o.codemirror.doc.getSelection()):r.setValue(""),e("#modal-editor-codeblock").slideDown(400,function(){r.resize(),r.focus()}))},className:"fa fa-code",title:"Code Block"},"|",{name:"table",action:function(e){},className:"fa fa-table",title:"Insert Table"},{name:"horizontal-rule",action:SimpleMDE.drawHorizontalRule,className:"fa fa-minus",title:"Horizontal Rule"}],shortcuts:{toggleBlockquote:null,toggleFullScreen:null}})}(),e(".btn-edit-save").on("click",function(a){e.ajax(window.location.href,{data:{markdown:o.value()},dataType:"json",method:"PUT"}).then(function(e,a,o){e.ok?window.location.assign("/"+n):t.pushError("Something went wrong",e.error)},function(e,a,o){t.pushError("Something went wrong","Save operation failed.")})})}()}if(e("#page-type-edit").length){var o;!function(){var n=e("#page-type-edit").data("entrypath");e(".btn-edit-discard").on("click",function(t){e("#modal-edit-discard").toggleClass("is-active")}),1===e("#mk-editor").length&&!function(){var n=!1,i=new Vue({el:"#modal-editor-image",data:{isLoading:!1,isLoadingText:"",newFolderName:"",newFolderShow:!1,folders:[],currentFolder:"",images:[]},methods:{open:function(){n=!0,e("#modal-editor-image").slideDown(),i.refreshFolders()},cancel:function(t){n=!1,e("#modal-editor-image").slideUp()},newFolder:function(e){i.newFolderShow=!0},newFolderDiscard:function(e){i.newFolderShow=!1},selectFolder:function(e){i.currentFolder=e,i.loadImages()},refreshFolders:function(){i.isLoading=!0,i.isLoadingText="Fetching folders list...",i.currentFolder="",Vue.nextTick(function(){a.emit("uploadsGetFolders",{},function(e){i.folders=e,i.loadImages()})})},loadImages:function(){i.isLoading=!0,i.isLoadingText="Fetching images...",Vue.nextTick(function(){a.emit("uploadsGetImages",{folder:i.currentFolder},function(e){i.images=e,i.isLoading=!1})})}}}),r=ace.edit("codeblock-editor");r.setTheme("ace/theme/tomorrow_night"),r.getSession().setMode("ace/mode/markdown"),r.setOption("fontSize","14px"),r.setOption("hScrollBarAlwaysVisible",!1),r.setOption("wrap",!0);var c=ace.require("ace/ext/modelist"),l=new Vue({el:"#modal-editor-codeblock",data:{modes:c.modesByName,modeSelected:"text"},watch:{modeSelected:function(e,t){d(e).done(function(){ace.require("ace/mode/"+e),r.getSession().setMode("ace/mode/"+e)})}},methods:{cancel:function(t){n=!1,e("#modal-editor-codeblock").slideUp()},insertCode:function(e){o.codemirror.doc.somethingSelected()&&o.codemirror.execCommand("singleSelection");var t="\n```"+l.modeSelected+"\n"+r.getValue()+"\n```\n";o.codemirror.doc.replaceSelection(t),l.cancel()}}}),s=[],d=function(t){return e.ajax({url:"/js/ace/mode-"+t+".js",dataType:"script",cache:!0,beforeSend:function(){if(_.includes(s,t))return!1},success:function(){s.push(t)}})};o=new SimpleMDE({autofocus:!0,autoDownloadFontAwesome:!1,element:e("#mk-editor").get(0),placeholder:"Enter Markdown formatted content here...",spellChecker:!1,status:!1,toolbar:[{name:"bold",action:SimpleMDE.toggleBold,className:"fa fa-bold",title:"Bold"},{name:"italic",action:SimpleMDE.toggleItalic,className:"fa fa-italic",title:"Italic"},{name:"strikethrough",action:SimpleMDE.toggleStrikethrough,className:"fa fa-strikethrough",title:"Strikethrough"},"|",{name:"heading-1",action:SimpleMDE.toggleHeading1,className:"fa fa-header fa-header-x fa-header-1",title:"Big Heading"},{name:"heading-2",action:SimpleMDE.toggleHeading2,className:"fa fa-header fa-header-x fa-header-2",title:"Medium Heading"},{name:"heading-3",action:SimpleMDE.toggleHeading3,className:"fa fa-header fa-header-x fa-header-3",title:"Small Heading"},{name:"quote",action:SimpleMDE.toggleBlockquote,className:"fa fa-quote-left",title:"Quote"},"|",{name:"unordered-list",action:SimpleMDE.toggleUnorderedList,className:"fa fa-list-ul",title:"Bullet List"},{name:"ordered-list",action:SimpleMDE.toggleOrderedList,className:"fa fa-list-ol",title:"Numbered List"},"|",{name:"link",action:function(t){n||(n=!0,e("#modal-editor-link").slideToggle())},className:"fa fa-link",title:"Insert Link"},{name:"image",action:function(e){n||i.open()},className:"fa fa-image",title:"Insert Image"},{name:"file",action:function(e){},className:"fa fa-file-text-o",title:"Insert File"},"|",{name:"inline-code",action:function(e){if(!e.codemirror.doc.somethingSelected())return t.pushError("Invalid selection","You must select at least 1 character first.");var a=e.codemirror.doc.getSelections();a=_.map(a,function(e){return"`"+e+"`"}),e.codemirror.doc.replaceSelections(a)},className:"fa fa-terminal",title:"Inline Code"},{name:"code-block",action:function(t){n||(n=!0,o.codemirror.doc.somethingSelected()?r.setValue(o.codemirror.doc.getSelection()):r.setValue(""),e("#modal-editor-codeblock").slideDown(400,function(){r.resize(),r.focus()}))},className:"fa fa-code",title:"Code Block"},"|",{name:"table",action:function(e){},className:"fa fa-table",title:"Insert Table"},{name:"horizontal-rule",action:SimpleMDE.drawHorizontalRule,className:"fa fa-minus",title:"Horizontal Rule"}],shortcuts:{toggleBlockquote:null,toggleFullScreen:null}})}(),e(".btn-edit-save").on("click",function(a){e.ajax(window.location.href,{data:{markdown:o.value()},dataType:"json",method:"PUT"}).then(function(e,a,o){e.ok?window.location.assign("/"+n):t.pushError("Something went wrong",e.error)},function(e,a,o){t.pushError("Something went wrong","Save operation failed.")})})}()}if(e("#page-type-source").length){var n;!function(){n=ace.edit("source-display"),n.setTheme("ace/theme/tomorrow_night"),n.getSession().setMode("ace/mode/markdown"),n.setReadOnly(!0),n.renderer.updateFull();var a="home"!==e("#page-type-source").data("entrypath")?e("#page-type-source").data("entrypath"):"",o=a+"/new-page";e(".btn-create-prompt").on("click",function(t){e("#txt-create-prompt").val(o),e("#modal-create-prompt").toggleClass("is-active"),setInputSelection(e("#txt-create-prompt").get(0),a.length+1,o.length),e("#txt-create-prompt").removeClass("is-danger").next().addClass("is-hidden")}),e("#txt-create-prompt").on("keypress",function(t){13===t.which&&e(".btn-create-go").trigger("click")}),e(".btn-create-go").on("click",function(t){var a=makeSafePath(e("#txt-create-prompt").val());_.isEmpty(a)?e("#txt-create-prompt").addClass("is-danger").next().removeClass("is-hidden"):(e("#txt-create-prompt").parent().addClass("is-loading"),window.location.assign("/create/"+a))}),""!==a&&e(".btn-move-prompt").removeClass("is-hidden");var i=_.lastIndexOf(a,"/")+1;e(".btn-move-prompt").on("click",function(t){e("#txt-move-prompt").val(a),e("#modal-move-prompt").toggleClass("is-active"),setInputSelection(e("#txt-move-prompt").get(0),i,a.length),e("#txt-move-prompt").removeClass("is-danger").next().addClass("is-hidden")}),e("#txt-move-prompt").on("keypress",function(t){13===t.which&&e(".btn-move-go").trigger("click")}),e(".btn-move-go").on("click",function(o){var n=makeSafePath(e("#txt-move-prompt").val());_.isEmpty(n)||n===a||"home"===n?e("#txt-move-prompt").addClass("is-danger").next().removeClass("is-hidden"):(e("#txt-move-prompt").parent().addClass("is-loading"),e.ajax(window.location.href,{data:{move:n},dataType:"json",method:"PUT"}).then(function(e,a,o){e.ok?window.location.assign("/"+n):t.pushError("Something went wrong",e.error)},function(e,a,o){t.pushError("Something went wrong","Save operation failed.")}))})}()}});var Alerts=function(){function e(){_classCallCheck(this,e);var t=this;t.mdl=new Vue({el:"#alerts",data:{children:[]},methods:{acknowledge:function(e){t.close(e)}}}),t.uidNext=1}return _createClass(e,[{key:"push",value:function(e){var t=this,a=_.defaults(e,{_uid:t.uidNext,class:"is-info",message:"---",sticky:!1,title:"---"});t.mdl.children.push(a),a.sticky||_.delay(function(){t.close(a._uid)},5e3),t.uidNext++}},{key:"pushError",value:function(e,t){this.push({class:"is-danger",message:t,sticky:!1,title:e})}},{key:"pushSuccess",value:function(e,t){this.push({class:"is-success",message:t,sticky:!1,title:e})}},{key:"close",value:function(e){var t=this,a=_.findIndex(t.mdl.children,["_uid",e]),o=_.nth(t.mdl.children,a);a>=0&&o&&(o.class+=" exit",t.mdl.children.$set(a,o),_.delay(function(){t.mdl.children.$remove(o)},500))}}]),e}();
\ No newline at end of file
......@@ -2,23 +2,54 @@
let vueImage = new Vue({
el: '#modal-editor-image',
data: {
modeSelected: 'text'
isLoading: false,
isLoadingText: '',
newFolderName: '',
newFolderShow: false,
folders: [],
currentFolder: '',
images: []
},
methods: {
open: () => {
mdeModalOpenState = true;
$('#modal-editor-image').slideDown();
vueImage.refreshFolders();
},
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();
newFolder: (ev) => {
vueImage.newFolderShow = true;
},
newFolderDiscard: (ev) => {
vueImage.newFolderShow = false;
},
selectFolder: (fldName) => {
vueImage.currentFolder = fldName;
vueImage.loadImages();
},
refreshFolders: () => {
vueImage.isLoading = true;
vueImage.isLoadingText = 'Fetching folders list...';
vueImage.currentFolder = '';
Vue.nextTick(() => {
socket.emit('uploadsGetFolders', { }, (data) => {
vueImage.folders = data;
vueImage.loadImages();
});
});
},
loadImages: () => {
vueImage.isLoading = true;
vueImage.isLoadingText = 'Fetching images...';
Vue.nextTick(() => {
socket.emit('uploadsGetImages', { folder: vueImage.currentFolder }, (data) => {
vueImage.images = data;
vueImage.isLoading = false;
});
});
}
}
});
\ No newline at end of file
......@@ -90,8 +90,7 @@ if($('#mk-editor').length === 1) {
name: "image",
action: (editor) => {
if(!mdeModalOpenState) {
mdeModalOpenState = true;
$('#modal-editor-image').slideDown();
vueImage.open();
}
},
className: "fa fa-image",
......
......@@ -33,6 +33,38 @@
}
.editor-modal-load {
display: flex;
align-items: center;
opacity: 0;
transition: opacity .5s ease;
span {
font-size: 12px;
color: $blue;
}
i {
margin-left: 10px;
width: 32px;
height: 32px;
display: flex;
justify-content: center;
align-items: center;
&::before {
content: " ";
@include spinner($blue,0.5s,24px);
}
}
&.is-active {
opacity: 1;
}
}
.CodeMirror {
border-left: none;
border-right: none;
......
......@@ -14,6 +14,17 @@
}
.menu {
.menu-list a, .menu-nav a {
display: flex;
align-items: center;
}
.menu-list .icon {
margin-right: 8px
}
}
.section.is-small {
padding: 20px 20px;
}
......
......@@ -6,7 +6,7 @@ var loki = require('lokijs'),
Promise = require('bluebird'),
_ = require('lodash');
var cols = ['User','Entry'];
var cols = ['User', 'Entry'];
/**
* Loki.js module
......
......@@ -119,7 +119,7 @@ module.exports = {
winston.error('Git remote error!');
throw err;
}).then(() => {
winston.info('[GIT] Git repository is now ready.');
winston.info('[GIT] Git repository is OK.');
return true;
});
......
......@@ -9,10 +9,43 @@ var fs = require('fs'),
*
* @param {Object} appconfig The application configuration
*/
module.exports = (appconfig) => {
module.exports = {
_uploadsPath: './repo/uploads',
_uploadsFolders: [],
/**
* Initialize Local Data Storage model
*
* @param {Object} appconfig The application config
* @return {Object} Local Data Storage model instance
*/
init(appconfig, skipFolderCreation = false) {
let self = this;
self._uploadsPath = path.join(ROOTPATH, appconfig.datadir.db, 'uploads');
// Create data directories
if(!skipFolderCreation) {
self.createBaseDirectories(appconfig);
}
return self;
},
/**
* Creates a base directories (Synchronous).
*
* @param {Object} appconfig The application config
* @return {Void} Void
*/
createBaseDirectories(appconfig) {
winston.info('[SERVER] Create data directories if they don\'t exist...');
try {
fs.mkdirSync(appconfig.datadir.db);
} catch (err) {
......@@ -31,4 +64,41 @@ module.exports = (appconfig) => {
}
}
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.');
return;
},
/**
* Sets the uploads folders.
*
* @param {Array<String>} arrFolders The arr folders
* @return {Void} Void
*/
setUploadsFolders(arrFolders) {
this._uploadsFolders = arrFolders;
return;
},
/**
* Gets the uploads folders.
*
* @return {Array<String>} The uploads folders.
*/
getUploadsFolders() {
return this._uploadsFolders;
}
};
\ No newline at end of file
......@@ -36,7 +36,7 @@
"bcryptjs-then": "^1.0.1",
"bluebird": "^3.4.6",
"body-parser": "^1.15.2",
"bson": "^0.5.4",
"bson": "^0.5.5",
"cheerio": "^0.22.0",
"child-process-promise": "^2.1.3",
"compression": "^1.6.2",
......@@ -54,13 +54,13 @@
"fs-extra": "^0.30.0",
"git-wrapper2-promise": "^0.2.9",
"highlight.js": "^9.6.0",
"i18next": "^3.4.1",
"i18next-express-middleware": "^1.0.1",
"i18next": "^3.4.2",
"i18next-express-middleware": "^1.0.2",
"i18next-node-fs-backend": "^0.1.2",
"js-yaml": "^3.6.1",
"lodash": "^4.15.0",
"lokijs": "^1.4.1",
"markdown-it": "^7.0.1",
"markdown-it": "^8.0.0",
"markdown-it-abbr": "^1.0.4",
"markdown-it-anchor": "^2.5.0",
"markdown-it-attrs": "^0.7.0",
......@@ -69,7 +69,7 @@
"markdown-it-external-links": "0.0.5",
"markdown-it-footnote": "^3.0.1",
"markdown-it-task-lists": "^1.4.1",
"moment": "^2.14.1",
"moment": "^2.15.0",
"moment-timezone": "^0.5.5",
"passport": "^0.3.2",
"passport-local": "^1.0.0",
......@@ -82,7 +82,7 @@
"snyk": "^1.19.1",
"socket.io": "^1.4.8",
"sticky-js": "^1.0.7",
"validator": "^5.6.0",
"validator": "^5.7.0",
"validator-as-promised": "^1.0.2",
"winston": "^2.2.0"
},
......
......@@ -25,7 +25,7 @@ winston.add(winston.transports.Console, {
winston.info('[SERVER] Requarks Wiki is initializing...');
var appconfig = require('./models/config')('./config.yml');
let lcdata = require('./models/localdata');
let lcdata = require('./models/localdata').init(appconfig, false);
global.db = require('./models/db')(appconfig);
global.git = require('./models/git').init(appconfig, false);
......
......@@ -4,18 +4,23 @@
.columns
.column
h3 Image
h3 Insert Image
.column.is-narrow.editor-modal-load(v-bind:class="{ 'is-active': isLoading }")
span {{ isLoadingText }}
i
.column.is-narrow
.control.is-grouped
p.control
a.button.is-dark.is-outlined(v-on:click="cancel")
a.button.is-dark.is-outlined(v-on:click="newFolder")
span.icon.is-small: i.fa.fa-folder
span New Folder
.control.has-addons
a.button.is-info.is-outlined(v-on:click="cancel")
a.button.is-info.is-outlined(v-on:click="uploadImage")
span.icon.is-small: i.fa.fa-upload
span Upload Image
a.button.is-info.is-outlined(v-on:click="cancel")
a.button.is-info.is-outlined(v-on:click="fetchFromUrl")
span.icon.is-small: i.fa.fa-download
span Fetch from URL
.column.is-narrow
......@@ -27,9 +32,36 @@
.columns
.column.is-one-quarter(style={'max-width':'350px'})
.box
.box(style={'max-height': '400px', overflow: 'auto', 'overflow-x': 'hidden'})
aside.menu
p.menu-label
| Folders
ul.menu-list
li
a(v-on:click="selectFolder('')", v-bind:class="{ 'is-active': currentFolder === '' }")
span.icon.is-small: i.fa.fa-folder-o
span /
li(v-for="fld in folders")
a(v-on:click="selectFolder(fld)", v-bind:class="{ 'is-active': currentFolder === fld }")
span.icon.is-small: i.fa.fa-folder
span / {{ fld }}
.column
| Files
figure.image.is-128x128
img(src='http://placehold.it/128x128')
.modal(v-bind:class="{ 'is-active': newFolderShow }")
.modal-background
.modal-container
.modal-content
.card.is-fullwidth
header.card-header
p.card-header-title New Folder
.card-content
.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!
footer.card-footer
a.card-footer-item(v-on:click="newFolderDiscard") Discard
a.card-footer-item(v-on:click="newFolderCreate") Create
\ No newline at end of file
......@@ -39,6 +39,7 @@ global.internalAuth = require('./lib/internalAuth').init(process.argv[2]);;
winston.info('[WS] WS Server is initializing...');
var appconfig = require('./models/config')('./config.yml');
let lcdata = require('./models/localdata').init(appconfig, true);
global.entries = require('./models/entries').init(appconfig);
global.mark = require('./models/markdown');
......@@ -104,6 +105,10 @@ server.listen(appconfig.wsPort, () => {
io.on('connection', (socket) => {
//-----------------------------------------
// SEARCH
//-----------------------------------------
socket.on('searchAdd', (data) => {
if(internalAuth.validateKey(data.auth)) {
search.add(data.content);
......@@ -122,11 +127,25 @@ io.on('connection', (socket) => {
});
});
});
//-----------------------------------------
// UPLOADS
//-----------------------------------------
socket.on('uploadsSetFolders', (data, cb) => {
if(internalAuth.validateKey(data.auth)) {
lcdata.setUploadsFolders(data.content);
}
});
/*setTimeout(() => {
search._si.searchAsync({ query: { AND: [{'*': ['unit']}] }}).then((stuff) => { console.log(stuff.hits); });
}, 8000);*/
socket.on('uploadsGetFolders', (data, cb) => {
cb(lcdata.getUploadsFolders());
});
socket.on('uploadsGetImages', (data, cb) => {
cb([]);
});
});
// ----------------------------------------
// Shutdown gracefully
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment