diff --git a/core/modules/startup/bulkops.js b/core/modules/startup/bulkops.js new file mode 100644 index 000000000..d70afadaa --- /dev/null +++ b/core/modules/startup/bulkops.js @@ -0,0 +1,28 @@ +/*\ +title: $:/core/modules/startup/bulkops.js +type: application/javascript +module-type: startup + +Support for bulk tiddler operations + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +// Export name and synchronous status +exports.name = "bulkops"; +exports.platforms = ["browser"]; +exports.after = ["startup"]; +exports.synchronous = true; + +exports.startup = function() { + $tw.rootWidget.addEventListener("tm-rename-tiddler",function(event) { + var paramObject = event.paramObject || {}; + $tw.wiki.renameTiddler(paramObject.from,paramObject.to); + }); +}; + +})(); diff --git a/core/modules/wiki-bulkops.js b/core/modules/wiki-bulkops.js new file mode 100644 index 000000000..ce72f1c99 --- /dev/null +++ b/core/modules/wiki-bulkops.js @@ -0,0 +1,53 @@ +/*\ +title: $:/core/modules/wiki-bulkops.js +type: application/javascript +module-type: wikimethod + +Bulk tiddler operations such as rename. + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +Rename a tiddler, and relink any tags or lists that reference it. +*/ +exports.renameTiddler = function(fromTitle,toTitle) { + var self = this; + fromTitle = (fromTitle || "").trim(); + toTitle = (toTitle || "").trim(); + if(fromTitle && toTitle && fromTitle !== toTitle) { + // Rename the tiddler itself + var tiddler = this.getTiddler(fromTitle); + this.addTiddler(new $tw.Tiddler(tiddler,{title: toTitle},this.getModificationFields())); + this.deleteTiddler(fromTitle); + // Rename any tags or lists that reference it + this.each(function(tiddler,title) { + var tags = (tiddler.fields.tags || []).slice(0), + list = (tiddler.fields.list || []).slice(0), + isModified = false; + // Rename tags + $tw.utils.each(tags,function (title,index) { + if(title === fromTitle) { + tags[index] = toTitle; + isModified = true; + } + }); + // Rename lists + $tw.utils.each(list,function (title,index) { + if(title === fromTitle) { + list[index] = toTitle; + isModified = true; + } + }); + if(isModified) { + self.addTiddler(new $tw.Tiddler(tiddler,{tags: tags, list: list},self.getModificationFields())); + } + }); + } +} + +})(); diff --git a/editions/text-slicer/tiddlers/HelloThere.tid b/editions/text-slicer/tiddlers/HelloThere.tid index ea6d861b9..24d2d6438 100644 --- a/editions/text-slicer/tiddlers/HelloThere.tid +++ b/editions/text-slicer/tiddlers/HelloThere.tid @@ -2,7 +2,9 @@ title: HelloThere This edition of ~TiddlyWiki contains tools to help slice up long texts into individual tiddlers. -//It is currently only intended for advanced users. The tools are in the early stages of development, and likely to need some customisation to do what you need.// +//''This plugin is under active development, and is subject to change in the future''. It is currently only intended for advanced users. The tools are in the early stages of development, and likely to need some customisation to do what you need.// + +! Usage The source document must first be marked up as an ordinary wikitext tiddler. Currently only the following formatting is recognised: @@ -12,14 +14,13 @@ 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]] +# Click the ''text slicer'' icon on the [[Sample Text]] tiddler below +# 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 +# Click the ''Show toolbar'' checkbox to display a simple toolbar for each tiddler +# Use the text box and the ''rename'' button to rename tiddlers without breaking the tagging links -The table of contents at the top of the output tiddler shows how the document has been split up into individual tiddlers: +! Plugin Instructions -* A tiddler for each heading, with the children of the heading tagged with the title of the heading -* A tiddler for each paragraph -* A tiddler for each list, and a tiddler for each list item -* The list field of tag tiddlers is used to control ordering of children +{{$:/plugins/tiddlywiki/text-slicer/docs}} diff --git a/editions/translators/tiddlywiki.info b/editions/translators/tiddlywiki.info index 7f047d5ee..8e4dc295a 100644 --- a/editions/translators/tiddlywiki.info +++ b/editions/translators/tiddlywiki.info @@ -18,11 +18,13 @@ "ia-IA", "it-IT", "ja-JP", + "ko-KR", "nl-NL", "pa-IN", "pt-PT", "ru-RU", "sk-SK", + "sv-SE", "zh-Hans", "zh-Hant" ], diff --git a/editions/tw5.com/tiddlers/images/external/tiddlywiki.files b/editions/tw5.com/tiddlers/images/external/tiddlywiki.files index c81bd8c15..88b68ebd8 100644 --- a/editions/tw5.com/tiddlers/images/external/tiddlywiki.files +++ b/editions/tw5.com/tiddlers/images/external/tiddlywiki.files @@ -108,6 +108,15 @@ "tags": "Language Icon" } }, + { + "file": "../../../../../languages/ko-KR/icon.tid", + "isTiddlerFile": true, + "fields": { + "title": "Language Icon: ko-KR", + "language": "ko-KR", + "tags": "Language Icon" + } + }, { "file": "../../../../../languages/nl-NL/icon.tid", "isTiddlerFile": true, @@ -153,6 +162,15 @@ "tags": "Language Icon" } }, + { + "file": "../../../../../languages/sv-SE/icon.tid", + "isTiddlerFile": true, + "fields": { + "title": "Language Icon: sv-SE", + "language": "sv-SE", + "tags": "Language Icon" + } + }, { "file": "../../../../../languages/zh-Hans/icon.tid", "isTiddlerFile": true, diff --git a/plugins/tiddlywiki/text-slicer/docs.tid b/plugins/tiddlywiki/text-slicer/docs.tid new file mode 100644 index 000000000..336b0e2a3 --- /dev/null +++ b/plugins/tiddlywiki/text-slicer/docs.tid @@ -0,0 +1,26 @@ +title: $:/plugins/tiddlywiki/text-slicer/docs + +!! Text Slicing Approach + +Individual tiddlers are created for each heading, paragraph and list item. They are linked together using TiddlyWiki's tagging mechanism. + +For example, consider a tiddler titled ''Example'' containing this simple text: + +<<< +! This is a heading + +This is a paragraph. + +* And the first list item +* Second list item +<<< + +It will be sliced up into: + +* a tiddler for the overall document +** a tiddler for the heading +*** a tiddler for the paragraph +*** a tiddler for the list +**** and a tiddler for each list item + +These tiddlers are bound together using tagging: child tiddlers are tagged with the title of their parent, and the parent tiddler has a ''list'' field that lists each child in the correct order. diff --git a/plugins/tiddlywiki/text-slicer/macros.tid b/plugins/tiddlywiki/text-slicer/macros.tid index bcba9bc62..fb1c0f41f 100644 --- a/plugins/tiddlywiki/text-slicer/macros.tid +++ b/plugins/tiddlywiki/text-slicer/macros.tid @@ -1,15 +1,11 @@ title: $:/plugins/tiddlywiki/text-slicer/macros tags: $:/tags/Macro -\define display-tiddler() -<$list filter="[draft.oflimit[1]]" editTemplate="$:/core/ui/EditTemplate" emptyMessage="""<$transclude mode='block'/>"""/> -\end - \define display-heading-tiddler(level:"h1") <$level$><$view field="title"/> <$list filter='[tag!has[draft.of]]'> <$tiddler> -<> +{{||$:/plugins/tiddlywiki/text-slicer/templates/display-tiddler}} \end @@ -19,7 +15,7 @@ tags: $:/tags/Macro <$list filter='[tag!has[draft.of]]'>
  • <$tiddler> -<> +{{||$:/plugins/tiddlywiki/text-slicer/templates/display-tiddler}}
  • diff --git a/plugins/tiddlywiki/text-slicer/plugin.info b/plugins/tiddlywiki/text-slicer/plugin.info index d45d1c3e4..97c06fd5c 100644 --- a/plugins/tiddlywiki/text-slicer/plugin.info +++ b/plugins/tiddlywiki/text-slicer/plugin.info @@ -3,5 +3,5 @@ "description": "Tools for slicing text into tiddlers", "author": "JeremyRuston", "core-version": ">=5.0.0", - "list": "readme" + "list": "readme docs" } diff --git a/plugins/tiddlywiki/text-slicer/readme.tid b/plugins/tiddlywiki/text-slicer/readme.tid index a3859bf93..058a3efb9 100644 --- a/plugins/tiddlywiki/text-slicer/readme.tid +++ b/plugins/tiddlywiki/text-slicer/readme.tid @@ -1,3 +1,5 @@ title: $:/plugins/tiddlywiki/text-slicer/readme +//''This plugin is under active development, and is subject to change in the future''. It is currently only intended for advanced users. The tools are in the early stages of development, and likely to need some customisation to do what you need.// + This plugin contains tools to help slice up long texts into individual tiddlers. diff --git a/plugins/tiddlywiki/text-slicer/slice-button.tid b/plugins/tiddlywiki/text-slicer/slice-button.tid index 371b15f17..2ce65e615 100644 --- a/plugins/tiddlywiki/text-slicer/slice-button.tid +++ b/plugins/tiddlywiki/text-slicer/slice-button.tid @@ -1,9 +1,14 @@ title: $:/plugins/tiddlywiki/text-slicer/ui/slice-button tags: $:/tags/ViewToolbar +list-before: $:/core/ui/Buttons/edit caption: {{$:/plugins/tiddlywiki/text-slicer/text-slicer-icon}} Slice tiddler description: Slice this tiddler by headings and lists -<$button message="tm-slice-tiddler" param=<> tooltip={{$:/language/Buttons/Clone/Hint}} aria-label={{$:/language/Buttons/Clone/Caption}} class=<>> +\define hint() +Slice this tiddler by headings and lists +\end + +<$button message="tm-slice-tiddler" param=<> tooltip=<> aria-label=<> class=<>> <$list filter="[prefix[yes]]"> {{$:/plugins/tiddlywiki/text-slicer/text-slicer-icon}} diff --git a/plugins/tiddlywiki/text-slicer/slicer.js b/plugins/tiddlywiki/text-slicer/slicer.js index 10f2013af..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); }); }; @@ -121,7 +121,7 @@ function sliceTiddler(title) { if(parser) { parentStack.push({type: "h0", title: addTiddler({ title: "Sliced up " + title, - text: "
    \n\n<>\n\n
    \n<>", + text: "{{||$:/plugins/tiddlywiki/text-slicer/templates/display-document}}", list: [] })}); processNodeList(parser.tree); @@ -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/tag-TextSlicerToolbar.tid b/plugins/tiddlywiki/text-slicer/tag-TextSlicerToolbar.tid new file mode 100644 index 000000000..ef2f27cd4 --- /dev/null +++ b/plugins/tiddlywiki/text-slicer/tag-TextSlicerToolbar.tid @@ -0,0 +1,3 @@ +title: $:/tags/TextSlicerToolbar +list: $:/plugins/tiddlywiki/text-slicer/toolbar/title $:/plugins/tiddlywiki/text-slicer/toolbar/rename + diff --git a/plugins/tiddlywiki/text-slicer/template-display-document.tid b/plugins/tiddlywiki/text-slicer/template-display-document.tid new file mode 100644 index 000000000..c2344b1c3 --- /dev/null +++ b/plugins/tiddlywiki/text-slicer/template-display-document.tid @@ -0,0 +1,21 @@ +title: $:/plugins/tiddlywiki/text-slicer/templates/display-document + +\define config-show-toolbar() +$:/plugins/tiddlywiki/text-slicer/config/show-toolbar/$(currentTiddler)$ +\end + +\define display-tiddler() +<$set name="tv-show-toolbar" value={{$(config-show-toolbar)$}}> +<> + +\end + +
    + +<$macrocall $name="toc-selective-expandable" tag=<>/> + +
    + +<$checkbox tiddler=<> field="text" checked="yes" unchecked="no" default="no"> Show toolbar + +<> diff --git a/plugins/tiddlywiki/text-slicer/template-display-tiddler.tid b/plugins/tiddlywiki/text-slicer/template-display-tiddler.tid new file mode 100644 index 000000000..0a4023560 --- /dev/null +++ b/plugins/tiddlywiki/text-slicer/template-display-tiddler.tid @@ -0,0 +1,6 @@ +title: $:/plugins/tiddlywiki/text-slicer/templates/display-tiddler + +<$list filter="[prefix[yes]]" variable="hasToolbar"> +{{||$:/plugins/tiddlywiki/text-slicer/templates/tiddler-toolbar}} + +<$list filter="[draft.oflimit[1]]" editTemplate="$:/core/ui/EditTemplate" emptyMessage="""<$transclude mode='block'/>"""/> diff --git a/plugins/tiddlywiki/text-slicer/template-tiddler-toolbar.tid b/plugins/tiddlywiki/text-slicer/template-tiddler-toolbar.tid new file mode 100644 index 000000000..7494c6020 --- /dev/null +++ b/plugins/tiddlywiki/text-slicer/template-tiddler-toolbar.tid @@ -0,0 +1,5 @@ +title: $:/plugins/tiddlywiki/text-slicer/templates/tiddler-toolbar + +
    +<$list filter="[all[shadows+tiddlers]tag[$:/tags/TextSlicerToolbar]!has[draft.of]]" variable="listItem"><$transclude tiddler=<>/> +
    diff --git a/plugins/tiddlywiki/text-slicer/text-slicer-icon.tid b/plugins/tiddlywiki/text-slicer/text-slicer-icon.tid index 41b6496c3..369bb26a2 100644 --- a/plugins/tiddlywiki/text-slicer/text-slicer-icon.tid +++ b/plugins/tiddlywiki/text-slicer/text-slicer-icon.tid @@ -3,19 +3,21 @@ tags: $:/tags/Image - - - - - - - - - - - - - + + + + + + + + + + + + + + + - \ No newline at end of file + diff --git a/plugins/tiddlywiki/text-slicer/toolbar-rename.tid b/plugins/tiddlywiki/text-slicer/toolbar-rename.tid new file mode 100644 index 000000000..a11f10bbd --- /dev/null +++ b/plugins/tiddlywiki/text-slicer/toolbar-rename.tid @@ -0,0 +1,16 @@ +title: $:/plugins/tiddlywiki/text-slicer/toolbar/rename +tags: $:/tags/TextSlicerToolbar + +\define renameProxyTitle() +$:/config/plugins/tiddlywiki/text-slicer/rename-$(currentTiddler)$ +\end + +\define body() +<$edit-text tag="input" tiddler=<> placeholder="Rename" default=<>/> +<$button> +<$action-sendmessage $message="tm-rename-tiddler" from=<> to={{$(renameProxyTitle)$}}/> +rename + +\end + +<> \ No newline at end of file diff --git a/plugins/tiddlywiki/text-slicer/toolbar-title.tid b/plugins/tiddlywiki/text-slicer/toolbar-title.tid new file mode 100644 index 000000000..21c652be6 --- /dev/null +++ b/plugins/tiddlywiki/text-slicer/toolbar-title.tid @@ -0,0 +1,4 @@ +title: $:/plugins/tiddlywiki/text-slicer/toolbar/title +tags: $:/tags/TextSlicerToolbar + +<$link><$text text=<>/>