From 0f78c4afbf74d13ee7a31bd81b3dd5f95d958664 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sat, 12 Jul 2014 09:07:51 +0100 Subject: [PATCH 01/42] Fix problem with tabs macro changing current tiddler The problem was introduced in e18d8a88661a1c2caa1b722841747c75ca6af437 --- core/wiki/macros/tabs.tid | 6 +----- editions/tw5.com/tiddlers/ReleaseHistoryTemplate.tid | 6 +++--- editions/tw5.com/tiddlers/macros/TabsMacro.tid | 2 ++ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/core/wiki/macros/tabs.tid b/core/wiki/macros/tabs.tid index 8d6d2d8fb..c7c749ed2 100644 --- a/core/wiki/macros/tabs.tid +++ b/core/wiki/macros/tabs.tid @@ -16,16 +16,12 @@ tags: $:/tags/Macro <$reveal type="match" state=<> text=<> default="$default$"> -<$tiddler tiddler=<>> - <$transclude tiddler="$template$" mode="block"> -<$transclude mode="block"/> +<$transclude tiddler=<> mode="block"/> - - diff --git a/editions/tw5.com/tiddlers/ReleaseHistoryTemplate.tid b/editions/tw5.com/tiddlers/ReleaseHistoryTemplate.tid index da4ebc11c..2f4eb2500 100644 --- a/editions/tw5.com/tiddlers/ReleaseHistoryTemplate.tid +++ b/editions/tw5.com/tiddlers/ReleaseHistoryTemplate.tid @@ -1,7 +1,7 @@ title: ReleaseHistoryTemplate -

<$link ><$view field="title"/>

+

<$link to=<>><$view tiddler=<> field="title"/>

-^^Released <$view field="released" format="date" template="DDth MMM YYYY at 0hh:0mm">TBA^^ +^^Released <$view tiddler=<> field="released" format="date" template="DDth MMM YYYY at 0hh:0mm">TBA^^ -<$transclude/> +<$transclude tiddler=<> /> diff --git a/editions/tw5.com/tiddlers/macros/TabsMacro.tid b/editions/tw5.com/tiddlers/macros/TabsMacro.tid index 47f66deb6..934fffef0 100644 --- a/editions/tw5.com/tiddlers/macros/TabsMacro.tid +++ b/editions/tw5.com/tiddlers/macros/TabsMacro.tid @@ -17,6 +17,8 @@ By default the tab control arranges the tabs horizontally with the content under |4th |class |Additional CSS classes for the three wrappers DIV of the tab | | |5th |template |Optional template through which to render the tab content | | +Within the template the title of the current tab is available in the widget variable ''currentTab''. + ! Examples Here is an example of the tabs macro: From 9de679b84bdabac16c54e81513bae1b479b4b01d Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sat, 12 Jul 2014 09:08:20 +0100 Subject: [PATCH 02/42] Fix tiddler widget to refresh properly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously wasn’t refreshing for changes to the tiddler that it refers to --- core/modules/widgets/tiddler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/modules/widgets/tiddler.js b/core/modules/widgets/tiddler.js index fab6c9c29..b7521fd34 100755 --- a/core/modules/widgets/tiddler.js +++ b/core/modules/widgets/tiddler.js @@ -53,7 +53,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of */ TiddlerWidget.prototype.refresh = function(changedTiddlers) { var changedAttributes = this.computeAttributes(); - if(changedAttributes.tiddler) { + if(changedAttributes.tiddler || changedTiddlers[this.tiddlerTitle]) { this.refreshSelf(); return true; } else { From b9bf1ff574607adba012e3ba71d40e975b653c76 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sat, 12 Jul 2014 09:08:38 +0100 Subject: [PATCH 03/42] Add plugin.info to tw2parser Every plugin must have a plugin.info file to be valid --- plugins/tiddlywiki/tw2parser/plugin.info | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 plugins/tiddlywiki/tw2parser/plugin.info diff --git a/plugins/tiddlywiki/tw2parser/plugin.info b/plugins/tiddlywiki/tw2parser/plugin.info new file mode 100644 index 000000000..8d39915e4 --- /dev/null +++ b/plugins/tiddlywiki/tw2parser/plugin.info @@ -0,0 +1,6 @@ +{ + "title": "$:/plugins/tiddlywiki/tw2parser", + "description": "TiddlyWiki Classic-compatible wikitext parser", + "author": "JeremyRuston", + "core-version": ">=5.0.0" +} From 4743d0a8637fd7143106d06c2aa58a734ca8801d Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sat, 12 Jul 2014 09:08:52 +0100 Subject: [PATCH 04/42] Fix transclusion recursion detection We were inadvertantly doing the recursion check before we were checking if the transclusion target exists. --- core/modules/widgets/transclude.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/core/modules/widgets/transclude.js b/core/modules/widgets/transclude.js index 485220937..18570036f 100755 --- a/core/modules/widgets/transclude.js +++ b/core/modules/widgets/transclude.js @@ -42,14 +42,6 @@ TranscludeWidget.prototype.execute = function() { this.transcludeField = this.getAttribute("field"); this.transcludeIndex = this.getAttribute("index"); this.transcludeMode = this.getAttribute("mode"); - // Check for recursion - var recursionMarker = this.makeRecursionMarker(); - if(this.parentWidget && this.parentWidget.hasVariable("transclusion",recursionMarker)) { - this.makeChildWidgets([{type: "text", text: "Recursive transclusion error in transclude widget"}]); - return; - } - // Set context variables for recursion detection - this.setVariable("transclusion",recursionMarker); // Parse the text reference var parseAsInline = !this.parseTreeNode.isBlock; if(this.transcludeMode === "inline") { @@ -63,6 +55,16 @@ TranscludeWidget.prototype.execute = function() { this.transcludeIndex, {parseAsInline: parseAsInline}), parseTreeNodes = parser ? parser.tree : this.parseTreeNode.children; + // Set context variables for recursion detection + var recursionMarker = this.makeRecursionMarker(); + this.setVariable("transclusion",recursionMarker); + // Check for recursion + if(parser) { + if(this.parentWidget && this.parentWidget.hasVariable("transclusion",recursionMarker)) { + parseTreeNodes = [{type: "text", text: "Recursive transclusion error in transclude widget"}]; + return; + } + } // Construct the child widgets this.makeChildWidgets(parseTreeNodes); }; From f08f57c5d24eb0146ac2cb77472a5fc5f135f1e9 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sat, 12 Jul 2014 09:09:13 +0100 Subject: [PATCH 05/42] Extend checkbox widget to toggle fields --- core/modules/widgets/checkbox.js | 56 +++++++++++++++---- .../tiddlers/widgets/CheckboxWidget.tid | 31 +++++++++- 2 files changed, 74 insertions(+), 13 deletions(-) diff --git a/core/modules/widgets/checkbox.js b/core/modules/widgets/checkbox.js index 07cb95a7a..4ac023bc8 100644 --- a/core/modules/widgets/checkbox.js +++ b/core/modules/widgets/checkbox.js @@ -55,22 +55,52 @@ CheckboxWidget.prototype.render = function(parent,nextSibling) { CheckboxWidget.prototype.getValue = function() { var tiddler = this.wiki.getTiddler(this.checkboxTitle); - return tiddler ? tiddler.hasTag(this.checkboxTag) : false; + if(tiddler) { + if(this.checkboxTag) { + return tiddler.hasTag(this.checkboxTag); + } + if(this.checkboxField) { + var value = tiddler.fields[this.checkboxField] || this.checkboxDefault || ""; + if(value === this.checkboxChecked) { + return true; + } + if(value === this.checkboxUnchecked) { + return false; + } + } + } + return false; }; CheckboxWidget.prototype.handleChangeEvent = function(event) { var checked = this.inputDomNode.checked, - tiddler = this.wiki.getTiddler(this.checkboxTitle); - if(tiddler && tiddler.hasTag(this.checkboxTag) !== checked) { - var newTags = (tiddler.fields.tags || []).slice(0), - pos = newTags.indexOf(this.checkboxTag); - if(pos !== -1) { - newTags.splice(pos,1); + tiddler = this.wiki.getTiddler(this.checkboxTitle), + newFields = {}, + hasChanged = false; + if(tiddler) { + // Set the tag if specified + if(this.checkboxTag && tiddler.hasTag(this.checkboxTag) !== checked) { + newFields.tags = (tiddler.fields.tags || []).slice(0); + var pos = newFields.tags.indexOf(this.checkboxTag); + if(pos !== -1) { + newFields.tags.splice(pos,1); + } + if(checked) { + newFields.tags.push(this.checkboxTag); + } + hasChanged = true; } - if(checked) { - newTags.push(this.checkboxTag); + // Set the field if specified + if(this.checkboxField) { + var value = checked ? this.checkboxChecked : this.checkboxUnchecked; + if(tiddler.fields[this.checkboxField] !== value) { + newFields[this.checkboxField] = value; + hasChanged = true; + } + } + if(hasChanged) { + this.wiki.addTiddler(new $tw.Tiddler(tiddler,newFields,this.wiki.getModificationFields())); } - this.wiki.addTiddler(new $tw.Tiddler(tiddler,{tags: newTags},this.wiki.getModificationFields())); } }; @@ -81,6 +111,10 @@ CheckboxWidget.prototype.execute = function() { // Get the parameters from the attributes this.checkboxTitle = this.getAttribute("tiddler",this.getVariable("currentTiddler")); this.checkboxTag = this.getAttribute("tag"); + this.checkboxField = this.getAttribute("field"); + this.checkboxChecked = this.getAttribute("checked"); + this.checkboxUnchecked = this.getAttribute("unchecked"); + this.checkboxDefault = this.getAttribute("default"); // Make the child widgets this.makeChildWidgets(); }; @@ -90,7 +124,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of */ CheckboxWidget.prototype.refresh = function(changedTiddlers) { var changedAttributes = this.computeAttributes(); - if(changedAttributes.tiddler || changedAttributes.tag || changedAttributes["class"]) { + if(changedAttributes.tiddler || changedAttributes.tag || changedAttributes.field || changedAttributes.checked || changedAttributes.unchecked || changedAttributes["default"] || changedAttributes["class"]) { this.refreshSelf(); return true; } else { diff --git a/editions/tw5.com/tiddlers/widgets/CheckboxWidget.tid b/editions/tw5.com/tiddlers/widgets/CheckboxWidget.tid index a17090702..3ac13ba40 100644 --- a/editions/tw5.com/tiddlers/widgets/CheckboxWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/CheckboxWidget.tid @@ -1,11 +1,14 @@ title: CheckboxWidget created: 201310241419 -modified: 201310300837 +modified: 201407110837 tags: widget ! Introduction -The checkbox widget displays an HTML `` element that is dynamically bound to the presence or absence of a specified tag on a specified tiddler. +The checkbox widget displays an HTML `` element that is dynamically bound to either: + +* the presence or absence of a specified tag on a specified tiddler +* the value of a specified field of a specified tiddler ! Content and Attributes @@ -14,3 +17,27 @@ The content of the `<$checkbox>` widget is displayed within an HTML `