diff --git a/core/modules/filterrunprefixes/all.js b/core/modules/filterrunprefixes/all.js index 2e25bbc4d..652936de0 100644 --- a/core/modules/filterrunprefixes/all.js +++ b/core/modules/filterrunprefixes/all.js @@ -18,7 +18,7 @@ Export our filter prefix function */ exports.all = function(operationSubFunction) { return function(results,source,widget) { - Array.prototype.push.apply(results,operationSubFunction(source,widget)); + results.push.apply(results, operationSubFunction(source,widget)); }; }; diff --git a/core/modules/filterrunprefixes/and.js b/core/modules/filterrunprefixes/and.js index ad41c049c..309c228e6 100644 --- a/core/modules/filterrunprefixes/and.js +++ b/core/modules/filterrunprefixes/and.js @@ -19,9 +19,9 @@ Export our filter prefix function exports.and = function(operationSubFunction,options) { return function(results,source,widget) { // This replaces all the elements of the array, but keeps the actual array so that references to it are preserved - source = options.wiki.makeTiddlerIterator(results); - results.splice(0,results.length); - $tw.utils.pushTop(results,operationSubFunction(source,widget)); + source = options.wiki.makeTiddlerIterator(results.toArray()); + results.clear(); + results.pushTop(operationSubFunction(source,widget)); }; }; diff --git a/core/modules/filterrunprefixes/else.js b/core/modules/filterrunprefixes/else.js index c39b9e8fe..6e9ef29b3 100644 --- a/core/modules/filterrunprefixes/else.js +++ b/core/modules/filterrunprefixes/else.js @@ -19,7 +19,7 @@ exports.else = function(operationSubFunction) { return function(results,source,widget) { if(results.length === 0) { // Main result so far is empty - $tw.utils.pushTop(results,operationSubFunction(source,widget)); + results.pushTop(operationSubFunction(source,widget)); } }; }; diff --git a/core/modules/filterrunprefixes/except.js b/core/modules/filterrunprefixes/except.js index 18d649627..659f14228 100644 --- a/core/modules/filterrunprefixes/except.js +++ b/core/modules/filterrunprefixes/except.js @@ -18,7 +18,7 @@ Export our filter prefix function */ exports.except = function(operationSubFunction) { return function(results,source,widget) { - $tw.utils.removeArrayEntries(results,operationSubFunction(source,widget)); + results.remove(operationSubFunction(source,widget)); }; }; diff --git a/core/modules/filterrunprefixes/filter.js b/core/modules/filterrunprefixes/filter.js index 726732c8e..555f8981b 100644 --- a/core/modules/filterrunprefixes/filter.js +++ b/core/modules/filterrunprefixes/filter.js @@ -13,17 +13,17 @@ module-type: filterrunprefix /* Export our filter function */ -exports.filter = function(operationSubFunction) { +exports.filter = function(operationSubFunction,options) { return function(results,source,widget) { if(results.length > 0) { var resultsToRemove = []; - $tw.utils.each(results,function(result) { - var filtered = operationSubFunction($tw.wiki.makeTiddlerIterator([result]),widget); + results.each(function(result) { + var filtered = operationSubFunction(options.wiki.makeTiddlerIterator([result]),widget); if(filtered.length === 0) { resultsToRemove.push(result); } }); - $tw.utils.removeArrayEntries(results,resultsToRemove); + results.remove(resultsToRemove); } } }; diff --git a/core/modules/filterrunprefixes/intersection.js b/core/modules/filterrunprefixes/intersection.js index 2874125d4..34d36066f 100644 --- a/core/modules/filterrunprefixes/intersection.js +++ b/core/modules/filterrunprefixes/intersection.js @@ -17,7 +17,8 @@ exports.intersection = function(operationSubFunction) { return function(results,source,widget) { if(results.length !== 0) { var secondRunResults = operationSubFunction(source,widget); - var firstRunResults = results.splice(0); + var firstRunResults = results.toArray(); + results.clear(); $tw.utils.each(firstRunResults,function(title) { if(secondRunResults.indexOf(title) !== -1) { results.push(title); @@ -27,4 +28,4 @@ exports.intersection = function(operationSubFunction) { }; }; -})(); \ No newline at end of file +})(); diff --git a/core/modules/filterrunprefixes/or.js b/core/modules/filterrunprefixes/or.js index 5192f490b..82eff083a 100644 --- a/core/modules/filterrunprefixes/or.js +++ b/core/modules/filterrunprefixes/or.js @@ -17,7 +17,7 @@ Export our filter prefix function */ exports.or = function(operationSubFunction) { return function(results,source,widget) { - $tw.utils.pushTop(results,operationSubFunction(source,widget)); + results.pushTop(operationSubFunction(source,widget)); }; }; diff --git a/core/modules/filterrunprefixes/reduce.js b/core/modules/filterrunprefixes/reduce.js index 4dcef4bc7..534c3e450 100644 --- a/core/modules/filterrunprefixes/reduce.js +++ b/core/modules/filterrunprefixes/reduce.js @@ -16,9 +16,9 @@ exports.reduce = function(operationSubFunction,options) { return function(results,source,widget) { if(results.length > 0) { var accumulator = ""; - for(var index=0; index 0) { accumulator = "" + list[0]; } - } - results.splice(0,results.length); + ++index; + }); + results.clear(); results.push(accumulator); } } diff --git a/core/modules/filters.js b/core/modules/filters.js index 0fc0a3dc9..4fec05964 100644 --- a/core/modules/filters.js +++ b/core/modules/filters.js @@ -311,11 +311,11 @@ exports.compileFilter = function(filterString) { } else if(typeof source === "object") { // Array or hashmap source = self.makeTiddlerIterator(source); } - var results = []; + var results = new $tw.utils.LinkedList(); $tw.utils.each(operationFunctions,function(operationFunction) { operationFunction(results,source,widget); }); - return results; + return results.toArray(); }); }; diff --git a/core/modules/utils/filesystem.js b/core/modules/utils/filesystem.js index 9ee2e8acd..eb1050f90 100644 --- a/core/modules/utils/filesystem.js +++ b/core/modules/utils/filesystem.js @@ -217,6 +217,10 @@ Options include: */ exports.generateTiddlerFileInfo = function(tiddler,options) { var fileInfo = {}, metaExt; + // Propagate the isEditableFile flag + if(options.fileInfo) { + fileInfo.isEditableFile = options.fileInfo.isEditableFile || false; + } // Check if the tiddler has any unsafe fields that can't be expressed in a .tid or .meta file: containing control characters, or leading/trailing whitespace var hasUnsafeFields = false; $tw.utils.each(tiddler.getFieldStrings(),function(value,fieldName) { @@ -248,20 +252,22 @@ exports.generateTiddlerFileInfo = function(tiddler,options) { extFilters: options.extFilters, wiki: options.wiki }); - if(metaExt === ".tid") { - // Overriding to the .tid extension needs special handling - fileInfo.type = "application/x-tiddler"; - fileInfo.hasMetaFile = false; - } else if (metaExt === ".json") { - // Overriding to the .json extension needs special handling - fileInfo.type = "application/json"; - fileInfo.hasMetaFile = false; - } else if (metaExt) { - //If the new type matches a known extention, use that MIME type's encoding - var extInfo = $tw.utils.getFileExtensionInfo(metaExt); - fileInfo.type = extInfo ? extInfo.type : null; - fileInfo.encoding = $tw.utils.getTypeEncoding(metaExt); - fileInfo.hasMetaFile = true; + if(metaExt){ + if(metaExt === ".tid") { + // Overriding to the .tid extension needs special handling + fileInfo.type = "application/x-tiddler"; + fileInfo.hasMetaFile = false; + } else if (metaExt === ".json") { + // Overriding to the .json extension needs special handling + fileInfo.type = "application/json"; + fileInfo.hasMetaFile = false; + } else { + //If the new type matches a known extention, use that MIME type's encoding + var extInfo = $tw.utils.getFileExtensionInfo(metaExt); + fileInfo.type = extInfo ? extInfo.type : null; + fileInfo.encoding = $tw.utils.getTypeEncoding(metaExt); + fileInfo.hasMetaFile = true; + } } } } @@ -276,10 +282,6 @@ exports.generateTiddlerFileInfo = function(tiddler,options) { fileInfo: options.fileInfo, originalpath: options.originalpath }); - // Propigate the isEditableFile flag - if(options.fileInfo) { - fileInfo.isEditableFile = options.fileInfo.isEditableFile || false; - } return fileInfo; }; @@ -380,7 +382,7 @@ exports.generateTiddlerFilepath = function(title,options) { count++; } while(fs.existsSync(fullPath)); //If the path does not start with the wikiPath directory or the wikiTiddlersPath directory, or if the last write failed - var encode = !(fullPath.indexOf($tw.boot.wikiPath) == 0 || fullPath.indexOf($tw.boot.wikiTiddlersPath) == 0) || ((options.fileInfo || {writeError: false}).writeError == true); + var encode = !(fullPath.indexOf(path.resolve($tw.boot.wikiPath)) == 0 || fullPath.indexOf($tw.boot.wikiTiddlersPath) == 0) || ((options.fileInfo || {writeError: false}).writeError == true); if(encode){ //encodeURIComponent() and then resolve to tiddler directory fullPath = path.resolve(directory, encodeURIComponent(fullPath)); diff --git a/core/modules/utils/linked-list.js b/core/modules/utils/linked-list.js new file mode 100644 index 000000000..50421ab56 --- /dev/null +++ b/core/modules/utils/linked-list.js @@ -0,0 +1,118 @@ +/*\ +module-type: utils +title: $:/core/modules/utils/linkedlist.js +type: application/javascript + +This is a doubly-linked indexed list intended for manipulation, particularly +pushTop, which it does with significantly better performance than an array. + +\*/ +(function(){ + +function LinkedList() { + this.clear(); +}; + +LinkedList.prototype.clear = function() { + this.index = Object.create(null); + // LinkedList performs the duty of both the head and tail node + this.next = this; + this.prev = this; + this.length = 0; +}; + +LinkedList.prototype.remove = function(value) { + if($tw.utils.isArray(value)) { + for(var t=0; t> -wikilist-button-background: <> -wikilist-button-foreground: <> +wikilist-button-background: #3F638B +wikilist-button-foreground: <> wikilist-button-open: #32D74B wikilist-button-open-hover: #32D74B wikilist-button-reveal: #0A84FF diff --git a/core/palettes/GruvBoxDark.tid b/core/palettes/GruvBoxDark.tid index d53ec61e0..494a9349b 100644 --- a/core/palettes/GruvBoxDark.tid +++ b/core/palettes/GruvBoxDark.tid @@ -97,7 +97,7 @@ tiddler-border: <> tiddler-controls-foreground-hover: #7c6f64 tiddler-controls-foreground-selected: <> tiddler-controls-foreground: #665c54 -tiddler-editor-background: #282828 +tiddler-editor-background: #32302f tiddler-editor-border-image: #282828 tiddler-editor-border: #282828 tiddler-editor-fields-even: #504945 @@ -121,7 +121,7 @@ toolbar-done-button: untagged-background: #504945 very-muted-foreground: #bdae93 wikilist-background: <> -wikilist-button-background: <> +wikilist-button-background: #acacac wikilist-button-foreground: <> wikilist-item: <> wikilist-toolbar-background: <> diff --git a/core/palettes/Nord.tid b/core/palettes/Nord.tid index 21d93a759..7af3b01e4 100644 --- a/core/palettes/Nord.tid +++ b/core/palettes/Nord.tid @@ -99,7 +99,7 @@ tiddler-controls-foreground-selected: #EBCB8B tiddler-controls-foreground: #4C566A tiddler-editor-background: #2e3440 tiddler-editor-border-image: #2e3440 -tiddler-editor-border: #2e3440 +tiddler-editor-border: #3b4252 tiddler-editor-fields-even: #2e3440 tiddler-editor-fields-odd: #2e3440 tiddler-info-background: #2e3440 @@ -120,3 +120,14 @@ toolbar-cancel-button: toolbar-done-button: untagged-background: #2d3038 very-muted-foreground: #2d3038 +wikilist-background: <> +wikilist-toolbar-background: <> +wikilist-item: <> +wikilist-title: <> +wikilist-info: <> +wikilist-button-open: #A3BE8C +wikilist-button-open-hover: #A3BE8C +wikilist-button-reveal: #81A1C1 +wikilist-button-reveal-hover: #81A1C1 +wikilist-button-remove: #B48EAD +wikilist-button-remove-hover: #B48EAD diff --git a/core/ui/SideBarSegments/search.tid b/core/ui/SideBarSegments/search.tid index a5b6f1b97..91d4fe922 100644 --- a/core/ui/SideBarSegments/search.tid +++ b/core/ui/SideBarSegments/search.tid @@ -46,12 +46,12 @@ tags: $:/tags/SideBarSegment