Search results picker + create/update index update
This commit is contained in:
1 parent
dca6b71610
commit
48e2afa5c0
16 files changed
+169
-102
No files matched your search
@@ -68,6 +68,7 @@ var job = new cron({
|
|||||||
winston.warn('[AGENT] Previous job has not completed gracefully or is still running! Skipping for now. (This is not normal, you should investigate)');
|
winston.warn('[AGENT] Previous job has not completed gracefully or is still running! Skipping for now. (This is not normal, you should investigate)');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
winston.info('[AGENT] Running all jobs...');
|
||||||
jobIsBusy = true;
|
jobIsBusy = true;
|
||||||
|
|
||||||
// Prepare async job collector
|
// Prepare async job collector
|
||||||
@@ -87,6 +88,10 @@ var job = new cron({
|
|||||||
//-> Stream all documents
|
//-> Stream all documents
|
||||||
|
|
||||||
let cacheJobs = [];
|
let cacheJobs = [];
|
||||||
|
let jobCbStreamDocs_resolve = null,
|
||||||
|
jobCbStreamDocs = new Promise((resolve, reject) => {
|
||||||
|
jobCbStreamDocs_resolve = resolve;
|
||||||
|
});
|
||||||
|
|
||||||
fs.walk(repoPath).on('data', function (item) {
|
fs.walk(repoPath).on('data', function (item) {
|
||||||
if(path.extname(item.path) === '.md') {
|
if(path.extname(item.path) === '.md') {
|
||||||
@@ -113,15 +118,10 @@ var job = new cron({
|
|||||||
|
|
||||||
}).then((fileStatus) => {
|
}).then((fileStatus) => {
|
||||||
|
|
||||||
//-> Update search index
|
//-> Update cache and search index
|
||||||
|
|
||||||
if(fileStatus !== 'active') {
|
if(fileStatus !== 'active') {
|
||||||
return entries.fetchIndexableVersion(entryPath).then((content) => {
|
return entries.updateCache(entryPath);
|
||||||
ws.emit('searchAdd', {
|
|
||||||
auth: WSInternalKey,
|
|
||||||
content
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -131,9 +131,11 @@ var job = new cron({
|
|||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}).on('end', () => {
|
||||||
|
jobCbStreamDocs_resolve(Promise.all(cacheJobs));
|
||||||
});
|
});
|
||||||
|
|
||||||
return Promise.all(cacheJobs);
|
return jobCbStreamDocs;
|
||||||
|
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
@@ -143,7 +145,7 @@ var job = new cron({
|
|||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
Promise.all(jobs).then(() => {
|
Promise.all(jobs).then(() => {
|
||||||
winston.info('[AGENT] All jobs completed successfully! Going to sleep for now...');
|
winston.info('[AGENT] All jobs completed successfully! Going to sleep for now.');
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
winston.error('[AGENT] One or more jobs have failed: ', err);
|
winston.error('[AGENT] One or more jobs have failed: ', err);
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
@@ -161,8 +163,8 @@ var job = new cron({
|
|||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
ws.on('connect', function () {
|
ws.on('connect', function () {
|
||||||
job.start();
|
|
||||||
winston.info('[AGENT] Background Agent started successfully! [RUNNING]');
|
winston.info('[AGENT] Background Agent started successfully! [RUNNING]');
|
||||||
|
job.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
ws.on('connect_error', function () {
|
ws.on('connect_error', function () {
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
@charset "UTF-8";.card,.highlight,.highlight pre,.textarea,embed,img,object{max-width:100%}a,hr{padding:0}a,button,input[type=button],input[type=file],input[type=submit],label{cursor:pointer}a,button,input,select,textarea{margin:0}a,input[type=radio],input[type=checkbox]{vertical-align:baseline}a:hover,strong,table th{color:#222324}body,pre,pre code{color:#69707a}.container,sub,sup{position:relative}.button,.delete,.input,.modal-close,.progress,.select select,.textarea{-moz-appearance:none;-webkit-appearance:none}.heading,.menu-label{letter-spacing:1px;text-transform:uppercase}.animated{-webkit-animation-duration:1s;animation-duration:1s;-webkit-animation-fill-mode:both;animation-fill-mode:both}.animated.infinite{-webkit-animation-iteration-count:infinite;animation-iteration-count:infinite}.animated.hinge{-webkit-animation-duration:2s;animation-duration:2s}.animated.bounceIn,.animated.bounceOut,.animated.flipOutX,.animated.flipOutY{-webkit-animation-duration:.75s;animation-duration:.75s}@-webkit-keyframes bounce{0%,20%,53%,80%,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1);-webkit-transform:translateZ(0);transform:translateZ(0)}40%,43%{-webkit-transform:translate3d(0,-30px,0);transform:translate3d(0,-30px,0)}40%,43%,70%{-webkit-animation-timing-function:cubic-bezier(.755,.05,.855,.06);animation-timing-function:cubic-bezier(.755,.05,.855,.06)}70%{-webkit-transform:translate3d(0,-15px,0);transform:translate3d(0,-15px,0)}90%{-webkit-transform:translate3d(0,-4px,0);transform:translate3d(0,-4px,0)}}@keyframes bounce{0%,20%,53%,80%,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1);-webkit-transform:translateZ(0);transform:translateZ(0)}40%,43%{-webkit-transform:translate3d(0,-30px,0);transform:translate3d(0,-30px,0)}40%,43%,70%{-webkit-animation-timing-function:cubic-bezier(.755,.05,.855,.06);animation-timing-function:cubic-bezier(.755,.05,.855,.06)}70%{-webkit-transform:translate3d(0,-15px,0);transform:translate3d(0,-15px,0)}90%{-webkit-transform:translate3d(0,-4px,0);transform:translate3d(0,-4px,0)}}.bounce{-webkit-animation-name:bounce;animation-name:bounce;-webkit-transform-origin:center bottom;transform-origin:center bottom}@-webkit-keyframes flash{0%,50%,to{opacity:1}25%,75%{opacity:0}}@keyframes flash{0%,50%,to{opacity:1}25%,75%{opacity:0}}.flash{-webkit-animation-name:flash;animation-name:flash}@-webkit-keyframes pulse{0%,to{-webkit-transform:scaleX(1);transform:scaleX(1)}50%{-webkit-transform:scale3d(1.05,1.05,1.05);transform:scale3d(1.05,1.05,1.05)}}@keyframes pulse{0%,to{-webkit-transform:scaleX(1);transform:scaleX(1)}50%{-webkit-transform:scale3d(1.05,1.05,1.05);transform:scale3d(1.05,1.05,1.05)}}.pulse{-webkit-animation-name:pulse;animation-name:pulse}@-webkit-keyframes rubberBand{0%,to{-webkit-transform:scaleX(1);transform:scaleX(1)}30%{-webkit-transform:scale3d(1.25,.75,1);transform:scale3d(1.25,.75,1)}40%{-webkit-transform:scale3d(.75,1.25,1);transform:scale3d(.75,1.25,1)}50%{-webkit-transform:scale3d(1.15,.85,1);transform:scale3d(1.15,.85,1)}65%{-webkit-transform:scale3d(.95,1.05,1);transform:scale3d(.95,1.05,1)}75%{-webkit-transform:scale3d(1.05,.95,1);transform:scale3d(1.05,.95,1)}}@keyframes rubberBand{0%,to{-webkit-transform:scaleX(1);transform:scaleX(1)}30%{-webkit-transform:scale3d(1.25,.75,1);transform:scale3d(1.25,.75,1)}40%{-webkit-transform:scale3d(.75,1.25,1);transform:scale3d(.75,1.25,1)}50%{-webkit-transform:scale3d(1.15,.85,1);transform:scale3d(1.15,.85,1)}65%{-webkit-transform:scale3d(.95,1.05,1);transform:scale3d(.95,1.05,1)}75%{-webkit-transform:scale3d(1.05,.95,1);transform:scale3d(1.05,.95,1)}}.rubberBand{-webkit-animation-name:rubberBand;animation-name:rubberBand}@-webkit-keyframes shake{0%,to{-webkit-transform:translateZ(0);transform:translateZ(0)}10%,30%,50%,70%,90%{-webkit-transform:translate3d(-10px,0,0);transform:translate3d(-10px,0,0)}20%,40%,60%,80%{-webkit-transform:translate3d(10px,0,0);transform:translate3d(10px,0,0)}}@keyframes shake{0%,to{-webkit-transform:translateZ(0);transform:translateZ(0)}10%,30%,50%,70%,90%{-webkit-transform:translate3d(-10px,0,0);transform:translate3d(-10px,0,0)}20%,40%,60%,80%{-webkit-transform:translate3d(10px,0,0);transform:translate3d(10px,0,0)}}.shake{-webkit-animation-name:shake;animation-name:shake}@-webkit-keyframes headShake{0%{-webkit-transform:translateX(0);transform:translateX(0)}6.5%{-webkit-transform:translateX(-6px) rotateY(-9deg);transform:translateX(-6px) rotateY(-9deg)}18.5%{-webkit-transform:translateX(5px) rotateY(7deg);transform:translateX(5px) rotateY(7deg)}31.5%{-webkit-transform:translateX(-3px) rotateY(-5deg);transform:translateX(-3px) rotateY(-5deg)}43.5%{-webkit-transform:translateX(2px) rotateY(3deg);transform:translateX(2px) rotateY(3deg)}50%{-webkit-transform:translateX(0);transform:translateX(0)}}@keyframes headShake{0%{-webkit-transform:translateX(0);transform:trLine truncated
|
@charset "UTF-8";.card,.highlight,.highlight pre,.textarea,embed,img,object{max-width:100%}a,hr{padding:0}a,button,input[type=button],input[type=file],input[type=submit],label{cursor:pointer}a,button,input,select,textarea{margin:0}a,input[type=radio],input[type=checkbox]{vertical-align:baseline}a:hover,strong,table th{color:#222324}body,pre,pre code{color:#69707a}.container,sub,sup{position:relative}.button,.delete,.input,.modal-close,.progress,.select select,.textarea{-moz-appearance:none;-webkit-appearance:none}.heading,.menu-label{letter-spacing:1px;text-transform:uppercase}.animated{-webkit-animation-duration:1s;animation-duration:1s;-webkit-animation-fill-mode:both;animation-fill-mode:both}.animated.infinite{-webkit-animation-iteration-count:infinite;animation-iteration-count:infinite}.animated.hinge{-webkit-animation-duration:2s;animation-duration:2s}.animated.bounceIn,.animated.bounceOut,.animated.flipOutX,.animated.flipOutY{-webkit-animation-duration:.75s;animation-duration:.75s}@-webkit-keyframes bounce{0%,20%,53%,80%,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1);-webkit-transform:translateZ(0);transform:translateZ(0)}40%,43%{-webkit-transform:translate3d(0,-30px,0);transform:translate3d(0,-30px,0)}40%,43%,70%{-webkit-animation-timing-function:cubic-bezier(.755,.05,.855,.06);animation-timing-function:cubic-bezier(.755,.05,.855,.06)}70%{-webkit-transform:translate3d(0,-15px,0);transform:translate3d(0,-15px,0)}90%{-webkit-transform:translate3d(0,-4px,0);transform:translate3d(0,-4px,0)}}@keyframes bounce{0%,20%,53%,80%,to{-webkit-animation-timing-function:cubic-bezier(.215,.61,.355,1);animation-timing-function:cubic-bezier(.215,.61,.355,1);-webkit-transform:translateZ(0);transform:translateZ(0)}40%,43%{-webkit-transform:translate3d(0,-30px,0);transform:translate3d(0,-30px,0)}40%,43%,70%{-webkit-animation-timing-function:cubic-bezier(.755,.05,.855,.06);animation-timing-function:cubic-bezier(.755,.05,.855,.06)}70%{-webkit-transform:translate3d(0,-15px,0);transform:translate3d(0,-15px,0)}90%{-webkit-transform:translate3d(0,-4px,0);transform:translate3d(0,-4px,0)}}.bounce{-webkit-animation-name:bounce;animation-name:bounce;-webkit-transform-origin:center bottom;transform-origin:center bottom}@-webkit-keyframes flash{0%,50%,to{opacity:1}25%,75%{opacity:0}}@keyframes flash{0%,50%,to{opacity:1}25%,75%{opacity:0}}.flash{-webkit-animation-name:flash;animation-name:flash}@-webkit-keyframes pulse{0%,to{-webkit-transform:scaleX(1);transform:scaleX(1)}50%{-webkit-transform:scale3d(1.05,1.05,1.05);transform:scale3d(1.05,1.05,1.05)}}@keyframes pulse{0%,to{-webkit-transform:scaleX(1);transform:scaleX(1)}50%{-webkit-transform:scale3d(1.05,1.05,1.05);transform:scale3d(1.05,1.05,1.05)}}.pulse{-webkit-animation-name:pulse;animation-name:pulse}@-webkit-keyframes rubberBand{0%,to{-webkit-transform:scaleX(1);transform:scaleX(1)}30%{-webkit-transform:scale3d(1.25,.75,1);transform:scale3d(1.25,.75,1)}40%{-webkit-transform:scale3d(.75,1.25,1);transform:scale3d(.75,1.25,1)}50%{-webkit-transform:scale3d(1.15,.85,1);transform:scale3d(1.15,.85,1)}65%{-webkit-transform:scale3d(.95,1.05,1);transform:scale3d(.95,1.05,1)}75%{-webkit-transform:scale3d(1.05,.95,1);transform:scale3d(1.05,.95,1)}}@keyframes rubberBand{0%,to{-webkit-transform:scaleX(1);transform:scaleX(1)}30%{-webkit-transform:scale3d(1.25,.75,1);transform:scale3d(1.25,.75,1)}40%{-webkit-transform:scale3d(.75,1.25,1);transform:scale3d(.75,1.25,1)}50%{-webkit-transform:scale3d(1.15,.85,1);transform:scale3d(1.15,.85,1)}65%{-webkit-transform:scale3d(.95,1.05,1);transform:scale3d(.95,1.05,1)}75%{-webkit-transform:scale3d(1.05,.95,1);transform:scale3d(1.05,.95,1)}}.rubberBand{-webkit-animation-name:rubberBand;animation-name:rubberBand}@-webkit-keyframes shake{0%,to{-webkit-transform:translateZ(0);transform:translateZ(0)}10%,30%,50%,70%,90%{-webkit-transform:translate3d(-10px,0,0);transform:translate3d(-10px,0,0)}20%,40%,60%,80%{-webkit-transform:translate3d(10px,0,0);transform:translate3d(10px,0,0)}}@keyframes shake{0%,to{-webkit-transform:translateZ(0);transform:translateZ(0)}10%,30%,50%,70%,90%{-webkit-transform:translate3d(-10px,0,0);transform:translate3d(-10px,0,0)}20%,40%,60%,80%{-webkit-transform:translate3d(10px,0,0);transform:translate3d(10px,0,0)}}.shake{-webkit-animation-name:shake;animation-name:shake}@-webkit-keyframes headShake{0%{-webkit-transform:translateX(0);transform:translateX(0)}6.5%{-webkit-transform:translateX(-6px) rotateY(-9deg);transform:translateX(-6px) rotateY(-9deg)}18.5%{-webkit-transform:translateX(5px) rotateY(7deg);transform:translateX(5px) rotateY(7deg)}31.5%{-webkit-transform:translateX(-3px) rotateY(-5deg);transform:translateX(-3px) rotateY(-5deg)}43.5%{-webkit-transform:translateX(2px) rotateY(3deg);transform:translateX(2px) rotateY(3deg)}50%{-webkit-transform:translateX(0);transform:translateX(0)}}@keyframes headShake{0%{-webkit-transform:translateX(0);transform:trLine truncated
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
"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 n=document.selection.createRange();n.collapse(!0),n.moveEnd("character",a),n.moveStart("character",t),n.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 n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,a,n){return a&&e(t.prototype,a),n&&e(t,n),t}}();jQuery(document).ready(function(e){e("a").smoothScroll({speed:400,offset:-20});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;if(alertsData&&_.forEach(alertsData,function(e){t.push(e)}),1===e("#mk-editor").length)var a=new SimpleMDE({autofocus:!0,autoDownloadFontAwesome:!1,element:e("#mk-editor").get(0),hideIcons:["heading","quote"],placeholder:"Enter Markdown formatted content here...",showIcons:["strikethrough","heading-1","heading-2","heading-3","code","table","horizontal-rule"],spellChecker:!1,status:!1});var n=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,a){e.length>=3?(t.searchactive=!0,t.searchload++,n.emit("search",{terms:e},function(e){t.searchres=e.match,t.searchsuggest=e.suggest,t.searchload>0&&t.searchload--})):(t.searchactive=!1,t.searchres=[],t.searchsuggest=[],t.searchload=0)},searchmoveidx:function(e,t){}},methods:{useSuggestion:function(e){t.searchq=e},closeSearch:function(){t.searchq="",t.searchactive=!1},moveSelectSearch:function(){},moveDownSearch:function(){t.searchmoveidx<t.searchmovearr&&t.searchmoveidx++},moveUpSearch:function(){t.searchmoveidx>0&&t.searchmoveidx--}}});e("main").on("click",t.closeSearch)}}),e("#page-type-view").length&&!function(){var t="home"!==e("#page-type-view").data("entrypath")?e("#page-type-view").data("entrypath")+"/":"",a=t+"new-page";e(".btn-create-prompt").on("click",function(n){e("#txt-create-prompt").val(a),e("#modal-create-prompt").toggleClass("is-active"),setInputSelection(e("#txt-create-prompt").get(0),t.length,a.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))})}(),e("#page-type-create").length&&(e(".btn-create-discard").on("click",function(t){e("#modal-create-discard").toggleClass("is-active")}),e(".btn-create-save").on("click",function(n){e.ajax(window.location.href,{data:{markdown:a.value()},dataType:"json",method:"PUT"}).then(function(a,n,o){a.ok?window.location.assign("/"+e("#page-type-create").data("entrypath")):t.pushError("Something went wrong",a.error)},function(e,a,n){t.pushError("Something went wrong","Save operation failed.")})})),e("#page-type-edit").length){e(".editor-toolbar").attr("data-margin-top",e("#header").height());new Sticky(".editor-toolbar");e(".btn-edit-discard").on("click",function(t){e("#modal-edit-discard").toggleClass("is-active")}),e(".btn-edit-save").on("click",function(n){e.ajax(window.location.href,{data:{markdown:a.value()},dataType:"json",method:"PUT"}).then(function(a,n,o){a.ok?window.location.assign("/"+e("#page-type-edit").data("entrypath")):t.pushError("Something went wrong",a.error)},function(e,a,n){t.pushError("Something went wrong","Save operation failed.")})})}if(e("#page-type-source").length){var o=ace.edit("source-display");o.setTheme("ace/theme/tomorrow_night"),o.getSession().setMode("ace/mode/markdown"),o.setReadOnly(!0),o.renderer.updateFull()}});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:"---"});Line truncated
|
"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 n=document.selection.createRange();n.collapse(!0),n.moveEnd("character",a),n.moveStart("character",t),n.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 n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,a,n){return a&&e(t.prototype,a),n&&e(t,n),t}}();jQuery(document).ready(function(e){e("a").smoothScroll({speed:400,offset:-20});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;if(alertsData&&_.forEach(alertsData,function(e){t.push(e)}),1===e("#mk-editor").length)var a=new SimpleMDE({autofocus:!0,autoDownloadFontAwesome:!1,element:e("#mk-editor").get(0),hideIcons:["heading","quote"],placeholder:"Enter Markdown formatted content here...",showIcons:["strikethrough","heading-1","heading-2","heading-3","code","table","horizontal-rule"],spellChecker:!1,status:!1});var n=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,a){t.searchmoveidx=0,e.length>=3?(t.searchactive=!0,t.searchload++,n.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 t="home"!==e("#page-type-view").data("entrypath")?e("#page-type-view").data("entrypath")+"/":"",a=t+"new-page";e(".btn-create-prompt").on("click",function(n){e("#txt-create-prompt").val(a),e("#modal-create-prompt").toggleClass("is-active"),setInputSelection(e("#txt-create-prompt").get(0),t.length,a.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))})}(),e("#page-type-create").length&&(e(".btn-create-discard").on("click",function(t){e("#modal-create-discard").toggleClass("is-active")}),e(".btn-create-save").on("click",function(n){e.ajax(window.location.href,{data:{markdown:a.value()},dataType:"json",method:"PUT"}).then(function(a,n,r){a.ok?window.location.assign("/"+e("#page-type-create").data("entrypath")):t.pushError("Something went wrong",a.error)},function(e,a,n){t.pushError("Something went wrong","Save operation failed.")})})),e("#page-type-edit").length){e(".editor-toolbar").attr("data-margin-top",e("#header").height());new Sticky(".editor-toolbar");e(".btn-edit-discard").on("click",function(t){e("#modal-edit-discard").toggleClass("is-active")}),e(".btn-edit-save").on("click",function(n){e.ajax(window.location.href,{data:{markdown:a.value()},dataType:"json",method:"PUT"}).then(function(a,n,r){a.ok?window.location.assign("/"+e("#page-type-edit").data("entrypath")):t.pushError("Something went wrong",a.error)},function(e,a,n){t.pushError("Something went wrong","Save operation failed.")})})}if(e("#page-type-source").length){var r=ace.edit("source-display");r.setTheme("ace/theme/tomorrow_night"),r.getSession().seLine truncated
|
||||||
@@ -27,24 +27,32 @@ jQuery( document ).ready(function( $ ) {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
searchq: (val, oldVal) => {
|
searchq: (val, oldVal) => {
|
||||||
searchmoveidx: 0;
|
vueHeader.searchmoveidx = 0;
|
||||||
if(val.length >= 3) {
|
if(val.length >= 3) {
|
||||||
vueHeader.searchactive = true;
|
vueHeader.searchactive = true;
|
||||||
vueHeader.searchload++;
|
vueHeader.searchload++;
|
||||||
socket.emit('search', { terms: val }, (data) => {
|
socket.emit('search', { terms: val }, (data) => {
|
||||||
vueHeader.searchres = data.match;
|
vueHeader.searchres = data.match;
|
||||||
vueHeader.searchsuggest = data.suggest;
|
vueHeader.searchsuggest = data.suggest;
|
||||||
|
vueHeader.searchmovearr = _.concat([], vueHeader.searchres, vueHeader.searchsuggest);
|
||||||
if(vueHeader.searchload > 0) { vueHeader.searchload--; }
|
if(vueHeader.searchload > 0) { vueHeader.searchload--; }
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
vueHeader.searchactive = false;
|
vueHeader.searchactive = false;
|
||||||
vueHeader.searchres = [];
|
vueHeader.searchres = [];
|
||||||
vueHeader.searchsuggest = [];
|
vueHeader.searchsuggest = [];
|
||||||
|
vueHeader.searchmovearr = [];
|
||||||
vueHeader.searchload = 0;
|
vueHeader.searchload = 0;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
searchmoveidx: (val, oldVal) => {
|
searchmoveidx: (val, oldVal) => {
|
||||||
|
if(val > 0) {
|
||||||
|
vueHeader.searchmovekey = (vueHeader.searchmovearr[val - 1].document) ?
|
||||||
|
'res.' + vueHeader.searchmovearr[val - 1].document.entryPath :
|
||||||
|
'sug.' + vueHeader.searchmovearr[val - 1];
|
||||||
|
} else {
|
||||||
|
vueHeader.searchmovekey = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -53,13 +61,20 @@ jQuery( document ).ready(function( $ ) {
|
|||||||
},
|
},
|
||||||
closeSearch: () => {
|
closeSearch: () => {
|
||||||
vueHeader.searchq = '';
|
vueHeader.searchq = '';
|
||||||
vueHeader.searchactive = false;
|
|
||||||
},
|
},
|
||||||
moveSelectSearch: () => {
|
moveSelectSearch: () => {
|
||||||
|
if(vueHeader.searchmoveidx < 1) { return; }
|
||||||
|
let i = vueHeader.searchmoveidx - 1;
|
||||||
|
|
||||||
|
if(vueHeader.searchmovearr[i].document) {
|
||||||
|
window.location.assign('/' + vueHeader.searchmovearr[i].document.entryPath);
|
||||||
|
} else {
|
||||||
|
vueHeader.searchq = vueHeader.searchmovearr[i];
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
moveDownSearch: () => {
|
moveDownSearch: () => {
|
||||||
if(vueHeader.searchmoveidx < vueHeader.searchmovearr) {
|
if(vueHeader.searchmoveidx < vueHeader.searchmovearr.length) {
|
||||||
vueHeader.searchmoveidx++;
|
vueHeader.searchmoveidx++;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ #alerts {
|
|||||||
top: 60px;
|
top: 60px;
|
||||||
right: 10px;
|
right: 10px;
|
||||||
width: 350px;
|
width: 350px;
|
||||||
z-index: 2;
|
z-index: 10;
|
||||||
text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
|
text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
|
||||||
|
|
||||||
.notification {
|
.notification {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ router.get('/create/*', (req, res, next) => {
|
|||||||
|
|
||||||
entries.exists(safePath).then((docExists) => {
|
entries.exists(safePath).then((docExists) => {
|
||||||
if(!docExists) {
|
if(!docExists) {
|
||||||
entries.getStarter(safePath).then((contents) => {
|
return entries.getStarter(safePath).then((contents) => {
|
||||||
|
|
||||||
let pageData = {
|
let pageData = {
|
||||||
markdown: contents,
|
markdown: contents,
|
||||||
@@ -80,7 +80,9 @@ router.get('/create/*', (req, res, next) => {
|
|||||||
path: safePath
|
path: safePath
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return res.render('pages/create', { pageData });
|
res.render('pages/create', { pageData });
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
throw new Error('Could not load starter content!');
|
throw new Error('Could not load starter content!');
|
||||||
|
|||||||
+39
-32
@@ -156,7 +156,7 @@ module.exports = {
|
|||||||
// Cache to disk
|
// Cache to disk
|
||||||
|
|
||||||
if(options.cache) {
|
if(options.cache) {
|
||||||
let cacheData = BSON.serialize(pageData, false, false, false);
|
let cacheData = BSON.serialize(_.pick(pageData, ['html', 'meta', 'tree', 'parent']), false, false, false);
|
||||||
return fs.writeFileAsync(cpath, cacheData).catch((err) => {
|
return fs.writeFileAsync(cpath, cacheData).catch((err) => {
|
||||||
winston.error('Unable to write to cache! Performance may be affected.');
|
winston.error('Unable to write to cache! Performance may be affected.');
|
||||||
return true;
|
return true;
|
||||||
@@ -177,34 +177,6 @@ module.exports = {
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches a text version of a Markdown-formatted document
|
|
||||||
*
|
|
||||||
* @param {String} entryPath The entry path
|
|
||||||
* @return {String} Text-only version
|
|
||||||
*/
|
|
||||||
fetchIndexableVersion(entryPath) {
|
|
||||||
|
|
||||||
let self = this;
|
|
||||||
|
|
||||||
return self.fetchOriginal(entryPath, {
|
|
||||||
parseMarkdown: false,
|
|
||||||
parseMeta: true,
|
|
||||||
parseTree: false,
|
|
||||||
includeMarkdown: true,
|
|
||||||
includeParentInfo: true,
|
|
||||||
cache: false
|
|
||||||
}).then((pageData) => {
|
|
||||||
return {
|
|
||||||
entryPath,
|
|
||||||
meta: pageData.meta,
|
|
||||||
parent: pageData.parent || {},
|
|
||||||
text: mark.removeMarkdown(pageData.markdown)
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse raw url path and make it safe
|
* Parse raw url path and make it safe
|
||||||
*
|
*
|
||||||
@@ -314,13 +286,48 @@ module.exports = {
|
|||||||
return fs.statAsync(fpath).then((st) => {
|
return fs.statAsync(fpath).then((st) => {
|
||||||
if(st.isFile()) {
|
if(st.isFile()) {
|
||||||
return self.makePersistent(entryPath, contents).then(() => {
|
return self.makePersistent(entryPath, contents).then(() => {
|
||||||
return self.fetchOriginal(entryPath, {});
|
return self.updateCache(entryPath);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return Promise.reject(new Error('Entry does not exist!'));
|
return Promise.reject(new Error('Entry does not exist!'));
|
||||||
}
|
}
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
return Promise.reject(new Error('Entry does not exist!'));
|
winston.error(err);
|
||||||
|
return Promise.reject(new Error('Failed to save document.'));
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update local cache and search index
|
||||||
|
*
|
||||||
|
* @param {String} entryPath The entry path
|
||||||
|
* @return {Promise} Promise of the operation
|
||||||
|
*/
|
||||||
|
updateCache(entryPath) {
|
||||||
|
|
||||||
|
let self = this;
|
||||||
|
|
||||||
|
return self.fetchOriginal(entryPath, {
|
||||||
|
parseMarkdown: true,
|
||||||
|
parseMeta: true,
|
||||||
|
parseTree: true,
|
||||||
|
includeMarkdown: true,
|
||||||
|
includeParentInfo: true,
|
||||||
|
cache: true
|
||||||
|
}).then((pageData) => {
|
||||||
|
return {
|
||||||
|
entryPath,
|
||||||
|
meta: pageData.meta,
|
||||||
|
parent: pageData.parent || {},
|
||||||
|
text: mark.removeMarkdown(pageData.markdown)
|
||||||
|
};
|
||||||
|
}).then((content) => {
|
||||||
|
ws.emit('searchAdd', {
|
||||||
|
auth: WSInternalKey,
|
||||||
|
content
|
||||||
|
});
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -339,7 +346,7 @@ module.exports = {
|
|||||||
return self.exists(entryPath).then((docExists) => {
|
return self.exists(entryPath).then((docExists) => {
|
||||||
if(!docExists) {
|
if(!docExists) {
|
||||||
return self.makePersistent(entryPath, contents).then(() => {
|
return self.makePersistent(entryPath, contents).then(() => {
|
||||||
return self.fetchOriginal(entryPath, {});
|
return self.updateCache(entryPath);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return Promise.reject(new Error('Entry already exists!'));
|
return Promise.reject(new Error('Entry already exists!'));
|
||||||
|
|||||||
+3
-1
@@ -195,7 +195,9 @@ module.exports = {
|
|||||||
commitMsg = (isTracked) ? 'Updated ' + gitFilePath : 'Added ' + gitFilePath;
|
commitMsg = (isTracked) ? 'Updated ' + gitFilePath : 'Added ' + gitFilePath;
|
||||||
return self._git.add(gitFilePath);
|
return self._git.add(gitFilePath);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return self._git.commit(commitMsg);
|
return self._git.commit(commitMsg).catch((err) => {
|
||||||
|
if(_.includes(err.stdout, 'nothing to commit')) { return true; }
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+55
-35
@@ -100,42 +100,62 @@ module.exports = {
|
|||||||
|
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
return self._si.addAsync({
|
return self._si.searchAsync({
|
||||||
entryPath: content.entryPath,
|
query: {
|
||||||
title: content.meta.title,
|
AND: [{ 'entryPath': [content.entryPath] }]
|
||||||
subtitle: content.meta.subtitle || '',
|
}
|
||||||
parent: content.parent.title || '',
|
}).then((results) => {
|
||||||
content: content.text || ''
|
|
||||||
}, {
|
if(results.totalHits > 0) {
|
||||||
fieldOptions: [{
|
let delIds = _.map(results.hits, 'id');
|
||||||
fieldName: 'entryPath',
|
return self._si.delAsync(delIds);
|
||||||
searchable: true,
|
} else {
|
||||||
weight: 2
|
return true;
|
||||||
},
|
}
|
||||||
{
|
|
||||||
fieldName: 'title',
|
|
||||||
nGramLength: [1, 2],
|
|
||||||
searchable: true,
|
|
||||||
weight: 3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'subtitle',
|
|
||||||
searchable: true,
|
|
||||||
weight: 1,
|
|
||||||
store: false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'subtitle',
|
|
||||||
searchable: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'content',
|
|
||||||
searchable: true,
|
|
||||||
weight: 0,
|
|
||||||
store: false
|
|
||||||
}]
|
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
winston.info('Entry ' + content.entryPath + ' added to index.');
|
|
||||||
|
return self._si.addAsync({
|
||||||
|
entryPath: content.entryPath,
|
||||||
|
title: content.meta.title,
|
||||||
|
subtitle: content.meta.subtitle || '',
|
||||||
|
parent: content.parent.title || '',
|
||||||
|
content: content.text || ''
|
||||||
|
}, {
|
||||||
|
fieldOptions: [{
|
||||||
|
fieldName: 'entryPath',
|
||||||
|
searchable: true,
|
||||||
|
weight: 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'title',
|
||||||
|
nGramLength: [1, 2],
|
||||||
|
searchable: true,
|
||||||
|
weight: 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'subtitle',
|
||||||
|
searchable: true,
|
||||||
|
weight: 1,
|
||||||
|
store: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'parent',
|
||||||
|
searchable: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'content',
|
||||||
|
searchable: true,
|
||||||
|
weight: 0,
|
||||||
|
store: false
|
||||||
|
}]
|
||||||
|
}).then(() => {
|
||||||
|
winston.info('Entry ' + content.entryPath + ' added/updated to index.');
|
||||||
|
return true;
|
||||||
|
}).catch((err) => {
|
||||||
|
winston.error(err);
|
||||||
|
});
|
||||||
|
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
winston.error(err);
|
winston.error(err);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -206,13 +206,32 @@ server.on('listening', () => {
|
|||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
||||||
var fork = require('child_process').fork,
|
var fork = require('child_process').fork,
|
||||||
libInternalAuth = require('./lib/internalAuth'),
|
libInternalAuth = require('./lib/internalAuth');
|
||||||
internalAuthKey = libInternalAuth.generateKey();
|
|
||||||
|
|
||||||
var wsSrv = fork('ws-server.js', [internalAuthKey]),
|
global.WSInternalKey = libInternalAuth.generateKey();
|
||||||
bgAgent = fork('agent.js', [internalAuthKey]);
|
|
||||||
|
var wsSrv = fork('ws-server.js', [WSInternalKey]),
|
||||||
|
bgAgent = fork('agent.js', [WSInternalKey]);
|
||||||
|
|
||||||
process.on('exit', (code) => {
|
process.on('exit', (code) => {
|
||||||
wsSrv.disconnect();
|
wsSrv.disconnect();
|
||||||
bgAgent.disconnect();
|
bgAgent.disconnect();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ----------------------------------------
|
||||||
|
// Connect to local WebSocket server
|
||||||
|
// ----------------------------------------
|
||||||
|
|
||||||
|
var wsClient = require('socket.io-client');
|
||||||
|
global.ws = wsClient('http://localhost:' + appconfig.wsPort, { reconnectionAttempts: 10 });
|
||||||
|
|
||||||
|
ws.on('connect', function () {
|
||||||
|
winston.info('[SERVER] Connected to WebSocket server successfully!');
|
||||||
|
});
|
||||||
|
ws.on('connect_error', function () {
|
||||||
|
winston.warn('[SERVER] Unable to connect to WebSocket server! Retrying...');
|
||||||
|
});
|
||||||
|
ws.on('reconnect_failed', function () {
|
||||||
|
winston.error('[SERVER] Failed to reconnect to WebSocket server too many times! Stopping...');
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
block rootNavCenter
|
block rootNavCenter
|
||||||
.nav-item
|
.nav-item
|
||||||
p.control(v-bind:class="{ 'is-loading': searchload > 0 }")
|
p.control(v-bind:class="{ 'is-loading': searchload > 0 }")
|
||||||
input.input#search-input(type='text', v-model='searchq', @keyup.esc='closeSearch', @keyup.down='moveDownSearch', @keyup.up='moveUpSearch', debounce='400', placeholder='Search...')
|
input.input#search-input(type='text', v-model='searchq', @keyup.esc='closeSearch', @keyup.down='moveDownSearch', @keyup.up='moveUpSearch', @keyup.enter='moveSelectSearch', debounce='400', placeholder='Search...')
|
||||||
span.nav-toggle
|
span.nav-toggle
|
||||||
span
|
span
|
||||||
span
|
span
|
||||||
@@ -46,6 +46,6 @@
|
|||||||
| Did you mean...?
|
| Did you mean...?
|
||||||
ul.menu-list(v-if='searchsuggest.length > 0')
|
ul.menu-list(v-if='searchsuggest.length > 0')
|
||||||
li(v-for='sug in searchsuggest')
|
li(v-for='sug in searchsuggest')
|
||||||
a(v-on:click="useSuggestion(sug)") {{ sug }}
|
a(v-on:click="useSuggestion(sug)", v-bind:class="{ 'is-active': searchmovekey === 'sug.' + sug }") {{ sug }}
|
||||||
|
|
||||||
|
|
||||||
+3
-3
@@ -31,10 +31,10 @@ html
|
|||||||
|
|
||||||
body
|
body
|
||||||
#root
|
#root
|
||||||
include ./common/header
|
include ./common/header.pug
|
||||||
include ./common/alerts
|
include ./common/alerts.pug
|
||||||
main
|
main
|
||||||
block content
|
block content
|
||||||
include ./common/footer
|
include ./common/footer.pug
|
||||||
|
|
||||||
block outside
|
block outside
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
extends ../layout
|
extends ../layout.pug
|
||||||
|
|
||||||
block rootNavCenter
|
block rootNavCenter
|
||||||
h2.nav-item Create New Document
|
h2.nav-item Create New Document
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
extends ../layout
|
extends ../layout.pug
|
||||||
|
|
||||||
block rootNavCenter
|
block rootNavCenter
|
||||||
h2.nav-item= pageData.meta.title
|
h2.nav-item= pageData.meta.title
|
||||||
@@ -24,4 +24,4 @@ block content
|
|||||||
#page-type-edit(data-entrypath=pageData.meta.path)
|
#page-type-edit(data-entrypath=pageData.meta.path)
|
||||||
textarea#mk-editor= pageData.markdown
|
textarea#mk-editor= pageData.markdown
|
||||||
|
|
||||||
include ../modals/edit
|
include ../modals/edit.pug
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
extends ../layout
|
extends ../layout.pug
|
||||||
|
|
||||||
block content
|
block content
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
extends ../layout
|
extends ../layout.pug
|
||||||
|
|
||||||
mixin tocMenu(ti)
|
mixin tocMenu(ti)
|
||||||
each node in ti
|
each node in ti
|
||||||
@@ -61,4 +61,4 @@ block content
|
|||||||
.content.mkcontent
|
.content.mkcontent
|
||||||
!= pageData.html
|
!= pageData.html
|
||||||
|
|
||||||
include ../modals/create
|
include ../modals/create.pug
|
||||||
Reference in new issue
Block a user