diff --git a/core/modules/filters/accumulate-palette-entries.js b/core/modules/filters/accumulate-palette-entries.js deleted file mode 100644 index 6ca45a051..000000000 --- a/core/modules/filters/accumulate-palette-entries.js +++ /dev/null @@ -1,45 +0,0 @@ -/*\ -title: $:/core/modules/filters/accumulate-palette-entries.js -type: application/javascript -module-type: filteroperator - -A temporary filter operator for accumulating palette entries into a unique signature that can be used for cache invalidation. The signature is opaque, and should not be used for anything other than cache invalidation. - -Hopefully we can figure out a way to do this within TW's filter language; it might be a good way to stretch the capabilities of the language. - -\*/ -(function(){ - -/*jslint node: true, browser: true */ -/*global $tw: false */ -"use strict"; - -/* -Export our filter function -*/ -exports["accumulate-palette-entries"] = function(source,operator,options) { - var paletteTitle = operator.operand, - wiki = options.wiki, - visitedPalettes = []; - // Recursive function to accumulate the palette entries from a single palette - function accumulatePaletteEntries(title) { - var tiddler = wiki.getTiddler(title), - results = []; - if(visitedPalettes.indexOf(title) === -1 && tiddler) { - visitedPalettes.push(title); - if(tiddler.fields["palette-import"]) { - Array.prototype.push.apply(results,accumulatePaletteEntries(tiddler.fields["palette-import"])); - } - var json = wiki.getTiddlerData(tiddler,{}); - $tw.utils.each(Object.keys(json),function(key) { - results.push(key + ":" + json[key]); - }); - } - return results; - } - var results = JSON.stringify(accumulatePaletteEntries(paletteTitle)); - results += wiki.getTiddlerAsJson(paletteTitle); - return [results]; -}; - -})(); diff --git a/core/modules/filters/changecount.js b/core/modules/filters/changecount.js new file mode 100644 index 000000000..a19310289 --- /dev/null +++ b/core/modules/filters/changecount.js @@ -0,0 +1,26 @@ +/*\ +title: $:/core/modules/filters/changecount.js +type: application/javascript +module-type: filteroperator + +Filter operator for retrieving the changecount for each title in the list. + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +Export our filter function +*/ +exports.changecount = function(source,operator,options) { + var results = []; + source(function(tiddler,title) { + results.push(options.wiki.getChangeCount(title) + ""); + }); + return results; +}; + +})(); diff --git a/core/wiki/background-actions/AutoCompilePalette.tid b/core/wiki/background-actions/AutoCompilePalette.tid index 042439703..112ae9135 100644 --- a/core/wiki/background-actions/AutoCompilePalette.tid +++ b/core/wiki/background-actions/AutoCompilePalette.tid @@ -1,6 +1,6 @@ title: $:/core/background-actions/AutoCompilePalette tags: $:/tags/BackgroundAction $:/tags/StartupAction -track-filter: [accumulate-palette-entries[$:/palette]] +track-filter: [[$:/palette]] +[changecount[]] \import [subfilter{$:/core/config/GlobalImportFilter}] <> diff --git a/editions/test/tiddlers/tests/data/palettes/Accumulate.tid b/editions/test/tiddlers/tests/data/palettes/Accumulate.tid deleted file mode 100644 index 38a67c490..000000000 --- a/editions/test/tiddlers/tests/data/palettes/Accumulate.tid +++ /dev/null @@ -1,40 +0,0 @@ - -title: Operators/Palettes/Accumulate -description: Recursively accumulate palette definitions -type: text/vnd.tiddlywiki-multiple -tags: [[$:/tags/wiki-test-spec]] - -title: Output - -\import [subfilter{$:/core/config/GlobalImportFilter}] -\parsermode inline -<$text text={{{ [accumulate-palette-entries[MyPalette]] }}}/> -+ -title: $:/palette - -MyPalette -+ -title: MyPalette -name: My Palette -description: My custom palette -tags: $:/tags/Palette -type: application/x-tiddler-dictionary -palette-import: MyOtherPalette -color-scheme: light - -page-background: <> -custom: #f4e4d4 -+ -title: MyOtherPalette -name: My Other Palette -description: My other custom palette -tags: $:/tags/Palette -type: application/x-tiddler-dictionary -color-scheme: light - -page-background: #d4e4f4 -background: red -+ -title: ExpectedResult - -["page-background:#d4e4f4","background:red","page-background:<<colour custom>>","custom:#f4e4d4"]{"title":"MyPalette","name":"My Palette","description":"My custom palette","tags":"$:/tags/Palette","type":"application/x-tiddler-dictionary","palette-import":"MyOtherPalette","color-scheme":"light","text":"page-background: <<colour custom>>\ncustom: #f4e4d4"} \ No newline at end of file