From 535d8d6fa0caafa3f8d44c6f28c7a919dfce64f8 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Tue, 4 Aug 2015 08:04:57 +0100 Subject: [PATCH] Stop using an import tiddler for text slicer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead we directly output the tiddlers (we keep the old code around; later we’ll make the output mode switchable). Also improve the icon --- editions/text-slicer/tiddlers/HelloThere.tid | 3 +- plugins/tiddlywiki/text-slicer/slicer.js | 19 ++++++++++-- .../text-slicer/text-slicer-icon.tid | 30 +++++++++---------- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/editions/text-slicer/tiddlers/HelloThere.tid b/editions/text-slicer/tiddlers/HelloThere.tid index 60e371c13..1a933f955 100644 --- a/editions/text-slicer/tiddlers/HelloThere.tid +++ b/editions/text-slicer/tiddlers/HelloThere.tid @@ -15,8 +15,7 @@ The source document must first be marked up as an ordinary wikitext tiddler. Cur To try it out: # Click the "text slicer" icon on the [[Sample Text]] tiddler below -# Click the ''import'' button in the resulting import listing -# Open the tiddler [[Sliced up Sample Text]] +# View the tiddler [[Sliced up Sample Text]] #* It should match the content of [[Sample Text]] #* The table of contents at the top allows the structure to be explored diff --git a/plugins/tiddlywiki/text-slicer/slicer.js b/plugins/tiddlywiki/text-slicer/slicer.js index 51a38360e..b0e96846b 100644 --- a/plugins/tiddlywiki/text-slicer/slicer.js +++ b/plugins/tiddlywiki/text-slicer/slicer.js @@ -24,7 +24,7 @@ var SLICER_OUTPUT_TITLE = "$:/TextSlicer"; exports.startup = function() { $tw.rootWidget.addEventListener("tm-slice-tiddler",function(event) { // Slice up and output the tiddler - outputTiddlers(sliceTiddler(event.param),event.param); + outputTiddlers(sliceTiddler(event.param),event.param,event.param); }); }; @@ -129,8 +129,21 @@ function sliceTiddler(title) { return tiddlers; } -// Output to the output tiddler -function outputTiddlers(tiddlers,navigateFromTitle) { +// Output directly to the output tiddlers +function outputTiddlers(tiddlers,title,navigateFromTitle) { + $tw.utils.each(tiddlers,function(tiddlerFields) { + var title = tiddlerFields.title; + if(title) { + $tw.wiki.addTiddler(new $tw.Tiddler($tw.wiki.getCreationFields(),tiddlerFields,$tw.wiki.getModificationFields())); + } + }); + // Navigate to output + var story = new $tw.Story({wiki: $tw.wiki}); + story.navigateTiddler("Sliced up " + title,navigateFromTitle); +} + +// Output via an import tiddler +function outputTiddlers_viaImportTiddler(tiddlers,navigateFromTitle) { // Get the current slicer output tiddler var slicerOutputTiddler = $tw.wiki.getTiddler(SLICER_OUTPUT_TITLE), slicerOutputData = $tw.wiki.getTiddlerData(SLICER_OUTPUT_TITLE,{}), diff --git a/plugins/tiddlywiki/text-slicer/text-slicer-icon.tid b/plugins/tiddlywiki/text-slicer/text-slicer-icon.tid index da95b8a85..369bb26a2 100644 --- a/plugins/tiddlywiki/text-slicer/text-slicer-icon.tid +++ b/plugins/tiddlywiki/text-slicer/text-slicer-icon.tid @@ -3,22 +3,20 @@ tags: $:/tags/Image - - - - - - - - - - - - - - - - + + + + + + + + + + + + + +