diff --git a/core/modules/startup/startup.js b/core/modules/startup/startup.js index 81ac45842..6bdb2e9a9 100755 --- a/core/modules/startup/startup.js +++ b/core/modules/startup/startup.js @@ -18,7 +18,7 @@ exports.after = ["load-modules"]; exports.synchronous = true; // Set to `true` to enable performance instrumentation -var PERFORMANCE_INSTRUMENTATION = true; +var PERFORMANCE_INSTRUMENTATION = false; var widget = require("$:/core/modules/widgets/widget.js"); diff --git a/core/modules/story.js b/core/modules/story.js new file mode 100644 index 000000000..69cab2529 --- /dev/null +++ b/core/modules/story.js @@ -0,0 +1,136 @@ +/*\ +title: $:/core/modules/story.js +type: application/javascript +module-type: global + +Lightweight object for managing interactions with the story and history lists. + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +Construct Story object with options: +wiki: reference to wiki object to use to resolve tiddler titles +storyTitle: title of story list tiddler +historyTitle: title of history list tiddler +*/ +function Story(options) { + options = options || {}; + this.wiki = options.wiki || $tw.wiki; + this.storyTitle = options.storyTitle || "$:/StoryList"; + this.historyTitle = options.historyTitle || "$:/HistoryList"; +}; + +Story.prototype.navigateTiddler = function(navigateTo,navigateFromTitle,navigateFromClientRect) { + this.addToStory(navigateTo,navigateFromTitle); + this.addToHistory(navigateTo,navigateFromClientRect); +}; + +Story.prototype.getStoryList = function() { + return this.wiki.getTiddlerList(this.storyTitle) || []; +}; + +Story.prototype.addToStory = function(navigateTo,navigateFromTitle,options) { + options = options || {}; + var storyList = this.getStoryList(); + // See if the tiddler is already there + var slot = storyList.indexOf(navigateTo); + // Quit if it already exists in the story river + if(slot >= 0) { + return; + } + // First we try to find the position of the story element we navigated from + var fromIndex = storyList.indexOf(navigateFromTitle); + if(fromIndex >= 0) { + // The tiddler is added from inside the river + // Determine where to insert the tiddler; Fallback is "below" + switch(options.openLinkFromInsideRiver) { + case "top": + slot = 0; + break; + case "bottom": + slot = storyList.length; + break; + case "above": + slot = fromIndex; + break; + case "below": // Intentional fall-through + default: + slot = fromIndex + 1; + break; + } + } else { + // The tiddler is opened from outside the river. Determine where to insert the tiddler; default is "top" + if(options.openLinkFromOutsideRiver === "bottom") { + // Insert at bottom + slot = storyList.length; + } else { + // Insert at top + slot = 0; + } + } + // Add the tiddler + storyList.splice(slot,0,navigateTo); + // Save the story + this.saveStoryList(storyList); +}; + +Story.prototype.saveStoryList = function(storyList) { + var storyTiddler = this.wiki.getTiddler(this.storyTitle); + this.wiki.addTiddler(new $tw.Tiddler( + {title: this.storyTitle}, + storyTiddler, + {list: storyList} + )); +}; + +Story.prototype.addToHistory = function(navigateTo,navigateFromClientRect) { + var titles = $tw.utils.isArray(navigateTo) ? navigateTo : [navigateTo]; + // Add a new record to the top of the history stack + var historyList = this.wiki.getTiddlerData(this.historyTitle,[]); + $tw.utils.each(titles,function(title) { + historyList.push({title: title, fromPageRect: navigateFromClientRect}); + }); + this.wiki.setTiddlerData(this.historyTitle,historyList,{"current-tiddler": titles[titles.length-1]}); +}; + +Story.prototype.storyCloseTiddler = function(targetTitle) { +// TBD +}; + +Story.prototype.storyCloseAllTiddlers = function() { +// TBD +}; + +Story.prototype.storyCloseOtherTiddlers = function(targetTitle) { +// TBD +}; + +Story.prototype.storyEditTiddler = function(targetTitle) { +// TBD +}; + +Story.prototype.storyDeleteTiddler = function(targetTitle) { +// TBD +}; + +Story.prototype.storySaveTiddler = function(targetTitle) { +// TBD +}; + +Story.prototype.storyCancelTiddler = function(targetTitle) { +// TBD +}; + +Story.prototype.storyNewTiddler = function(targetTitle) { +// TBD +}; + +exports.Story = Story; + + +})(); diff --git a/core/modules/utils/parsetree.js b/core/modules/utils/parsetree.js index 26c7f9a1b..c61c728fd 100644 --- a/core/modules/utils/parsetree.js +++ b/core/modules/utils/parsetree.js @@ -56,4 +56,24 @@ exports.findParseTreeNode = function(nodeArray,search) { return undefined; }; +/* +Helper to get the text of a parse tree node or array of nodes +*/ +exports.getParseTreeText = function getParseTreeText(tree) { + var output = []; + if($tw.utils.isArray(tree)) { + $tw.utils.each(tree,function(node) { + output.push(getParseTreeText(node)); + }); + } else { + if(tree.type === "text") { + output.push(tree.text); + } + if(tree.children) { + return getParseTreeText(tree.children); + } + } + return output.join(""); +}; + })(); diff --git a/core/modules/widgets/navigator.js b/core/modules/widgets/navigator.js index 967f06ec7..df2724ec1 100755 --- a/core/modules/widgets/navigator.js +++ b/core/modules/widgets/navigator.js @@ -552,12 +552,12 @@ NavigatorWidget.prototype.handlePerformImportEvent = function(event) { }); // Replace the $:/Import tiddler with an import report this.wiki.addTiddler(new $tw.Tiddler({ - title: IMPORT_TITLE, + title: event.param, text: importReport.join("\n"), "status": "complete" })); // Navigate to the $:/Import tiddler - this.addToHistory([IMPORT_TITLE]); + this.addToHistory([event.param]); // Trigger an autosave $tw.rootWidget.dispatchEvent({type: "tm-auto-save-wiki"}); }; diff --git a/core/modules/wiki.js b/core/modules/wiki.js index ff9d1c360..234ba26d8 100755 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -1175,14 +1175,8 @@ fromPageRect: page coordinates of the origin of the navigation historyTitle: title of history tiddler (defaults to $:/HistoryList) */ exports.addToHistory = function(title,fromPageRect,historyTitle) { - historyTitle = historyTitle || "$:/HistoryList"; - var titles = $tw.utils.isArray(title) ? title : [title]; - // Add a new record to the top of the history stack - var historyList = this.getTiddlerData(historyTitle,[]); - $tw.utils.each(titles,function(title) { - historyList.push({title: title, fromPageRect: fromPageRect}); - }); - this.setTiddlerData(historyTitle,historyList,{"current-tiddler": titles[titles.length-1]}); + var story = new $tw.Story({wiki: this, historyTitle: historyTitle}); + story.addToHistory(title,fromPageRect); }; /* diff --git a/core/ui/ViewTemplate/import.tid b/core/ui/ViewTemplate/import.tid index 5fca39226..9dc4a52ea 100644 --- a/core/ui/ViewTemplate/import.tid +++ b/core/ui/ViewTemplate/import.tid @@ -9,6 +9,9 @@ tags: $:/tags/ViewTemplate <> +<$button message="tm-delete-tiddler" param=<>><> +<$button message="tm-perform-import" param=<>><> + {{||$:/core/ui/ImportListing}} <$button message="tm-delete-tiddler" param=<>><> diff --git a/editions/prerelease/tiddlers/Release 5.1.10.tid b/editions/prerelease/tiddlers/Release 5.1.10.tid index 48fc1ef5c..04e553657 100644 --- a/editions/prerelease/tiddlers/Release 5.1.10.tid +++ b/editions/prerelease/tiddlers/Release 5.1.10.tid @@ -1,6 +1,6 @@ caption: 5.1.10 -created: 20150705153725652 -modified: 20150705153725652 +created: 20150801123725652 +modified: 20150801123725652 tags: ReleaseNotes title: Release 5.1.10 type: text/vnd.tiddlywiki @@ -11,7 +11,21 @@ type: text/vnd.tiddlywiki !! Performance Optimisations +This release includes several low-level performance optimisations that should improve speed and responsiveness in many common operations. +* [[Caching the results of parsing a tiddler|https://github.com/Jermolene/TiddlyWiki5/commit/b0cb17cd83dde89753ec159e27c920a7bf22bee1]] +* [[Loop optimisations|https://github.com/Jermolene/TiddlyWiki5/commit/c6e48ebc2db4af895f5b3935b3f575b8aab292fe]] +* [[Tiddler iteration optimisations|https://github.com/Jermolene/TiddlyWiki5/commit/8f63e2a959a7ac44533ae2b6192716ee17a1ce93]] +* [[State qualifier generation|https://github.com/Jermolene/TiddlyWiki5/commit/848a7f4e744c8f4dcb4ec88a0e99c4ae6aac25e5]] +* [[Caching data tiddlers|https://github.com/Jermolene/TiddlyWiki5/commit/32f6d7f1b01474b82debcbdd5d76c49c59303265]] + +!! Résumé Builder Edition + +The new [[Résumé Builder Edition]] by @inmysocks is a custom edition to guide you through the process of using TiddlyWiki to create a good looking résumé (or curriculum vitæ). + +!! Text-Slicer Edition + +The new [[Text-Slicer Edition]] is a custom edition with tools to help advanced users slice longer texts up into individual tiddlers. ! Other Improvements @@ -21,18 +35,26 @@ type: text/vnd.tiddlywiki !! Usability Improvements -* +* [[Added|https://github.com/Jermolene/TiddlyWiki5/commit/d5e690a06d523a2047eaf9b623b633bb72c18af9]] ability to disable individual WikiText parser rules (see the ''Advanced'' tab of $:/ControlPanel). Also [[added|https://github.com/Jermolene/TiddlyWiki5/commit/58188cf8053bef87dbe97e4b05cdba67f75c615d]] a simple setting for disabling automatic linking of ~CamelCase words +* [[Extended|https://github.com/Jermolene/TiddlyWiki5/commit/2cb6400773096b02b71c1851fb0fac5dfefbbd6f]] support for automatically linked system tiddler titles to include digits and underscore !! Hackability Improvements -* +* [[Added|https://github.com/Jermolene/TiddlyWiki5/commit/c4397792f5d396288048bcc3bb4ee8e95dbc2c5e]] added [[recent Operator]] +* [[Added|https://github.com/Jermolene/TiddlyWiki5/commit/e0aacc84d5f084ff7a53153c590fbff3d24f2e2c]] `publishFilter` to default save template +* [[Allow|https://github.com/Jermolene/TiddlyWiki5/commit/7dddc925ae93725552b98bc348a07572895da96c]] ''delete'' button to be used in the tiddler view-mode toolbar !! Bug Fixes -* +* [[Fixed|https://github.com/Jermolene/TiddlyWiki5/issues/1882]] problem introduced in 5.1.9 with processing `tiddlywiki.info` files +* [[Fixed|https://github.com/Jermolene/TiddlyWiki5/commit/3fbf29093b32c00941b0c03951250de7c0cc8d6f]] problem with invisible icons in $:/AdvancedSearch +* [[Improved|https://github.com/Jermolene/TiddlyWiki5/commit/862e358b57fde74595420e7948bf44fdadf690dc]] check for required plugins in ServerCommand !! Contributors [[@Jermolene|https://github.com/Jermolene]] would like to thank the contributors to this release who have generously given their time to help improve TiddlyWiki: +* [[@danielo515|https://github.com/danielo515]] +* [[@idoine|https://github.com/idoine]] +* [[@inmysocks|https://github.com/inmysocks]] * [[@nameanyone|https://github.com/nameanyone]] diff --git a/editions/prerelease/tiddlers/staging/editions/Resume_Builder_Edition.tid b/editions/prerelease/tiddlers/staging/editions/Resume_Builder_Edition.tid index d7ba1d210..281281413 100644 --- a/editions/prerelease/tiddlers/staging/editions/Resume_Builder_Edition.tid +++ b/editions/prerelease/tiddlers/staging/editions/Resume_Builder_Edition.tid @@ -6,4 +6,4 @@ type: text/vnd.tiddlywiki The ''Résumé Builder'' edition of TiddlyWiki gets you started with a simple way to create a professional resume that you can save to the web or print. -http://tiddlywiki.com/editions/resumebuilder/index.html +editions/resumebuilder/index.html diff --git a/editions/prerelease/tiddlers/staging/editions/Text_Slicer_Edition.tid b/editions/prerelease/tiddlers/staging/editions/Text_Slicer_Edition.tid new file mode 100644 index 000000000..0eac50183 --- /dev/null +++ b/editions/prerelease/tiddlers/staging/editions/Text_Slicer_Edition.tid @@ -0,0 +1,9 @@ +created: 20150718123139133 +modified: 20150718123255662 +tags: Editions +title: Text-Slicer Edition +type: text/vnd.tiddlywiki + +The ''Text-Slicer'' edition of TiddlyWiki contains tools to help advanced users slice long texts up into individual tiddlers. + +editions/text-slicer/index.html diff --git a/editions/text-slicer/tiddlers/HelloThere.tid b/editions/text-slicer/tiddlers/HelloThere.tid new file mode 100644 index 000000000..ea6d861b9 --- /dev/null +++ b/editions/text-slicer/tiddlers/HelloThere.tid @@ -0,0 +1,25 @@ +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.// + +The source document must first be marked up as an ordinary wikitext tiddler. Currently only the following formatting is recognised: + +* Headings +* Ordered and unordered lists +* Paragraphs + +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]] +#* It should match the content of [[Sample Text]] + +The table of contents at the top of the output tiddler shows how the document has been split up into individual tiddlers: + +* 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 diff --git a/editions/text-slicer/tiddlers/Sample Text.tid b/editions/text-slicer/tiddlers/Sample Text.tid new file mode 100644 index 000000000..8abb8fd4b --- /dev/null +++ b/editions/text-slicer/tiddlers/Sample Text.tid @@ -0,0 +1,96 @@ +title: Sample Text + +! Introduction to TiddlyWiki + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +!! What is TiddlyWiki used for? + +Dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +!!! Who uses TiddlyWiki? + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +!! Who makes TiddlyWiki? + +Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +!!! How open source projects work + +Dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +Tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur qui officia deserunt mollit anim id est laborum. + +Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +!!! How GitHub works + +Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +!! Tiddlers + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + + +!!! Tiddler types + +Dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +!!! Fields + +Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + + +Tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur qui officia deserunt mollit anim id est laborum. + +Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +!!!! Tags + +Tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur qui officia deserunt mollit anim id est laborum. + +!! Lists and Stories + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +!!! List widget + +Dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +!!! Story + +* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +* Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +!! Plugins + +Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +!! Saving changes and generating HTML files + +Dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +* Tempor incididunt ut labore et dolore magna aliqua + +* Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat + +* Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur + +* Excepteur qui officia deserunt mollit anim id est laborum + +!!! TiddlyFox + +Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +!! Syncing tiddlers with servers + +Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +!!! Browser Same Domain Origin Policy + +Tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur qui officia deserunt mollit anim id est laborum. + diff --git a/editions/text-slicer/tiddlers/system/DefaultTiddlers.tid b/editions/text-slicer/tiddlers/system/DefaultTiddlers.tid new file mode 100644 index 000000000..3b2facfe7 --- /dev/null +++ b/editions/text-slicer/tiddlers/system/DefaultTiddlers.tid @@ -0,0 +1,4 @@ +title: $:/DefaultTiddlers + +HelloThere +[[Sample Text]] \ No newline at end of file diff --git a/editions/text-slicer/tiddlywiki.info b/editions/text-slicer/tiddlywiki.info new file mode 100644 index 000000000..8fa0682e3 --- /dev/null +++ b/editions/text-slicer/tiddlywiki.info @@ -0,0 +1,17 @@ +{ + "description": "Tools for slicing up long texts into individual tiddlers", + "plugins": [ + "tiddlywiki/text-slicer" + ], + "languages": [ + ], + "themes": [ + "tiddlywiki/vanilla", + "tiddlywiki/snowwhite" + ], + "build": { + "index": [ + "--rendertiddler","$:/core/save/all","index.html","text/plain" + ] + } +} \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/editions/Empty Edition.tid b/editions/tw5.com/tiddlers/editions/Empty Edition.tid index 4e2b24ca5..ec72cb3bf 100644 --- a/editions/tw5.com/tiddlers/editions/Empty Edition.tid +++ b/editions/tw5.com/tiddlers/editions/Empty Edition.tid @@ -8,4 +8,4 @@ The "empty" edition of TiddlyWiki is a vanilla distribution, with no additional The empty edition can be downloaded from: -http://tiddlywiki.com/empty.html +empty.html diff --git a/editions/tw5.com/tiddlers/editions/Full Edition.tid b/editions/tw5.com/tiddlers/editions/Full Edition.tid index 8637ddc82..80aa1984d 100644 --- a/editions/tw5.com/tiddlers/editions/Full Edition.tid +++ b/editions/tw5.com/tiddlers/editions/Full Edition.tid @@ -8,4 +8,4 @@ The "full" edition of TiddlyWiki consists of all the available languages, themes The full edition can be downloaded from: -http://tiddlywiki.com/editions/full/index.html +editions/full/index.html diff --git a/plugins/tiddlywiki/text-slicer/macros.tid b/plugins/tiddlywiki/text-slicer/macros.tid new file mode 100644 index 000000000..bcba9bc62 --- /dev/null +++ b/plugins/tiddlywiki/text-slicer/macros.tid @@ -0,0 +1,27 @@ +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> +<> + + +\end + +\define display-list-tiddler(type:"ol") +<$type$> +<$list filter='[tag!has[draft.of]]'> +
  • +<$tiddler> +<> + +
  • + + +\end diff --git a/plugins/tiddlywiki/text-slicer/plugin.info b/plugins/tiddlywiki/text-slicer/plugin.info new file mode 100644 index 000000000..d45d1c3e4 --- /dev/null +++ b/plugins/tiddlywiki/text-slicer/plugin.info @@ -0,0 +1,7 @@ +{ + "title": "$:/plugins/tiddlywiki/text-slicer", + "description": "Tools for slicing text into tiddlers", + "author": "JeremyRuston", + "core-version": ">=5.0.0", + "list": "readme" +} diff --git a/plugins/tiddlywiki/text-slicer/readme.tid b/plugins/tiddlywiki/text-slicer/readme.tid new file mode 100644 index 000000000..a3859bf93 --- /dev/null +++ b/plugins/tiddlywiki/text-slicer/readme.tid @@ -0,0 +1,3 @@ +title: $:/plugins/tiddlywiki/text-slicer/readme + +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 new file mode 100644 index 000000000..371b15f17 --- /dev/null +++ b/plugins/tiddlywiki/text-slicer/slice-button.tid @@ -0,0 +1,13 @@ +title: $:/plugins/tiddlywiki/text-slicer/ui/slice-button +tags: $:/tags/ViewToolbar +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=<>> +<$list filter="[prefix[yes]]"> +{{$:/plugins/tiddlywiki/text-slicer/text-slicer-icon}} + +<$list filter="[prefix[yes]]"> +Slice tiddler + + \ No newline at end of file diff --git a/plugins/tiddlywiki/text-slicer/slicer.js b/plugins/tiddlywiki/text-slicer/slicer.js new file mode 100644 index 000000000..10f2013af --- /dev/null +++ b/plugins/tiddlywiki/text-slicer/slicer.js @@ -0,0 +1,159 @@ +/*\ +title: $:/plugins/tiddlywiki/text-slicer/slicer.js +type: application/javascript +module-type: startup + +Setup the root widget event handlers + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +// Export name and synchronous status +exports.name = "slicer"; +exports.platforms = ["browser"]; +exports.after = ["startup"]; +exports.synchronous = true; + +var SLICER_OUTPUT_TITLE = "$:/TextSlicer"; + +// Install the root widget event handlers +exports.startup = function() { + $tw.rootWidget.addEventListener("tm-slice-tiddler",function(event) { + // Slice up and output the tiddler + outputTiddlers(sliceTiddler(event.param),event.param); + }); +}; + +var currentId = 0; + +function nextId() { + return ++currentId; +} + +// Slice a tiddler into individual tiddlers +function sliceTiddler(title) { + var tiddlers = {}, + parser = $tw.wiki.parseTiddler(title), + parentStack = [], + addTiddler = function(fields) { + if(fields.title) { + tiddlers[fields.title] = $tw.utils.extend({},tiddlers[fields.title],fields); + return fields.title; + } else { + return null; + } + }, + addToList = function(parent,child) { + var parentTiddler = tiddlers[parent] || {}, + parentList = parentTiddler.list || []; + parentList.push(child); + addTiddler($tw.utils.extend({title: parent},parentTiddler,{list: parentList})); + }, + convertTypeToLevel = function(type) { + if(type.charAt(0) === "h") { + return parseInt(type.charAt(1),10); + } else { + return null; + } + }, + popParentStackUntil = function(type) { + // Pop the stack to remove any entries at the same or lower level + var newLevel = convertTypeToLevel(type), + topIndex = parentStack.length - 1; + do { + var topLevel = convertTypeToLevel(parentStack[parentStack.length - 1].type); + if(topLevel !== null && topLevel < newLevel ) { + break; + } + parentStack.length--; + } while(true); + return parentStack[parentStack.length - 1].title; + }, + processNodeList = function(nodeList) { + $tw.utils.each(nodeList,function(parseTreeNode) { + var parentTitle, + text = $tw.utils.getParseTreeText(parseTreeNode); + if(parseTreeNode.type === "element" && (parseTreeNode.tag === "h1" || parseTreeNode.tag === "h2" || parseTreeNode.tag === "h3" || parseTreeNode.tag === "h4")) { + parentTitle = popParentStackUntil(parseTreeNode.tag); + addToList(parentTitle,text); + parentStack.push({type: parseTreeNode.tag, title: addTiddler({ + title: text, + text: "<>", + list: [], + tags: [parentTitle] + })}); + } else if(parseTreeNode.type === "element" && (parseTreeNode.tag === "ul" || parseTreeNode.tag === "ol")) { + var listTitle = title + "-list-" + nextId(); + parentTitle = parentStack[parentStack.length - 1].title; + addToList(parentTitle,listTitle); + parentStack.push({type: parseTreeNode.tag, title: addTiddler({ + title: listTitle, + text: "<>", + list: [], + tags: [parentTitle] + })}); + processNodeList(parseTreeNode.children); + parentStack.pop(); + } else if(parseTreeNode.type === "element" && parseTreeNode.tag === "li") { + var listItemTitle = title + "-listitem-" + nextId(); + parentTitle = parentStack[parentStack.length - 1].title; + addToList(parentTitle,listItemTitle); + addTiddler({ + title: listItemTitle, + text: text, + list: [], + tags: [parentTitle] + }); + } else if(parseTreeNode.type === "element" && parseTreeNode.tag === "p") { + parentTitle = parentStack[parentStack.length - 1].title; + addToList(parentTitle,addTiddler({ + title: title + "-para-" + nextId(), + text: text, + tags: [parentTitle] + })); + } + }); + }; + if(parser) { + parentStack.push({type: "h0", title: addTiddler({ + title: "Sliced up " + title, + text: "
    \n\n<>\n\n
    \n<>", + list: [] + })}); + processNodeList(parser.tree); + } + return tiddlers; +} + +// Output to the output tiddler +function outputTiddlers(tiddlers,navigateFromTitle) { + // Get the current slicer output tiddler + var slicerOutputTiddler = $tw.wiki.getTiddler(SLICER_OUTPUT_TITLE), + slicerOutputData = $tw.wiki.getTiddlerData(SLICER_OUTPUT_TITLE,{}), + newFields = new Object({ + title: SLICER_OUTPUT_TITLE, + type: "application/json", + "plugin-type": "import", + "status": "pending" + }); + // Process each tiddler + slicerOutputData.tiddlers = slicerOutputData.tiddlers || {}; + $tw.utils.each(tiddlers,function(tiddlerFields) { + var title = tiddlerFields.title; + if(title) { + slicerOutputData.tiddlers[title] = tiddlerFields; + } + }); + // Save the slicer output tiddler + newFields.text = JSON.stringify(slicerOutputData,null,$tw.config.preferences.jsonSpaces); + $tw.wiki.addTiddler(new $tw.Tiddler(slicerOutputTiddler,newFields)); + // Navigate to output + var story = new $tw.Story({wiki: $tw.wiki}); + story.navigateTiddler(SLICER_OUTPUT_TITLE,navigateFromTitle); +} + +})(); diff --git a/plugins/tiddlywiki/text-slicer/text-slicer-icon.tid b/plugins/tiddlywiki/text-slicer/text-slicer-icon.tid new file mode 100644 index 000000000..41b6496c3 --- /dev/null +++ b/plugins/tiddlywiki/text-slicer/text-slicer-icon.tid @@ -0,0 +1,21 @@ +title: $:/plugins/tiddlywiki/text-slicer/text-slicer-icon +tags: $:/tags/Image + + + + + + + + + + + + + + + + + + + \ No newline at end of file