mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-01-25 20:33:41 +00:00
Compare commits
3 Commits
improved-r
...
genesis-wi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
243e2980f0 | ||
|
|
fb5786dcf0 | ||
|
|
227a5a0cd0 |
@@ -12,9 +12,6 @@ Adds tiddler filtering methods to the $tw.Wiki object.
|
|||||||
/*global $tw: false */
|
/*global $tw: false */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/* Maximum permitted filter recursion depth */
|
|
||||||
var MAX_FILTER_DEPTH = 300;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Parses an operation (i.e. a run) within a filter string
|
Parses an operation (i.e. a run) within a filter string
|
||||||
operators: Array of array of operator nodes into which results should be inserted
|
operators: Array of array of operator nodes into which results should be inserted
|
||||||
@@ -331,7 +328,7 @@ exports.compileFilter = function(filterString) {
|
|||||||
})());
|
})());
|
||||||
});
|
});
|
||||||
// Return a function that applies the operations to a source iterator of tiddler titles
|
// Return a function that applies the operations to a source iterator of tiddler titles
|
||||||
var fnMeasured = $tw.perf.measure("filter: " + filterString,function filterFunction(source,widget) {
|
var compiled = $tw.perf.measure("filter: " + filterString,function filterFunction(source,widget) {
|
||||||
if(!source) {
|
if(!source) {
|
||||||
source = self.each;
|
source = self.each;
|
||||||
} else if(typeof source === "object") { // Array or hashmap
|
} else if(typeof source === "object") { // Array or hashmap
|
||||||
@@ -341,15 +338,9 @@ exports.compileFilter = function(filterString) {
|
|||||||
widget = $tw.rootWidget;
|
widget = $tw.rootWidget;
|
||||||
}
|
}
|
||||||
var results = new $tw.utils.LinkedList();
|
var results = new $tw.utils.LinkedList();
|
||||||
self.filterRecursionCount = (self.filterRecursionCount || 0) + 1;
|
$tw.utils.each(operationFunctions,function(operationFunction) {
|
||||||
if(self.filterRecursionCount < MAX_FILTER_DEPTH) {
|
operationFunction(results,source,widget);
|
||||||
$tw.utils.each(operationFunctions,function(operationFunction) {
|
});
|
||||||
operationFunction(results,source,widget);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
results.push("/**-- Excessive filter recursion --**/");
|
|
||||||
}
|
|
||||||
self.filterRecursionCount = self.filterRecursionCount - 1;
|
|
||||||
return results.toArray();
|
return results.toArray();
|
||||||
});
|
});
|
||||||
if(this.filterCacheCount >= 2000) {
|
if(this.filterCacheCount >= 2000) {
|
||||||
@@ -359,9 +350,9 @@ exports.compileFilter = function(filterString) {
|
|||||||
this.filterCache = Object.create(null);
|
this.filterCache = Object.create(null);
|
||||||
this.filterCacheCount = 0;
|
this.filterCacheCount = 0;
|
||||||
}
|
}
|
||||||
this.filterCache[filterString] = fnMeasured;
|
this.filterCache[filterString] = compiled;
|
||||||
this.filterCacheCount++;
|
this.filterCacheCount++;
|
||||||
return fnMeasured;
|
return compiled;
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
/*\
|
|
||||||
title: $:/core/modules/widgets/error.js
|
|
||||||
type: application/javascript
|
|
||||||
module-type: widget
|
|
||||||
|
|
||||||
Error widget
|
|
||||||
|
|
||||||
\*/
|
|
||||||
(function(){
|
|
||||||
|
|
||||||
/*jslint node: true, browser: true */
|
|
||||||
/*global $tw: false */
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var Widget = require("$:/core/modules/widgets/widget.js").widget;
|
|
||||||
|
|
||||||
var ErrorWidget = function(parseTreeNode,options) {
|
|
||||||
this.initialise(parseTreeNode,options);
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
Inherit from the base widget class
|
|
||||||
*/
|
|
||||||
ErrorWidget.prototype = new Widget();
|
|
||||||
|
|
||||||
/*
|
|
||||||
Render this widget into the DOM
|
|
||||||
*/
|
|
||||||
ErrorWidget.prototype.render = function(parent,nextSibling) {
|
|
||||||
this.parentDomNode = parent;
|
|
||||||
this.computeAttributes();
|
|
||||||
this.execute();
|
|
||||||
var message = this.getAttribute("$message","Unknown error"),
|
|
||||||
domNode = this.document.createElement("span");
|
|
||||||
domNode.appendChild(this.document.createTextNode(message));
|
|
||||||
domNode.className = "tc-error";
|
|
||||||
parent.insertBefore(domNode,nextSibling);
|
|
||||||
this.domNodes.push(domNode);
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
Compute the internal state of the widget
|
|
||||||
*/
|
|
||||||
ErrorWidget.prototype.execute = function() {
|
|
||||||
// Nothing to do for a text node
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
|
|
||||||
*/
|
|
||||||
ErrorWidget.prototype.refresh = function(changedTiddlers) {
|
|
||||||
var changedAttributes = this.computeAttributes();
|
|
||||||
if(changedAttributes["$message"]) {
|
|
||||||
this.refreshSelf();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.error = ErrorWidget;
|
|
||||||
|
|
||||||
})();
|
|
||||||
@@ -51,9 +51,11 @@ LetWidget.prototype.computeAttributes = function() {
|
|||||||
$tw.utils.each($tw.utils.getOrderedAttributesFromParseTreeNode(this.parseTreeNode),function(attribute) {
|
$tw.utils.each($tw.utils.getOrderedAttributesFromParseTreeNode(this.parseTreeNode),function(attribute) {
|
||||||
var value = self.computeAttribute(attribute),
|
var value = self.computeAttribute(attribute),
|
||||||
name = attribute.name;
|
name = attribute.name;
|
||||||
// Now that it's prepped, we're allowed to look this variable up
|
if(name.charAt(0) !== "$") {
|
||||||
// when defining later variables
|
// Now that it's prepped, we're allowed to look this variable up
|
||||||
self.currentValueFor[name] = value;
|
// when defining later variables
|
||||||
|
self.currentValueFor[name] = value;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// Run through again, setting variables and looking for differences
|
// Run through again, setting variables and looking for differences
|
||||||
$tw.utils.each(this.currentValueFor,function(value,name) {
|
$tw.utils.each(this.currentValueFor,function(value,name) {
|
||||||
|
|||||||
@@ -12,9 +12,6 @@ Widget base class
|
|||||||
/*global $tw: false */
|
/*global $tw: false */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/* Maximum permitted depth of the widget tree for recursion detection */
|
|
||||||
var MAX_WIDGET_TREE_DEPTH = 1000;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Create a widget object for a parse tree node
|
Create a widget object for a parse tree node
|
||||||
parseTreeNode: reference to the parse tree node to be rendered
|
parseTreeNode: reference to the parse tree node to be rendered
|
||||||
@@ -361,20 +358,6 @@ Widget.prototype.assignAttributes = function(domNode,options) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
Get the number of ancestor widgets for this widget
|
|
||||||
*/
|
|
||||||
Widget.prototype.getAncestorCount = function() {
|
|
||||||
if(this.ancestorCount === undefined) {
|
|
||||||
if(this.parentWidget) {
|
|
||||||
this.ancestorCount = this.parentWidget.getAncestorCount() + 1;
|
|
||||||
} else {
|
|
||||||
this.ancestorCount = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.ancestorCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Make child widgets correspondng to specified parseTreeNodes
|
Make child widgets correspondng to specified parseTreeNodes
|
||||||
*/
|
*/
|
||||||
@@ -382,29 +365,21 @@ Widget.prototype.makeChildWidgets = function(parseTreeNodes,options) {
|
|||||||
options = options || {};
|
options = options || {};
|
||||||
this.children = [];
|
this.children = [];
|
||||||
var self = this;
|
var self = this;
|
||||||
// Check for too much recursion
|
// Create set variable widgets for each variable
|
||||||
if(this.getAncestorCount() > MAX_WIDGET_TREE_DEPTH) {
|
$tw.utils.each(options.variables,function(value,name) {
|
||||||
this.children.push(this.makeChildWidget({type: "error", attributes: {
|
var setVariableWidget = {
|
||||||
"$message": {type: "string", value: $tw.language.getString("Error/RecursiveTransclusion")}
|
type: "set",
|
||||||
}}));
|
attributes: {
|
||||||
} else {
|
name: {type: "string", value: name},
|
||||||
// Create set variable widgets for each variable
|
value: {type: "string", value: value}
|
||||||
$tw.utils.each(options.variables,function(value,name) {
|
},
|
||||||
var setVariableWidget = {
|
children: parseTreeNodes
|
||||||
type: "set",
|
};
|
||||||
attributes: {
|
parseTreeNodes = [setVariableWidget];
|
||||||
name: {type: "string", value: name},
|
});
|
||||||
value: {type: "string", value: value}
|
$tw.utils.each(parseTreeNodes || (this.parseTreeNode && this.parseTreeNode.children),function(childNode) {
|
||||||
},
|
self.children.push(self.makeChildWidget(childNode));
|
||||||
children: parseTreeNodes
|
});
|
||||||
};
|
|
||||||
parseTreeNodes = [setVariableWidget];
|
|
||||||
});
|
|
||||||
// Create the child widgets
|
|
||||||
$tw.utils.each(parseTreeNodes || (this.parseTreeNode && this.parseTreeNode.children),function(childNode) {
|
|
||||||
self.children.push(self.makeChildWidget(childNode));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
caption: 5.2.4
|
caption: 5.2.4
|
||||||
created: 20220924141149286
|
created: 20220802100223020
|
||||||
modified: 20220924141149286
|
modified: 20220902201505817
|
||||||
tags: ReleaseNotes
|
tags: ReleaseNotes
|
||||||
title: Release 5.2.4
|
title: Release 5.2.4
|
||||||
type: text/vnd.tiddlywiki
|
type: text/vnd.tiddlywiki
|
||||||
@@ -31,11 +31,9 @@ Improvements to the translation features of TiddlyWiki:
|
|||||||
|
|
||||||
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/d62a16ee464fb9984b766b48504829a1a3eb143b">> problem with long presses on tiddler links triggering a preview on iOS/iPadOS
|
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/d62a16ee464fb9984b766b48504829a1a3eb143b">> problem with long presses on tiddler links triggering a preview on iOS/iPadOS
|
||||||
* <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/pull/6910">> consistency of button and input elements across browsers
|
* <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/pull/6910">> consistency of button and input elements across browsers
|
||||||
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/d825f1c875f5e46158c9c41c8c66471138c162d1">> edit preview to use the [[View Template Body Cascade]]
|
|
||||||
|
|
||||||
! Widget Improvements
|
! Widget Improvements
|
||||||
|
|
||||||
* <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/6961">> new GenesisWidget that allows the dynamic construction of another widget, where the name and attributes of the new widget can be dynamically determined, without needing to be known in advance
|
|
||||||
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/127f660c91020dcbb43897d954066b31af729e74">> EditTextWidget to remove the default text "Type the text for the tiddler 'foo'"
|
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/127f660c91020dcbb43897d954066b31af729e74">> EditTextWidget to remove the default text "Type the text for the tiddler 'foo'"
|
||||||
|
|
||||||
! Filter improvements
|
! Filter improvements
|
||||||
@@ -45,10 +43,6 @@ Improvements to the translation features of TiddlyWiki:
|
|||||||
! Hackability Improvements
|
! Hackability Improvements
|
||||||
|
|
||||||
* <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/6936">> new operators for reading and formatting JSON data: [[jsonget Operator]], [[jsonindexes Operator]], [[jsontype Operator]] and [[format Operator]]
|
* <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/6936">> new operators for reading and formatting JSON data: [[jsonget Operator]], [[jsonindexes Operator]], [[jsontype Operator]] and [[format Operator]]
|
||||||
* <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/commit/c5d3d4c26e8fe27f272dda004aec27d6b66c4f60">> safe mode to disable wiki store indexers
|
|
||||||
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/166a1565843878083fb1eba47c73b8e67b78400d">> safe mode to prevent globally disabling parser rules
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
! Bug Fixes
|
! Bug Fixes
|
||||||
|
|
||||||
@@ -60,29 +54,21 @@ Improvements to the translation features of TiddlyWiki:
|
|||||||
|
|
||||||
! Node.js Improvements
|
! Node.js Improvements
|
||||||
|
|
||||||
* <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/pull/6947">> console logging to avoid spaces and `<empty string>` message
|
*
|
||||||
|
|
||||||
! Performance Improvements
|
! Performance Improvements
|
||||||
|
|
||||||
* <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/commit/53d229592df76c6dd607e40be5bea4d5e063c48e">> performance of `wiki.getTiddler()`
|
*
|
||||||
* <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/commit/81ac9874846b3ead275f67010fcfdb49f3d2f43c">> performance of variable prototype chain handling
|
|
||||||
|
|
||||||
|
|
||||||
! Acknowledgements
|
! Acknowledgements
|
||||||
|
|
||||||
[[@Jermolene|https://github.com/Jermolene]] would like to thank the contributors to this release who have generously given their time to help improve TiddlyWiki:
|
[[@Jermolene|https://github.com/Jermolene]] would like to thank the contributors to this release who have generously given their time to help improve TiddlyWiki:
|
||||||
|
|
||||||
<<.contributors """
|
<<.contributors """
|
||||||
bestony
|
|
||||||
BramChen
|
BramChen
|
||||||
flibbles
|
|
||||||
fu-sen
|
fu-sen
|
||||||
Marxsal
|
|
||||||
oflg
|
oflg
|
||||||
pmario
|
pmario
|
||||||
rmunn
|
|
||||||
roma0104
|
|
||||||
tw-FRed
|
|
||||||
twMat
|
twMat
|
||||||
xcazin
|
xcazin
|
||||||
""">>
|
""">>
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
title: Filters/Recursion
|
|
||||||
description: Filter recursion detection
|
|
||||||
type: text/vnd.tiddlywiki-multiple
|
|
||||||
tags: [[$:/tags/wiki-test-spec]]
|
|
||||||
|
|
||||||
title: Output
|
|
||||||
|
|
||||||
\whitespace trim
|
|
||||||
\define myfilter() [subfilter<myfilter>]
|
|
||||||
|
|
||||||
<$text text={{{ [subfilter<myfilter>] }}}/>
|
|
||||||
+
|
|
||||||
title: ExpectedResult
|
|
||||||
|
|
||||||
<p>/**-- Excessive filter recursion --**/</p>
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
title: Transclude/Recursion
|
|
||||||
description: Transclusion recursion detection
|
|
||||||
type: text/vnd.tiddlywiki-multiple
|
|
||||||
tags: [[$:/tags/wiki-test-spec]]
|
|
||||||
|
|
||||||
title: Output
|
|
||||||
|
|
||||||
\whitespace trim
|
|
||||||
<$transclude $tiddler="Output"/>
|
|
||||||
+
|
|
||||||
title: ExpectedResult
|
|
||||||
|
|
||||||
<p><span class="tc-error">Recursive transclusion error in transclude widget</span></p>
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
caption: error
|
|
||||||
created: 20220909111836951
|
|
||||||
modified: 20220909111836951
|
|
||||||
tags: Widgets
|
|
||||||
title: ErrorWidget
|
|
||||||
type: text/vnd.tiddlywiki
|
|
||||||
|
|
||||||
<<.from-version "5.3.0">> The <<.wlink ErrorWidget>> widget is used by the core to display error messages such as the recursion errors reported by the <<.wlink TranscludeWidget>> widget.
|
|
||||||
|
|
||||||
The <<.wlink ErrorWidget>> does not provide any useful functionality to end users. It is only required by the core for technical reasons.
|
|
||||||
|
|
||||||
! Content and Attributes
|
|
||||||
|
|
||||||
The content of the <<.wlink ErrorWidget>> widget is ignored.
|
|
||||||
|
|
||||||
|!Attribute |!Description |
|
|
||||||
|$message |The error message |
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
title: LetWidget
|
title: LetWidget
|
||||||
created: 20211028115900000
|
created: 20211028115900000
|
||||||
modified: 20221001094658854
|
|
||||||
tags: Widgets
|
tags: Widgets
|
||||||
caption: let
|
caption: let
|
||||||
|
|
||||||
@@ -13,12 +12,10 @@ caption: let
|
|||||||
The content of the <<.wid let>> widget is the scope for the value assigned to the variable.
|
The content of the <<.wid let>> widget is the scope for the value assigned to the variable.
|
||||||
|
|
||||||
|!Attribute |!Description |
|
|!Attribute |!Description |
|
||||||
|//{attributes}// |Each attribute name specifies a variable name. The attribute value is assigned to the variable |
|
|//{attributes not starting with $}// |Each attribute name specifies a variable name. The attribute value is assigned to the variable |
|
||||||
|
|
||||||
Attributes are evaluated in the order they are written. Attributes with the same name are allowed. Each time a duplicate attribute is encountered, it will replace the existing value set by the earlier duplicate.
|
Attributes are evaluated in the order they are written. Attributes with the same name are allowed. Each time a duplicate attribute is encountered, it will replace the existing value set by the earlier duplicate.
|
||||||
|
|
||||||
<<.note """<<.from-version "5.2.4">> There is no longer any restriction on using variable names that start with the $ character.""">>
|
|
||||||
|
|
||||||
! Examples
|
! Examples
|
||||||
|
|
||||||
Consider a case where you need to set multiple variables, where some depend on the evaluation of others.
|
Consider a case where you need to set multiple variables, where some depend on the evaluation of others.
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ The main module of the Jasmine test plugin for TiddlyWiki5
|
|||||||
/*global $tw: true */
|
/*global $tw: true */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var TEST_TIDDLER_FILTER = "[all[tiddlers+shadows]type[application/javascript]tag[$:/tags/test-spec]]";
|
var TEST_TIDDLER_FILTER = "[type[application/javascript]tag[$:/tags/test-spec]]";
|
||||||
|
|
||||||
exports.name = "jasmine";
|
exports.name = "jasmine";
|
||||||
// Ensure this startup module is executed in the right order.
|
// Ensure this startup module is executed in the right order.
|
||||||
|
|||||||
Reference in New Issue
Block a user