1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-09-29 23:40:45 +00:00

Merge branch 'master' into demo-alternate-store

This commit is contained in:
jeremy@jermolene.com 2023-06-22 09:17:55 +01:00
commit 3561318515
143 changed files with 1707 additions and 491 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
.DS_Store
.c9/
.vs/
.vscode/
tmp/
output/

View File

@ -107,7 +107,7 @@ node $TW5_BUILD_TIDDLYWIKI \
# /empty.html Empty
# /empty.hta For Internet Explorer
node $TW5_BUILD_TIDDLYWIKI \
$TW5_BUILD_MAIN_EDITION \
./editions/empty \
--verbose \
--output $TW5_BUILD_OUTPUT \
--build empty \

View File

@ -569,26 +569,17 @@ $tw.utils.getTypeEncoding = function(ext) {
return typeInfo ? typeInfo.encoding : "utf8";
};
var polyfill =[
"// this polyfills the globalThis variable",
"// using the this variable on a getter ",
"// inserted into the prototype of globalThis",
"(function() {",
" if (typeof globalThis === 'object') return;",
" // node.green says this is available since 0.10.48",
" Object.prototype.__defineGetter__('__temp__', function() {",
" return this;",
" });",
" __temp__.globalThis = __temp__;",
" delete Object.prototype.__temp__;",
"}());"
].join("\n");
var globalCheck =[
" if(Object.keys(globalThis).length){",
" console.log(Object.keys(globalThis));",
" Object.defineProperty(Object.prototype, '__temp__', {",
" get: function () { return this; },",
" configurable: true",
" });",
" if(Object.keys(__temp__).length){",
" console.log(Object.keys(__temp__));",
" delete Object.prototype.__temp__;",
" throw \"Global assignment is not allowed within modules on node.\";",
" }"
" }",
" delete Object.prototype.__temp__;",
].join('\n');
/*
@ -604,7 +595,6 @@ $tw.utils.evalGlobal = function(code,context,filename,sandbox,allowGlobals) {
});
// Add the code prologue and epilogue
code = [
(!$tw.browser ? polyfill : ""),
"(function(" + contextNames.join(",") + ") {",
" (function(){\n" + code + "\n;})();",
(!$tw.browser && sandbox && !allowGlobals) ? globalCheck : "",
@ -2090,7 +2080,11 @@ $tw.loadPluginFolder = function(filepath,excludeRegExp) {
console.log("Warning: missing plugin.info file in " + filepath);
return null;
}
var pluginInfo = $tw.utils.parseJSONSafe(fs.readFileSync(infoPath,"utf8"));
var pluginInfo = $tw.utils.parseJSONSafe(fs.readFileSync(infoPath,"utf8"),function() {return null;});
if(!pluginInfo) {
console.log("warning: invalid JSON in plugin.info file at " + infoPath);
pluginInfo = {};
}
// Read the plugin files
var pluginFiles = $tw.loadTiddlersFromPath(filepath,excludeRegExp);
// Save the plugin tiddlers into the plugin info
@ -2207,7 +2201,11 @@ $tw.loadWikiTiddlers = function(wikiPath,options) {
pluginFields;
// Bail if we don't have a wiki info file
if(fs.existsSync(wikiInfoPath)) {
wikiInfo = $tw.utils.parseJSONSafe(fs.readFileSync(wikiInfoPath,"utf8"));
wikiInfo = $tw.utils.parseJSONSafe(fs.readFileSync(wikiInfoPath,"utf8"),function() {return null;});
if(!wikiInfo) {
console.log("warning: invalid JSON in tiddlywiki.info file at " + wikiInfoPath);
wikiInfo = {};
}
} else {
return null;
}

View File

@ -3,7 +3,7 @@ title: $:/Acknowledgements
TiddlyWiki incorporates code from these fine OpenSource projects:
* [[The Stanford Javascript Crypto Library|http://bitwiseshiftleft.github.io/sjcl/]]
* [[The Jasmine JavaScript Test Framework|http://pivotal.github.io/jasmine/]]
* [[The Jasmine JavaScript Test Framework|https://jasmine.github.io/]]
* [[Normalize.css by Nicolas Gallagher|http://necolas.github.io/normalize.css/]]
And media from these projects:

View File

@ -0,0 +1,11 @@
title: $:/core/images/network-activity
tags: $:/tags/Image
<svg width="22pt" height="22pt" class="tc-image-network-activity tc-image-button" viewBox="0 0 128 128"><g class={{{ [{$:/state/http-requests}match[0]then[]else[tc-network-activity-background]] }}}>
<$list filter="[{$:/state/http-requests}match[0]]" variable="ignore">
<path d="M64.043 45.153a4.002 4.002 0 0 1 4.367 2.21l.084.188 30.403 73.4a4 4 0 0 1-7.307 3.25l-.084-.188-3.103-7.49-8.898 8.899a3.985 3.985 0 0 1-2.624 1.166l-.205.005a3.987 3.987 0 0 1-2.828-1.171l-9.849-9.848-9.847 9.848a3.985 3.985 0 0 1-2.624 1.166l-.204.005a3.987 3.987 0 0 1-2.829-1.171l-8.899-8.9-3.102 7.491a4 4 0 1 1-7.391-3.062l30.403-73.4a4.001 4.001 0 0 1 4.495-2.39l.042-.008Zm13.636 56.74-8.023 8.024 7.02 7.019 8.023-8.022-7.02-7.02Zm-27.353.008-7.019 7.019 8.016 8.016 7.019-7.02-8.016-8.015Zm13.68-13.68-8.023 8.023 8.016 8.016 8.023-8.023-8.016-8.016Zm-8.971-8.971-4.687 11.315 8.001-8.001-3.314-3.314Zm17.933.009-3.305 3.305 7.979 7.979-4.674-11.284ZM64 57.607l-5.666 13.68c.096.072.188.15.278.232l.133.126 5.261 5.262 5.262-5.262c.128-.127.261-.244.4-.35L64 57.607Zm0-34.69a8 8 0 1 1 0 16 8 8 0 0 1 0-16Z"/>
</$list>
<$list filter="[{$:/state/http-requests}!match[0]]" variable="ignore">
<path d="M109.395.952a4.002 4.002 0 0 1 3.787 2.708C117.529 11.62 120 20.753 120 30.462c0 15.186-6.044 28.96-15.858 39.047a4 4 0 1 1-6.47-4.626l-.12-.094C106.466 56.074 112 43.914 112 30.462c0-8.492-2.205-16.469-6.074-23.39l.054-.036a4 4 0 0 1 3.415-6.084Zm-90.762 0a4 4 0 0 1 3.072 6.562l.093.06A47.786 47.786 0 0 0 16 30.463c0 13.315 5.42 25.363 14.176 34.058l-.01.007a4 4 0 1 1-6.312 4.863l-.063.05C14.017 59.359 8 45.613 8 30.462c0-9.77 2.502-18.956 6.9-26.952A4.002 4.002 0 0 1 18.634.952Z"/><path d="M64.043 44.698a4.002 4.002 0 0 1 4.367 2.21l.084.188 30.403 73.4a4 4 0 0 1-7.307 3.25l-.084-.188-3.103-7.49-8.898 8.9a3.985 3.985 0 0 1-2.624 1.166l-.205.005a3.987 3.987 0 0 1-2.828-1.172l-9.849-9.848-9.847 9.848a3.985 3.985 0 0 1-2.624 1.167l-.204.005a3.987 3.987 0 0 1-2.829-1.172l-8.899-8.899-3.102 7.49a4 4 0 0 1-7.391-3.061l30.403-73.4a4.001 4.001 0 0 1 4.495-2.39l.042-.009ZM77.68 101.44l-8.023 8.023 7.02 7.019 8.023-8.022-7.02-7.02Zm-27.353.007-7.019 7.019 8.016 8.016 7.019-7.019-8.016-8.016Zm13.68-13.68-8.023 8.023 8.016 8.016 8.023-8.023-8.016-8.016Zm-8.971-8.971L50.348 90.11l8.001-8.001-3.314-3.314Zm17.933.009-3.305 3.305 7.979 7.979-4.674-11.284ZM64 57.152l-5.666 13.68c.096.073.188.15.278.232l.133.127 5.261 5.261 5.262-5.261c.128-.128.261-.244.4-.351L64 57.152ZM38.503 1.058a4 4 0 0 1 2.7 6.952l.17-.175C35.582 13.625 32 21.625 32 30.462c0 8.838 3.582 16.838 9.374 22.629a4 4 0 0 1-5.659 5.658l-.01.01C28.473 51.52 24 41.526 24 30.485 24 19.567 28.374 9.67 35.466 2.453a3.995 3.995 0 0 1 3.037-1.395ZM89.369.952c1.14 0 2.17.478 2.899 1.244l.005-.006C99.518 9.43 104 19.434 104 30.485c0 10.826-4.3 20.648-11.287 27.85a4 4 0 1 1-6.054-5.213l-.032-.032C92.418 47.299 96 39.299 96 30.462c0-8.73-3.496-16.643-9.164-22.416A4 4 0 0 1 89.368.952Zm-39.282 11.14a4 4 0 0 1 2.59 7.048l.01.009A15.95 15.95 0 0 0 48 30.462a15.95 15.95 0 0 0 4.687 11.315l-.01.01a4 4 0 1 1-5.82 5.47l.173.177A23.925 23.925 0 0 1 40 30.462a23.925 23.925 0 0 1 7.03-16.97l.01.01a3.991 3.991 0 0 1 3.047-1.41Zm27.895.07a3.99 3.99 0 0 1 2.984 1.336l.006-.005A23.925 23.925 0 0 1 88 30.463a23.92 23.92 0 0 1-6.707 16.642l-.3.305a4 4 0 1 1-5.679-5.632v-.002A15.95 15.95 0 0 0 80 30.462a15.95 15.95 0 0 0-4.685-11.312 4.012 4.012 0 0 1-1.333-2.987 4 4 0 0 1 4-4ZM64 22.463a8 8 0 1 1 0 16 8 8 0 0 1 0-16Z"/>
</$list>
</g></svg>

View File

@ -67,6 +67,8 @@ More/Caption: more
More/Hint: More actions
NewHere/Caption: new here
NewHere/Hint: Create a new tiddler tagged with this one
NetworkActivity/Caption: network activity
NetworkActivity/Hint: Cancel all network activity
NewJournal/Caption: new journal
NewJournal/Hint: Create a new journal tiddler
NewJournalHere/Caption: new journal here

View File

@ -18,7 +18,7 @@ All parameters are optional with safe defaults, and can be specified in any orde
* ''anon-username'' - the username for signing edits for anonymous users
* ''username'' - optional username for basic authentication
* ''password'' - optional password for basic authentication
* ''authenticated-user-header'' - optional name of header to be used for trusted authentication
* ''authenticated-user-header'' - optional name of request header to be used for trusted authentication.
* ''readers'' - comma-separated list of principals allowed to read from this wiki
* ''writers'' - comma-separated list of principals allowed to write to this wiki
* ''csrf-disable'' - set to "yes" to disable CSRF checks (defaults to "no")

View File

@ -25,6 +25,8 @@ Encryption/RepeatPassword: Repeat password
Encryption/PasswordNoMatch: Passwords do not match
Encryption/SetPassword: Set password
Error/Caption: Error
Error/DeserializeOperator/MissingOperand: Filter Error: Missing operand for 'deserialize' operator
Error/DeserializeOperator/UnknownDeserializer: Filter Error: Unknown deserializer provided as operand for the 'deserialize' operator
Error/Filter: Filter error
Error/FilterSyntax: Syntax error in filter expression
Error/FilterRunPrefix: Filter Error: Unknown prefix for filter run

View File

@ -1,3 +1,3 @@
title: $:/SiteTitle
My ~TiddlyWiki
My TiddlyWiki

View File

@ -12,6 +12,8 @@ Adds tiddler filtering methods to the $tw.Wiki object.
/*global $tw: false */
"use strict";
var widgetClass = require("$:/core/modules/widgets/widget.js").widget;
/* Maximum permitted filter recursion depth */
var MAX_FILTER_DEPTH = 300;
@ -269,7 +271,7 @@ exports.compileFilter = function(filterString) {
operand.value = self.getTextReference(operand.text,"",currTiddlerTitle);
} else if(operand.variable) {
var varTree = $tw.utils.parseFilterVariable(operand.text);
operand.value = widget.evaluateVariable(varTree.name,{params: varTree.params, source: source})[0] || "";
operand.value = widgetClass.evaluateVariable(widget,varTree.name,{params: varTree.params, source: source})[0] || "";
} else {
operand.value = operand.text;
}

View File

@ -0,0 +1,39 @@
/*\
title: $:/core/modules/filters/deserialize.js
type: application/javascript
module-type: filteroperator
Filter operator for deserializing string data into JSON representing tiddlers
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports["deserialize"] = function(source,operator,options) {
var results = [],
deserializer;
if(operator.operand) {
// Get the deserializer identified by the operand
deserializer = $tw.Wiki.tiddlerDeserializerModules[operator.operand];
if(deserializer) {
source(function(tiddler,title) {
var tiddlers;
try {
tiddlers = deserializer(title);
} catch(e) {
// Return an empty array if we could not extract any tiddlers
tiddlers = [];
}
results.push(JSON.stringify(tiddlers));
});
} else {
return [$tw.language.getString("Error/DeserializeOperator/UnknownDeserializer")];
}
} else {
return [$tw.language.getString("Error/DeserializeOperator/MissingOperand")];
}
return results;
}
})();

View File

@ -17,9 +17,13 @@ Export our filter function
*/
exports.function = function(source,operator,options) {
var functionName = operator.operands[0],
variableInfo = options.widget && options.widget.getVariableInfo && options.widget.getVariableInfo(functionName);
params = [];
$tw.utils.each(operator.operands.slice(1),function(param) {
params.push({value: param});
});
var variableInfo = options.widget && options.widget.getVariableInfo && options.widget.getVariableInfo(functionName,{params: params, source: source});
if(variableInfo && variableInfo.srcVariable && variableInfo.srcVariable.isFunctionDefinition) {
return options.widget.evaluateVariable(functionName,{params: operator.operands.slice(1), source: source});
return variableInfo.resultList ? variableInfo.resultList : [variableInfo.text];
}
// Return the input list if the function wasn't found
var results = [];

View File

@ -21,10 +21,14 @@ Export our filter function
*/
exports["[unknown]"] = function(source,operator,options) {
// Check for a user defined filter operator
if(operator.operator.charAt(0) === ".") {
var variableInfo = options.widget && options.widget.getVariableInfo && options.widget.getVariableInfo(operator.operator);
if(variableInfo && variableInfo.srcVariable && variableInfo.srcVariable.isFunctionDefinition) {
var list = options.widget.evaluateVariable(operator.operator,{params: operator.operands, source: source});
if(operator.operator.indexOf(".") !== -1) {
var params = [];
$tw.utils.each(operator.operands,function(param) {
params.push({value: param});
});
var variableInfo = options.widget && options.widget.getVariableInfo && options.widget.getVariableInfo(operator.operator,{params: params, source: source});
if(variableInfo && variableInfo.srcVariable) {
var list = variableInfo.resultList ? variableInfo.resultList : [variableInfo.text];
if(operator.prefix === "!") {
var results = [];
source(function(tiddler,title) {

View File

@ -78,7 +78,7 @@ exports.parseTag = function(source,pos,options) {
orderedAttributes: []
};
// Define our regexps
var reTagName = /([a-zA-Z0-9\-\$]+)/g;
var reTagName = /([a-zA-Z0-9\-\$\.]+)/g;
// Skip whitespace
pos = $tw.utils.skipWhiteSpace(source,pos);
// Look for a less than sign
@ -138,7 +138,7 @@ exports.parseTag = function(source,pos,options) {
exports.findNextTag = function(source,pos,options) {
// A regexp for finding candidate HTML tags
var reLookahead = /<([a-zA-Z\-\$]+)/g;
var reLookahead = /<([a-zA-Z\-\$\.]+)/g;
// Find the next candidate
reLookahead.lastIndex = pos;
var match = reLookahead.exec(source);

View File

@ -26,7 +26,7 @@ Instantiate parse rule
exports.init = function(parser) {
this.parser = parser;
// Regexp to match
this.matchRegExp = /^\\parameters\s*\(([^)]*)\)\s*\r?\n/mg;
this.matchRegExp = /^\\parameters\s*\(([^)]*)\)(\s*\r?\n)?/mg;
};
/*

View File

@ -0,0 +1,40 @@
/*\
title: $:/core/modules/parsers/wikiparser/rules/wikilinkprefix.js
type: application/javascript
module-type: wikirule
Wiki text inline rule for suppressed wiki links. For example:
```
~SuppressedLink
```
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.name = "wikilinkprefix";
exports.types = {inline: true};
exports.init = function(parser) {
this.parser = parser;
// Regexp to match
this.matchRegExp = new RegExp($tw.config.textPrimitives.unWikiLink + $tw.config.textPrimitives.wikiLink,"mg");
};
/*
Parse the most recent match
*/
exports.parse = function() {
// Get the details of the match
var linkText = this.match[0];
// Move past the wikilink
this.parser.pos = this.matchRegExp.lastIndex;
// Return the link without unwikilink character as plain text
return [{type: "text", text: linkText.substr(1)}];
};
})();

View File

@ -37,7 +37,7 @@ HeaderAuthenticator.prototype.authenticateRequest = function(request,response,st
return false;
} else {
// authenticatedUsername will be undefined for anonymous users
state.authenticatedUsername = username;
state.authenticatedUsername = $tw.utils.decodeURIComponentSafe(username);
return true;
}
};

View File

@ -20,6 +20,38 @@ exports.before = ["story"];
exports.synchronous = true;
exports.startup = function() {
// Install the HTTP client event handler
$tw.httpClient = new $tw.utils.HttpClient();
var getPropertiesWithPrefix = function(properties,prefix) {
var result = Object.create(null);
$tw.utils.each(properties,function(value,name) {
if(name.indexOf(prefix) === 0) {
result[name.substring(prefix.length)] = properties[name];
}
});
return result;
};
$tw.rootWidget.addEventListener("tm-http-request",function(event) {
var params = event.paramObject || {};
$tw.httpClient.initiateHttpRequest({
wiki: event.widget.wiki,
url: params.url,
method: params.method,
body: params.body,
oncompletion: params.oncompletion,
onprogress: params.onprogress,
bindStatus: params["bind-status"],
bindProgress: params["bind-progress"],
variables: getPropertiesWithPrefix(params,"var-"),
headers: getPropertiesWithPrefix(params,"header-"),
passwordHeaders: getPropertiesWithPrefix(params,"password-header-"),
queryStrings: getPropertiesWithPrefix(params,"query-"),
passwordQueryStrings: getPropertiesWithPrefix(params,"password-query-")
});
});
$tw.rootWidget.addEventListener("tm-http-cancel-all-requests",function(event) {
$tw.httpClient.cancelAllHttpRequests();
});
// Install the modal message mechanism
$tw.modal = new $tw.utils.Modal($tw.wiki);
$tw.rootWidget.addEventListener("tm-modal",function(event) {

View File

@ -80,7 +80,7 @@ ClassicStoryView.prototype.remove = function(widget) {
if(duration) {
var targetElement = widget.findFirstDomNode(),
removeElement = function() {
widget.destroy();
widget.removeChildDomNodes();
};
// Abandon if the list entry isn't a DOM element (it might be a text node)
if(!targetElement || targetElement.nodeType === Node.TEXT_NODE) {
@ -112,7 +112,7 @@ ClassicStoryView.prototype.remove = function(widget) {
{opacity: "0.0"}
]);
} else {
widget.destroy();
widget.removeChildDomNodes();
}
};

View File

@ -73,7 +73,7 @@ PopStoryView.prototype.remove = function(widget) {
duration = $tw.utils.getAnimationDuration(),
removeElement = function() {
if(targetElement && targetElement.parentNode) {
widget.destroy();
widget.removeChildDomNodes();
}
};
// Abandon if the list entry isn't a DOM element (it might be a text node)

View File

@ -154,7 +154,7 @@ ZoominListView.prototype.remove = function(widget) {
var targetElement = widget.findFirstDomNode(),
duration = $tw.utils.getAnimationDuration(),
removeElement = function() {
widget.destroy();
widget.removeChildDomNodes();
};
// Abandon if the list entry isn't a DOM element (it might be a text node)
if(!targetElement || targetElement.nodeType === Node.TEXT_NODE) {

View File

@ -3,7 +3,7 @@ title: $:/core/modules/utils/dom/http.js
type: application/javascript
module-type: utils
Browser HTTP support
HTTP support
\*/
(function(){
@ -13,11 +13,204 @@ Browser HTTP support
"use strict";
/*
A quick and dirty HTTP function; to be refactored later. Options are:
Manage tm-http-request events. Options include:
wiki: Reference to the wiki to be used for state tiddler tracking
stateTrackerTitle: Title of tiddler to be used for state tiddler tracking
*/
function HttpClient(options) {
options = options || {};
this.nextId = 1;
this.wiki = options.wiki || $tw.wiki;
this.stateTrackerTitle = options.stateTrackerTitle || "$:/state/http-requests";
this.requests = []; // Array of {id: string,request: HttpClientRequest}
this.updateRequestTracker();
}
/*
Return the index into this.requests[] corresponding to a given ID. Returns null if not found
*/
HttpClient.prototype.getRequestIndex = function(targetId) {
var targetIndex = null;
$tw.utils.each(this.requests,function(requestInfo,index) {
if(requestInfo.id === targetId) {
targetIndex = index;
}
});
return targetIndex;
};
/*
Update the state tiddler that is tracking the outstanding requests
*/
HttpClient.prototype.updateRequestTracker = function() {
this.wiki.addTiddler({title: this.stateTrackerTitle, text: "" + this.requests.length});
};
HttpClient.prototype.initiateHttpRequest = function(options) {
var self = this,
id = this.nextId,
request = new HttpClientRequest(options);
this.nextId += 1;
this.requests.push({id: id, request: request});
this.updateRequestTracker();
request.send(function(err) {
var targetIndex = self.getRequestIndex(id);
if(targetIndex !== null) {
self.requests.splice(targetIndex,1);
self.updateRequestTracker();
}
});
return id;
};
HttpClient.prototype.cancelAllHttpRequests = function() {
var self = this;
if(this.requests.length > 0) {
for(var t=this.requests.length - 1; t--; t>=0) {
var requestInfo = this.requests[t];
requestInfo.request.cancel();
}
}
this.requests = [];
this.updateRequestTracker();
};
HttpClient.prototype.cancelHttpRequest = function(targetId) {
var targetIndex = this.getRequestIndex(targetId);
if(targetIndex !== null) {
this.requests[targetIndex].request.cancel();
this.requests.splice(targetIndex,1);
this.updateRequestTracker();
}
};
/*
Initiate an HTTP request. Options:
wiki: wiki to be used for executing action strings
url: URL for request
method: method eg GET, POST
body: text of request body
oncompletion: action string to be invoked on completion
onprogress: action string to be invoked on progress updates
bindStatus: optional title of tiddler to which status ("pending", "complete", "error") should be written
bindProgress: optional title of tiddler to which the progress of the request (0 to 100) should be bound
variables: hashmap of variable name to string value passed to action strings
headers: hashmap of header name to header value to be sent with the request
passwordHeaders: hashmap of header name to password store name to be sent with the request
queryStrings: hashmap of query string parameter name to parameter value to be sent with the request
passwordQueryStrings: hashmap of query string parameter name to password store name to be sent with the request
*/
function HttpClientRequest(options) {
var self = this;
console.log("Initiating an HTTP request",options)
this.wiki = options.wiki;
this.completionActions = options.oncompletion;
this.progressActions = options.onprogress;
this.bindStatus = options["bind-status"];
this.bindProgress = options["bind-progress"];
this.method = options.method || "GET";
this.body = options.body || "";
this.variables = options.variables;
var url = options.url;
$tw.utils.each(options.queryStrings,function(value,name) {
url = $tw.utils.setQueryStringParameter(url,name,value);
});
$tw.utils.each(options.passwordQueryStrings,function(value,name) {
url = $tw.utils.setQueryStringParameter(url,name,$tw.utils.getPassword(value) || "");
});
this.url = url;
this.requestHeaders = {};
$tw.utils.each(options.headers,function(value,name) {
self.requestHeaders[name] = value;
});
$tw.utils.each(options.passwordHeaders,function(value,name) {
self.requestHeaders[name] = $tw.utils.getPassword(value) || "";
});
}
HttpClientRequest.prototype.send = function(callback) {
var self = this,
setBinding = function(title,text) {
if(title) {
this.wiki.addTiddler(new $tw.Tiddler({title: title, text: text}));
}
};
if(this.url) {
setBinding(this.bindStatus,"pending");
setBinding(this.bindProgress,"0");
// Set the request tracker tiddler
var requestTrackerTitle = this.wiki.generateNewTitle("$:/temp/HttpRequest");
this.wiki.addTiddler({
title: requestTrackerTitle,
tags: "$:/tags/HttpRequest",
text: JSON.stringify({
url: this.url,
type: this.method,
status: "inprogress",
headers: this.requestHeaders,
data: this.body
})
});
this.xhr = $tw.utils.httpRequest({
url: this.url,
type: this.method,
headers: this.requestHeaders,
data: this.body,
callback: function(err,data,xhr) {
var hasSucceeded = xhr.status >= 200 && xhr.status < 300,
completionCode = hasSucceeded ? "complete" : "error",
headers = {};
$tw.utils.each(xhr.getAllResponseHeaders().split("\r\n"),function(line) {
var pos = line.indexOf(":");
if(pos !== -1) {
headers[line.substr(0,pos)] = line.substr(pos + 1).trim();
}
});
setBinding(self.bindStatus,completionCode);
setBinding(self.bindProgress,"100");
var resultVariables = {
status: xhr.status.toString(),
statusText: xhr.statusText,
error: (err || "").toString(),
data: (data || "").toString(),
headers: JSON.stringify(headers)
};
self.wiki.addTiddler(new $tw.Tiddler(self.wiki.getTiddler(requestTrackerTitle),{
status: completionCode,
}));
self.wiki.invokeActionString(self.completionActions,undefined,$tw.utils.extend({},self.variables,resultVariables),{parentWidget: $tw.rootWidget});
callback(hasSucceeded ? null : xhr.statusText);
// console.log("Back!",err,data,xhr);
},
progress: function(lengthComputable,loaded,total) {
if(lengthComputable) {
setBinding(self.bindProgress,"" + Math.floor((loaded/total) * 100))
}
self.wiki.invokeActionString(self.progressActions,undefined,{
lengthComputable: lengthComputable ? "yes" : "no",
loaded: loaded,
total: total
},{parentWidget: $tw.rootWidget});
}
});
}
};
HttpClientRequest.prototype.cancel = function() {
if(this.xhr) {
this.xhr.abort();
}
};
exports.HttpClient = HttpClient;
/*
Make an HTTP request. Options are:
url: URL to retrieve
headers: hashmap of headers to send
type: GET, PUT, POST etc
callback: function invoked with (err,data,xhr)
progress: optional function invoked with (lengthComputable,loaded,total)
returnProp: string name of the property to return as first argument of callback
*/
exports.httpRequest = function(options) {
@ -83,8 +276,16 @@ exports.httpRequest = function(options) {
options.callback($tw.language.getString("Error/XMLHttpRequest") + ": " + this.status,null,this);
}
};
// Handle progress
if(options.progress) {
request.onprogress = function(event) {
console.log("Progress event",event)
options.progress(event.lengthComputable,event.loaded,event.total);
};
}
// Make the request
request.open(type,url,true);
// Headers
if(headers) {
$tw.utils.each(headers,function(header,headerTitle,object) {
request.setRequestHeader(headerTitle,header);
@ -96,6 +297,7 @@ exports.httpRequest = function(options) {
if(!hasHeader("X-Requested-With") && !isSimpleRequest(type,headers)) {
request.setRequestHeader("X-Requested-With","TiddlyWiki");
}
// Send data
try {
request.send(data);
} catch(e) {
@ -104,4 +306,19 @@ exports.httpRequest = function(options) {
return request;
};
exports.setQueryStringParameter = function(url,paramName,paramValue) {
var URL = $tw.browser ? window.URL : require("url").URL,
newUrl;
try {
newUrl = new URL(url);
} catch(e) {
}
if(newUrl && paramName) {
newUrl.searchParams.set(paramName,paramValue || "");
return newUrl.toString();
} else {
return url;
}
};
})();

View File

@ -112,7 +112,7 @@ CheckboxWidget.prototype.getValue = function() {
var list;
if(this.checkboxListField) {
if($tw.utils.hop(tiddler.fields,this.checkboxListField)) {
list = tiddler.getFieldList(this.checkboxListField);
list = tiddler.getFieldList(this.checkboxListField) || [];
} else {
list = $tw.utils.parseStringArray(this.checkboxDefault || "") || [];
}
@ -208,16 +208,20 @@ CheckboxWidget.prototype.handleChangeEvent = function(event) {
if(this.checkboxListField || this.checkboxListIndex) {
var fieldContents, listContents, oldPos, newPos;
if(this.checkboxListField) {
fieldContents = tiddler ? tiddler.fields[this.checkboxListField] : undefined;
fieldContents = (tiddler ? tiddler.fields[this.checkboxListField] : undefined) || [];
} else {
fieldContents = this.wiki.extractTiddlerDataItem(this.checkboxTitle,this.checkboxListIndex);
}
if($tw.utils.isArray(fieldContents)) {
// Make a copy so we can modify it without changing original that's refrenced elsewhere
listContents = fieldContents.slice(0);
} else {
listContents = $tw.utils.parseStringArray(fieldContents) || [];
} else if(typeof fieldContents === "string") {
listContents = $tw.utils.parseStringArray(fieldContents);
// No need to copy since parseStringArray returns a fresh array, not refrenced elsewhere
} else {
// Field was neither an array nor a string; it's probably something that shouldn't become
// an array (such as a date field), so bail out *without* triggering actions
return;
}
oldPos = notValue ? listContents.indexOf(notValue) : -1;
newPos = value ? listContents.indexOf(value) : -1;

View File

@ -39,7 +39,7 @@ DiffTextWidget.prototype.render = function(parent,nextSibling) {
this.execute();
// Create the diff
var dmpObject = new dmp.diff_match_patch(),
diffs = dmpObject.diff_main(this.getAttribute("source"),this.getAttribute("dest"));
diffs = dmpObject.diff_main(this.getAttribute("source",""),this.getAttribute("dest",""));
// Apply required cleanup
switch(this.getAttribute("cleanup","semantic")) {
case "none":

View File

@ -122,7 +122,7 @@ ImportVariablesWidget.prototype.refresh = function(changedTiddlers) {
}
if(changedAttributes.filter || !$tw.utils.isArrayEqual(this.tiddlerList,tiddlerList) || haveListedTiddlersChanged()) {
// Compute the filter
this.destroy();
this.removeChildDomNodes();
this.execute(tiddlerList);
this.renderChildren(this.parentDomNode,this.findNextSiblingDomNode());
return true;

View File

@ -219,7 +219,7 @@ ListWidget.prototype.handleListChanges = function(changedTiddlers) {
} else {
// If the list was empty then we need to remove the empty message
if(prevList.length === 0) {
this.destroy();
this.removeChildDomNodes();
this.children = [];
}
// If we are providing an counter variable then we must refresh the items, otherwise we can rearrange them
@ -312,7 +312,7 @@ ListWidget.prototype.removeListItem = function(index) {
if(this.storyview && this.storyview.remove) {
this.storyview.remove(widget);
} else {
widget.destroy();
widget.removeChildDomNodes();
}
// Remove the child widget
this.children.splice(index,1);

View File

@ -51,7 +51,8 @@ MacroCallWidget.prototype.execute = function() {
var positionalName = 0,
parseTreeNodes = [{
type: "transclude",
isBlock: this.parseTreeNode.isBlock
isBlock: this.parseTreeNode.isBlock,
children: this.parseTreeNode.children
}];
$tw.utils.addAttributeToParseTreeNode(parseTreeNodes[0],"$variable",this.macroName);
$tw.utils.addAttributeToParseTreeNode(parseTreeNodes[0],"$type",this.parseType);

View File

@ -48,7 +48,7 @@ SlotWidget.prototype.execute = function() {
var pointer = this.parentWidget,
depth = this.slotDepth;
while(pointer) {
if(pointer instanceof TranscludeWidget) {
if(pointer instanceof TranscludeWidget && pointer.hasVisibleSlots()) {
depth--;
if(depth <= 0) {
break;

View File

@ -171,99 +171,85 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
}
var parser;
// Get the parse tree
if(this.transcludeVariable) {
// Transcluding a variable
var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()}),
srcVariable = variableInfo && variableInfo.srcVariable;
if(srcVariable) {
if(srcVariable.isFunctionDefinition) {
// Function to return parameters by name or position
var fnGetParam = function(name,index) {
// Parameter names starting with dollar must be escaped to double dollars
if(name.charAt(0) === "$") {
name = "$" + name;
}
// Look for the parameter by name
if(self.hasAttribute(name)) {
return self.getAttribute(name);
// Look for the parameter by index
} else if(self.hasAttribute(index + "")) {
return self.getAttribute(index + "");
} else {
return undefined;
}
},
result = this.evaluateVariable(this.transcludeVariable,{params: fnGetParam})[0] || "";
parser = {
tree: [{
type: "text",
text: result
}],
source: result,
type: "text/vnd.tiddlywiki"
};
if(parseAsInline) {
parser.tree[0] = {
type: "text",
text: result
};
} else {
parser.tree[0] = {
type: "element",
tag: "p",
children: [{
if(this.hasAttribute("$variable")) {
if(this.transcludeVariable) {
// Transcluding a variable
var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()}),
srcVariable = variableInfo && variableInfo.srcVariable;
if(variableInfo.text) {
if(srcVariable.isFunctionDefinition) {
var result = (variableInfo.resultList ? variableInfo.resultList[0] : variableInfo.text) || "";
parser = {
tree: [{
type: "text",
text: result
}]
}
}
} else {
var cacheKey = (parseAsInline ? "inlineParser" : "blockParser") + (this.transcludeType || "");
if(variableInfo.isCacheable && srcVariable[cacheKey]) {
parser = srcVariable[cacheKey];
} else {
parser = this.wiki.parseText(this.transcludeType,variableInfo.text || "",{parseAsInline: parseAsInline, configTrimWhiteSpace: srcVariable.configTrimWhiteSpace});
if(variableInfo.isCacheable) {
srcVariable[cacheKey] = parser;
}
}
}
if(parser) {
// Add parameters widget for procedures and custom widgets
if(srcVariable.isProcedureDefinition || srcVariable.isWidgetDefinition) {
parser = {
tree: [
{
type: "parameters",
children: parser.tree
}
],
source: parser.source,
type: parser.type
}
$tw.utils.each(srcVariable.params,function(param) {
var name = param.name;
// Parameter names starting with dollar must be escaped to double dollars
if(name.charAt(0) === "$") {
name = "$" + name;
}],
source: result,
type: "text/vnd.tiddlywiki"
};
if(parseAsInline) {
parser.tree[0] = {
type: "text",
text: result
};
} else {
parser.tree[0] = {
type: "element",
tag: "p",
children: [{
type: "text",
text: result
}]
}
$tw.utils.addAttributeToParseTreeNode(parser.tree[0],name,param["default"])
});
} else {
// For macros and ordinary variables, wrap the parse tree in a vars widget assigning the parameters to variables named "__paramname__"
parser = {
tree: [
{
type: "vars",
children: parser.tree
}
],
source: parser.source,
type: parser.type
}
$tw.utils.each(variableInfo.params,function(param) {
$tw.utils.addAttributeToParseTreeNode(parser.tree[0],"__" + param.name + "__",param.value)
});
} else {
var cacheKey = (parseAsInline ? "inlineParser" : "blockParser") + (this.transcludeType || "");
if(variableInfo.isCacheable && srcVariable[cacheKey]) {
parser = srcVariable[cacheKey];
} else {
parser = this.wiki.parseText(this.transcludeType,variableInfo.text || "",{parseAsInline: parseAsInline, configTrimWhiteSpace: srcVariable.configTrimWhiteSpace});
if(variableInfo.isCacheable) {
srcVariable[cacheKey] = parser;
}
}
}
if(parser) {
// Add parameters widget for procedures and custom widgets
if(srcVariable.isProcedureDefinition || srcVariable.isWidgetDefinition) {
parser = {
tree: [
{
type: "parameters",
children: parser.tree
}
],
source: parser.source,
type: parser.type
}
$tw.utils.each(srcVariable.params,function(param) {
var name = param.name;
// Parameter names starting with dollar must be escaped to double dollars
if(name.charAt(0) === "$") {
name = "$" + name;
}
$tw.utils.addAttributeToParseTreeNode(parser.tree[0],name,param["default"])
});
} else if(srcVariable.isMacroDefinition || !srcVariable.isFunctionDefinition) {
// For macros and ordinary variables, wrap the parse tree in a vars widget assigning the parameters to variables named "__paramname__"
parser = {
tree: [
{
type: "vars",
children: parser.tree
}
],
source: parser.source,
type: parser.type
}
$tw.utils.each(variableInfo.params,function(param) {
$tw.utils.addAttributeToParseTreeNode(parser.tree[0],"__" + param.name + "__",param.value)
});
}
}
}
}
@ -382,6 +368,13 @@ TranscludeWidget.prototype.getTransclusionSlotFill = function(name,defaultParseT
}
};
/*
Return whether this transclusion should be visible to the slot widget
*/
TranscludeWidget.prototype.hasVisibleSlots = function() {
return this.getAttribute("$fillignore","no") === "no";
}
/*
Compose a string comprising the title, field and/or index to identify this transclusion for recursion detection
*/

View File

@ -112,14 +112,18 @@ Get the prevailing value of a context variable
name: name of variable
options: see below
Options include
params: array of {name:, value:} for each parameter
defaultValue: default value if the variable is not defined
source: optional source iterator for evaluating function invocations
allowSelfAssigned: if true, includes the current widget in the context chain instead of just the parent
Returns an object with the following fields:
params: array of {name:,value:} of parameters passed to wikitext variables
params: array of {name:,value:} or {value:} of parameters to be applied
text: text of variable, with parameters properly substituted
resultList: result of variable evaluation as an array
srcVariable: reference to the object defining the variable
*/
Widget.prototype.getVariableInfo = function(name,options) {
options = options || {};
@ -135,7 +139,8 @@ Widget.prototype.getVariableInfo = function(name,options) {
if(variable) {
var originalValue = variable.value,
value = originalValue,
params = [];
params = [],
resultList = [value];
// Only substitute parameter and variable references if this variable was defined with the \define pragma
if(variable.isMacroDefinition) {
params = self.resolveVariableParameters(variable.params,actualParams);
@ -144,10 +149,28 @@ Widget.prototype.getVariableInfo = function(name,options) {
value = $tw.utils.replaceString(value,new RegExp("\\$" + $tw.utils.escapeRegExp(param.name) + "\\$","mg"),param.value);
});
value = self.substituteVariableReferences(value,options);
resultList = [value];
} else if(variable.isFunctionDefinition) {
// Function evaluations
params = self.resolveVariableParameters(variable.params,actualParams);
var variables = Object.create(null);
// Apply default parameter values
$tw.utils.each(variable.params,function(param,index) {
if(param["default"]) {
variables[param.name] = param["default"];
}
});
// Parameters are an array of {value:} or {name:, value:} pairs
$tw.utils.each(params,function(param) {
variables[param.name] = param.value;
});
resultList = this.wiki.filterTiddlers(value,this.makeFakeWidgetWithVariables(variables),options.source);
value = resultList[0] || "";
}
return {
text: value,
params: params,
resultList: resultList,
srcVariable: variable,
isCacheable: originalValue === value
};
@ -159,6 +182,7 @@ Widget.prototype.getVariableInfo = function(name,options) {
}
return {
text: text,
resultList: [text],
srcVariable: {}
};
};
@ -317,62 +341,11 @@ Widget.prototype.makeFakeWidgetWithVariables = function(variables) {
};
},
makeFakeWidgetWithVariables: self.makeFakeWidgetWithVariables,
evaluateVariable: self.evaluateVariable,
resolveVariableParameters: self.resolveVariableParameters,
wiki: self.wiki
};
};
/*
Evaluate a variable and associated actual parameters and return the resulting array.
The way that the variable is evaluated depends upon its type:
* Functions are evaluated as parameterised filter strings
* Macros are returned as plain text with substitution of parameters
* Procedures and widgets are returned as plain text
Options are:
params - the actual parameters may be one of:
* an array of values that may be an anonymous string value, or a {name:, value:} pair
* a hashmap of {name: value} pairs
* a function invoked with parameters (name,index) that returns a parameter value by name or position
source - iterator for source tiddlers
*/
Widget.prototype.evaluateVariable = function(name,options) {
options = options || {};
var params = options.params || [];
// Get the details of the variable (includes processing text substitution for macros
var variableInfo = this.getVariableInfo(name,{params: params,defaultValue: ""});
// Process function parameters
var variables = Object.create(null);
if(variableInfo.srcVariable && variableInfo.srcVariable.isFunctionDefinition) {
// Apply default parameter values
$tw.utils.each(variableInfo.srcVariable.params,function(param,index) {
if(param["default"]) {
variables[param.name] = param["default"];
}
});
if($tw.utils.isArray(params)) {
// Parameters are an array of values or {name:, value:} pairs
$tw.utils.each(this.resolveVariableParameters(variableInfo.srcVariable.params,params),function(param) {
variables[param.name] = param.value;
});
} else if(typeof params === "function") {
// Parameters are passed via a function
$tw.utils.each(variableInfo.srcVariable.params,function(param,index) {
variables[param.name] = params(param.name,index) || param["default"] || "";
});
} else {
// Parameters are a hashmap
$tw.utils.each(params,function(value,name) {
variables[name] = value;
});
}
return this.wiki.filterTiddlers(variableInfo.text,this.makeFakeWidgetWithVariables(variables),options.source);
} else {
return [variableInfo.text];
}
};
/*
Compute the current values of the attributes of the widget. Returns a hashmap of the names of the attributes that have changed.
Options include:
@ -403,16 +376,10 @@ Widget.prototype.computeAttribute = function(attribute) {
if(attribute.type === "filtered") {
value = this.wiki.filterTiddlers(attribute.filter,this)[0] || "";
} else if(attribute.type === "indirect") {
value = this.wiki.getTextReference(attribute.textReference,"",this.getVariable("currentTiddler"));
value = this.wiki.getTextReference(attribute.textReference,"",this.getVariable("currentTiddler")) || "";
} else if(attribute.type === "macro") {
var variableInfo = this.getVariableInfo(attribute.value.name,{params: attribute.value.params});
if(variableInfo.srcVariable && variableInfo.srcVariable.isFunctionDefinition) {
// It is a function definition. Go through each of the defined parameters, and make a variable with the value of the corresponding provided parameter
var paramArray = this.resolveVariableParameters(variableInfo.srcVariable.params,attribute.value.params);
value = this.evaluateVariable(attribute.value.name,{params: paramArray})[0] || "";
} else {
value = variableInfo.text;
}
value = variableInfo.text;
} else { // String attribute
value = attribute.value;
}
@ -546,8 +513,8 @@ Widget.prototype.makeChildWidget = function(parseTreeNode,options) {
var variableDefinitionName = "$" + parseTreeNode.type;
if(this.variables[variableDefinitionName]) {
var isOverrideable = function() {
// Widget is overrideable if it has a double dollar user defined name, or if it is an existing JS widget and we're not in safe mode
return parseTreeNode.type.charAt(0) === "$" || (!!self.widgetClasses[parseTreeNode.type] && !$tw.safeMode);
// Widget is overrideable if its name contains a period, or if it is an existing JS widget and we're not in safe mode
return parseTreeNode.type.indexOf(".") !== -1 || (!!self.widgetClasses[parseTreeNode.type] && !$tw.safeMode);
};
if(!parseTreeNode.isNotRemappable && isOverrideable()) {
var variableInfo = this.getVariableInfo(variableDefinitionName,{allowSelfAssigned: true});
@ -688,7 +655,7 @@ Rebuild a previously rendered widget
*/
Widget.prototype.refreshSelf = function() {
var nextSibling = this.findNextSiblingDomNode();
this.removeChildDomNodes({ recursive: true });
this.removeChildDomNodes();
this.render(this.parentDomNode,nextSibling);
};
@ -751,45 +718,43 @@ Widget.prototype.findFirstDomNode = function() {
};
/*
Remove any DOM nodes created by this widget or its children
Entry into destroy procedure
*/
Widget.prototype.removeChildDomNodes = function(options) {
var recursive = options && options.recursive;
/**
* If this widget has directly created DOM nodes, delete them and exit.
* This assumes that any child widgets are contained within the created DOM nodes, which would normally be the case
*/
Widget.prototype.destroyChildren = function() {
$tw.utils.each(this.children,function(childWidget) {
childWidget.destroy();
});
};
/*
Legacy entry into destroy procedure
*/
Widget.prototype.removeChildDomNodes = function() {
this.destroy();
};
/*
Default destroy
*/
Widget.prototype.destroy = function() {
// call children to remove their resources
this.destroyChildren();
// remove our resources
this.children = [];
this.removeLocalDomNodes();
};
/*
Remove any DOM nodes created by this widget
*/
Widget.prototype.removeLocalDomNodes = function() {
// If this widget has directly created DOM nodes, delete them and exit.
if(this.domNodes.length > 0) {
$tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode);
});
this.domNodes = [];
return true;
} else if(recursive) {
// Otherwise, ask the child widgets to delete their DOM nodes
$tw.utils.each(this.children,function(childWidget) {
childWidget.removeChildDomNodes(options);
});
}
return false
};
/*
Inform widget subclass that extends this widget and children widgets of this widget. Let them know this widget tree is about to destroy, and dom nodes are being unmounted from the document.
*/
Widget.prototype.destroy = function(options) {
// removeDom by default
var removeDom = (options && options.removeDom) || true;
if (removeDom) {
// prepare options for children, if we have removed the dom, child don't need to remove their dom
removeDom = !this.removeChildDomNodes();
}
// nothing need to do, as dom is already removed in the removeChildDomNodes
// we just need to inform the children
$tw.utils.each(this.children,function(childWidget) {
childWidget.destroy({ removeDom: removeDom });
});
};
/*
Invoke the action widgets that are descendents of the current widget.
@ -852,6 +817,20 @@ Widget.prototype.allowActionPropagation = function() {
return true;
};
/*
Evaluate a variable with parameters. This is a static convenience method that attempts to evaluate a variable as a function, returning an array of strings
*/
Widget.evaluateVariable = function(widget,name,options) {
var result;
if(widget.getVariableInfo) {
var variableInfo = widget.getVariableInfo(name,options);
result = variableInfo.resultList || [variableInfo.text];
} else {
result = [widget.getVariable(name)];
}
return result;
};
exports.widget = Widget;
})();

View File

@ -1415,6 +1415,14 @@ exports.checkTiddlerText = function(title,targetText,options) {
return text === targetText;
}
/*
Execute an action string without an associated context widget
*/
exports.invokeActionString = function(actions,event,variables,options) {
var widget = this.makeWidget(null,{parentWidget: options.parentWidget});
widget.invokeActionString(actions,null,event,variables);
};
/*
Read an array of browser File objects, invoking callback(tiddlerFieldsArray) once they're all read
*/

View File

@ -54,6 +54,7 @@ modal-footer-background: #f5f5f5
modal-footer-border: #dddddd
modal-header-border: #eeeeee
muted-foreground: #bbb
network-activity-foreground: #448844
notification-background: #ffffdd
notification-border: #999999
page-background: #f4f4f4

View File

@ -3,6 +3,7 @@ tags: $:/tags/Exporter
description: {{$:/language/Exporters/StaticRiver}}
extension: .html
\define tv-config-static() yes
\define tv-wikilink-template() #$uri_encoded$
\define tv-config-toolbar-icons() no
\define tv-config-toolbar-text() no

View File

@ -1,6 +1,7 @@
title: $:/core/templates/server/static.tiddler.html
\whitespace trim
\define tv-config-static() yes
\define tv-wikilink-template() $uri_encoded$
\import [subfilter{$:/core/config/GlobalImportFilter}]
<html>

View File

@ -1,6 +1,7 @@
title: $:/core/templates/static.template.html
type: text/vnd.tiddlywiki-html
\define tv-config-static() yes
\define tv-wikilink-template() static/$uri_doubleencoded$.html
\define tv-config-toolbar-icons() no
\define tv-config-toolbar-text() no

View File

@ -1,6 +1,7 @@
title: $:/core/templates/static.tiddler.html
\define tv-wikilink-template() $uri_doubleencoded$.html
\define tv-config-static() yes
\define tv-config-toolbar-icons() no
\define tv-config-toolbar-text() no
\define tv-config-toolbar-class() tc-btn-invisible

View File

@ -30,15 +30,15 @@ Block transclusions are shown in red, and inline transclusions are shown in gree
<!-- Look for a parameter starting with $ to determine if we are in legacy mode -->
<$list filter="[<@params>jsonindexes[]] :filter[<currentTiddler>prefix[$]] +[limit[1]]" variable="ignore" emptyMessage="""
<!-- Legacy mode: we render the transclusion without a dollar sign for recursionMarker and mode -->
<$genesis $type="$transclude" $remappable="no" $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget<currentTiddler>]" recursionMarker="no" mode=<<mode>>>
<$genesis $type="$transclude" $remappable="no" $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget<currentTiddler>]" recursionMarker="no" mode=<<mode>> $$fillignore="yes">
<!-- Reach back up to the grandparent transclusion to get the correct slot value -->
<$slot $name="ts-raw" $depth="2"/>
<$slot $name="ts-raw"/>
</$genesis>
""">
<!-- Non-legacy mode: we use dollar signs for the recursionMarker and mode -->
<$genesis $type="$transclude" $remappable="no" $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget<currentTiddler>]" $$recursionMarker="no" $$mode=<<mode>>>
<$genesis $type="$transclude" $remappable="no" $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget<currentTiddler>]" $$recursionMarker="no" $$mode=<<mode>> $$fillignore="yes">
<!-- Reach back up to the grandparent transclusion to get the correct slot fill value -->
<$slot $name="ts-raw" $depth="2"/>
<$slot $name="ts-raw"/>
</$genesis>
</$list>
</$genesis>

View File

@ -2,18 +2,6 @@ title: $:/core/ui/ControlPanel/Settings
tags: $:/tags/ControlPanel
caption: {{$:/language/ControlPanel/Settings/Caption}}
\define lingo-base() $:/language/ControlPanel/Settings/
<<lingo Hint>>
<$list filter="[all[shadows+tiddlers]tag[$:/tags/ControlPanel/Settings]]">
<div style="border-top:1px solid #eee;">
!! <$link><$transclude field="caption"/></$link>
<$transclude/>
</div>
</$list>
<div class="tc-control-panel">
<$macrocall $name="tabs" tabsList="[all[shadows+tiddlers]tag[$:/tags/ControlPanel/SettingsTab]!has[draft.of]]" default="$:/core/ui/ControlPanel/Settings/TiddlyWiki" explicitState="$:/state/tab--697582678"/>
</div>

View File

@ -1,6 +1,7 @@
title: $:/core/ui/ControlPanel/Settings/TiddlyWiki
tags: $:/tags/ControlPanel/SettingsTab
caption: TiddlyWiki
list-before:
\define lingo-base() $:/language/ControlPanel/Settings/

View File

@ -14,8 +14,8 @@ color:$(foregroundColor)$;
\define tag-body-inner(colour,fallbackTarget,colourA,colourB,icon,tagField:"tags")
\whitespace trim
<$vars foregroundColor=<<contrastcolour target:"""$colour$""" fallbackTarget:"""$fallbackTarget$""" colourA:"""$colourA$""" colourB:"""$colourB$""">> backgroundColor="""$colour$""">
<span style=<<tag-styles>> class="tc-tag-label tc-tag-list-item tc-small-gap-right">
<$transclude tiddler="""$icon$"""/><$view field="title" format="text" />
<span style=<<tag-styles>> class="tc-tag-label tc-tag-list-item tc-small-gap-right" data-tag-title=<<currentTiddler>>>
<$transclude tiddler="""$icon$"""/><$view field="title" format="text"/>
<$button class="tc-btn-invisible tc-remove-tag-button" style=<<tag-styles>>><$action-listops $tiddler=<<saveTiddler>> $field=<<__tagField__>> $subfilter="-[{!!title}]"/>{{$:/core/images/close-button}}</$button>
</span>
</$vars>

View File

@ -18,7 +18,7 @@ title: $:/core/ui/EditorToolbar/link-dropdown
\define external-link()
\whitespace trim
<$button class="tc-btn-invisible" style="width: auto; display: inline-block; background-colour: inherit;" actions=<<add-link-actions>>>
<$button class="tc-btn-invisible tc-btn-mini" style="width: auto; display: inline-block; background-colour: inherit;" actions=<<add-link-actions>>>
{{$:/core/images/chevron-right}}
</$button>
\end
@ -45,7 +45,7 @@ title: $:/core/ui/EditorToolbar/link-dropdown
<$reveal tag="span" state=<<storeTitle>> type="nomatch" text="">
<<external-link>>
&#32;
<$button class="tc-btn-invisible" style="width: auto; display: inline-block; background-colour: inherit;">
<$button class="tc-btn-invisible tc-btn-mini" style="width: auto; display: inline-block; background-colour: inherit;">
<<cancel-search-actions>><$set name="cssEscapedTitle" value={{{ [<storyTiddler>escapecss[]] }}}><$action-sendmessage $message="tm-focus-selector" $param=<<get-focus-selector>>/></$set>
{{$:/core/images/close-button}}
</$button>

View File

@ -0,0 +1,16 @@
title: $:/core/ui/Buttons/network-activity
tags: $:/tags/PageControls
caption: {{$:/core/images/network-activity}} {{$:/language/Buttons/NetworkActivity/Caption}}
description: {{$:/language/Buttons/NetworkActivity/Hint}}
\whitespace trim
<$button message="tm-http-cancel-all-requests" tooltip={{$:/language/Buttons/NetworkActivity/Hint}} aria-label={{$:/language/Buttons/NetworkActivity/Caption}} class=<<tv-config-toolbar-class>>>
<$list filter="[<tv-config-toolbar-icons>match[yes]]">
{{$:/core/images/network-activity}}
</$list>
<$list filter="[<tv-config-toolbar-text>match[yes]]">
<span class="tc-btn-text">
<$text text={{$:/language/Buttons/NetworkActivity/Caption}}/>
</span>
</$list>
</$button>

View File

@ -26,7 +26,7 @@ $button$
<div class="tc-sidebar-tab-open">
<$list filter="[list<tv-story-list>]" history=<<tv-history-list>> storyview="pop">
<div class="tc-sidebar-tab-open-item">
<$macrocall $name="droppable-item" button="<$button message='tm-close-tiddler' tooltip={{$:/language/Buttons/Close/Hint}} aria-label={{$:/language/Buttons/Close/Caption}} class='tc-btn-invisible tc-btn-mini tc-small-gap-right'>{{$:/core/images/close-button}}</$button><$link to={{!!title}}><$view field='title'/></$link>"/>
<$macrocall $name="droppable-item" button="<$button message='tm-close-tiddler' tooltip={{$:/language/Buttons/Close/Hint}} aria-label={{$:/language/Buttons/Close/Caption}} class='tc-btn-invisible tc-btn-mini tc-small-gap-right'>{{$:/core/images/close-button}}</$button><$link/>"/>
</div>
</$list>
<$tiddler tiddler="">

View File

@ -15,7 +15,7 @@ title: $:/core/ui/TagPickerTagTemplate
<<actions>>
<$set name="backgroundColor" value={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]] }}}>
<$wikify name="foregroundColor" text="""<$macrocall $name="contrastcolour" target=<<backgroundColor>> fallbackTarget=<<fallbackTarget>> colourA=<<colourA>> colourB=<<colourB>>/>""">
<span class="tc-tag-label tc-btn-invisible" style=<<tag-pill-styles>>>
<span class="tc-tag-label tc-btn-invisible" style=<<tag-pill-styles>> data-tag-title=<<currentTiddler>> >
{{||$:/core/ui/TiddlerIcon}}<$view field="title" format="text"/>
</span>
</$wikify>

View File

@ -13,6 +13,7 @@ core/ui/Buttons/language: hide
core/ui/Buttons/tag-manager: hide
core/ui/Buttons/manager: hide
core/ui/Buttons/more-page-actions: hide
core/ui/Buttons/network-activity: hide
core/ui/Buttons/new-journal: hide
core/ui/Buttons/new-image: hide
core/ui/Buttons/palette: hide

View File

@ -1,3 +1,3 @@
title: $:/config/WikiParserRules/Inline/wikilink
enable
disable

View File

@ -19,9 +19,9 @@ tags: $:/tags/Macro
\define toc-body(tag,sort:"",itemClassFilter,exclude,path)
\whitespace trim
<ol class="tc-toc">
<$list filter="""[all[shadows+tiddlers]tag<__tag__>!has[draft.of]$sort$] -[<__tag__>] -[enlist<__exclude__>]""">
<$list filter="""[all[shadows+tiddlers]tag<__tag__>!has[draft.of]$sort$] -[<__tag__>] -[subfilter<__exclude__>]""">
<$let item=<<currentTiddler>> path={{{ [<__path__>addsuffix[/]addsuffix<__tag__>] }}}>
<$set name="excluded" filter="""[enlist<__exclude__>] [<__tag__>]""">
<$set name="excluded" filter="[subfilter<__exclude__>] [<__tag__>]">
<$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item">
<li class=<<toc-item-class>>>
<$list filter="[all[current]toc-link[no]]" emptyMessage="<$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}><<toc-caption>></$link>">
@ -36,8 +36,8 @@ tags: $:/tags/Macro
</ol>
\end
\define toc(tag,sort:"",itemClassFilter:"")
<$macrocall $name="toc-body" tag=<<__tag__>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> />
\define toc(tag,sort:"",itemClassFilter:"", exclude)
<$macrocall $name="toc-body" tag=<<__tag__>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> exclude=<<__exclude__>>/>
\end
\define toc-linked-expandable-body(tag,sort:"",itemClassFilter,exclude,path)
@ -75,7 +75,7 @@ tags: $:/tags/Macro
<li class=<<toc-item-class>>>
<$reveal type="nomatch" stateTitle=<<toc-state>> text="open">
<$button setTitle=<<toc-state>> setTo="open" class="tc-btn-invisible tc-popup-keep">
<$transclude tiddler=<<toc-closed-icon>> />
<$transclude tiddler=<<toc-closed-icon>> />
<<toc-caption>>
</$button>
</$reveal>
@ -100,9 +100,9 @@ tags: $:/tags/Macro
\define toc-expandable(tag,sort:"",itemClassFilter:"",exclude,path)
\whitespace trim
<$let tag=<<__tag__>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> path={{{ [<__path__>addsuffix[/]addsuffix<__tag__>] }}}>
<$set name="excluded" filter="""[enlist<__exclude__>] [<__tag__>]""">
<$set name="excluded" filter="[subfilter<__exclude__>] [<__tag__>]">
<ol class="tc-toc toc-expandable">
<$list filter="""[all[shadows+tiddlers]tag<__tag__>!has[draft.of]$sort$] -[<__tag__>] -[enlist<__exclude__>]""">
<$list filter="""[all[shadows+tiddlers]tag<__tag__>!has[draft.of]$sort$] -[<__tag__>] -[subfilter<__exclude__>]""">
<$list filter="[all[current]toc-link[no]]" emptyMessage=<<toc-expandable-empty-message>> >
<$macrocall $name="toc-unlinked-expandable-body" tag=<<__tag__>> sort=<<__sort__>> itemClassFilter="""itemClassFilter""" exclude=<<excluded>> path=<<path>> />
</$list>
@ -174,9 +174,9 @@ tags: $:/tags/Macro
\define toc-selective-expandable(tag,sort:"",itemClassFilter,exclude,path)
\whitespace trim
<$let tag=<<__tag__>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> path={{{ [<__path__>addsuffix[/]addsuffix<__tag__>] }}}>
<$set name="excluded" filter="[enlist<__exclude__>] [<__tag__>]">
<$set name="excluded" filter="[subfilter<__exclude__>] [<__tag__>]">
<ol class="tc-toc toc-selective-expandable">
<$list filter="""[all[shadows+tiddlers]tag<__tag__>!has[draft.of]$sort$] -[<__tag__>] -[enlist<__exclude__>]""">
<$list filter="""[all[shadows+tiddlers]tag<__tag__>!has[draft.of]$sort$] -[<__tag__>] -[subfilter<__exclude__>]""">
<$list filter="[all[current]toc-link[no]]" variable="ignore" emptyMessage=<<toc-selective-expandable-empty-message>> >
<$macrocall $name="toc-unlinked-selective-expandable-body" tag=<<__tag__>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> exclude=<<excluded>> path=<<path>>/>
</$list>
@ -186,13 +186,13 @@ tags: $:/tags/Macro
</$let>
\end
\define toc-tabbed-external-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"")
\define toc-tabbed-external-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"",exclude)
\whitespace trim
<$tiddler tiddler={{{ [<__selectedTiddler__>get[text]] }}}>
<div class="tc-tabbed-table-of-contents">
<$linkcatcher to=<<__selectedTiddler__>>>
<div class="tc-table-of-contents">
<$macrocall $name="toc-selective-expandable" tag=<<__tag__>> sort=<<__sort__>> itemClassFilter="[all[current]] -[<__selectedTiddler__>get[text]]"/>
<$macrocall $name="toc-selective-expandable" tag=<<__tag__>> sort=<<__sort__>> itemClassFilter="[all[current]] -[<__selectedTiddler__>get[text]]" exclude=<<__exclude__>>/>
</div>
</$linkcatcher>
<div class="tc-tabbed-table-of-contents-content">
@ -210,9 +210,9 @@ tags: $:/tags/Macro
</$tiddler>
\end
\define toc-tabbed-internal-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"")
\define toc-tabbed-internal-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"",exclude)
\whitespace trim
<$linkcatcher to=<<__selectedTiddler__>>>
<$macrocall $name="toc-tabbed-external-nav" tag=<<__tag__>> sort=<<__sort__>> selectedTiddler=<<__selectedTiddler__>> unselectedText=<<__unselectedText__>> missingText=<<__missingText__>> template=<<__template__>>/>
<$macrocall $name="toc-tabbed-external-nav" tag=<<__tag__>> sort=<<__sort__>> selectedTiddler=<<__selectedTiddler__>> unselectedText=<<__unselectedText__>> missingText=<<__missingText__>> template=<<__template__>> exclude=<<__exclude__>> />
</$linkcatcher>
\end

View File

@ -1,2 +1,2 @@
title: $:/tags/PageControls
list: [[$:/core/ui/Buttons/home]] [[$:/core/ui/Buttons/close-all]] [[$:/core/ui/Buttons/fold-all]] [[$:/core/ui/Buttons/unfold-all]] [[$:/core/ui/Buttons/permaview]] [[$:/core/ui/Buttons/new-tiddler]] [[$:/core/ui/Buttons/new-journal]] [[$:/core/ui/Buttons/new-image]] [[$:/core/ui/Buttons/import]] [[$:/core/ui/Buttons/export-page]] [[$:/core/ui/Buttons/control-panel]] [[$:/core/ui/Buttons/advanced-search]] [[$:/core/ui/Buttons/manager]] [[$:/core/ui/Buttons/tag-manager]] [[$:/core/ui/Buttons/language]] [[$:/core/ui/Buttons/palette]] [[$:/core/ui/Buttons/theme]] [[$:/core/ui/Buttons/layout]] [[$:/core/ui/Buttons/storyview]] [[$:/core/ui/Buttons/encryption]] [[$:/core/ui/Buttons/timestamp]] [[$:/core/ui/Buttons/full-screen]] [[$:/core/ui/Buttons/print]] [[$:/core/ui/Buttons/save-wiki]] [[$:/core/ui/Buttons/refresh]] [[$:/core/ui/Buttons/more-page-actions]]
list: [[$:/core/ui/Buttons/home]] [[$:/core/ui/Buttons/close-all]] [[$:/core/ui/Buttons/fold-all]] [[$:/core/ui/Buttons/unfold-all]] [[$:/core/ui/Buttons/permaview]] [[$:/core/ui/Buttons/new-tiddler]] [[$:/core/ui/Buttons/new-journal]] [[$:/core/ui/Buttons/new-image]] [[$:/core/ui/Buttons/import]] [[$:/core/ui/Buttons/export-page]] [[$:/core/ui/Buttons/control-panel]] [[$:/core/ui/Buttons/advanced-search]] [[$:/core/ui/Buttons/manager]] [[$:/core/ui/Buttons/tag-manager]] [[$:/core/ui/Buttons/language]] [[$:/core/ui/Buttons/palette]] [[$:/core/ui/Buttons/theme]] [[$:/core/ui/Buttons/layout]] [[$:/core/ui/Buttons/storyview]] [[$:/core/ui/Buttons/encryption]] [[$:/core/ui/Buttons/timestamp]] [[$:/core/ui/Buttons/full-screen]] [[$:/core/ui/Buttons/print]] [[$:/core/ui/Buttons/save-wiki]] [[$:/core/ui/Buttons/refresh]] [[$:/core/ui/Buttons/network-activity]] [[$:/core/ui/Buttons/more-page-actions]]

View File

@ -0,0 +1,36 @@
created: 20230601123245916
modified: 20230601125015463
title: Widget `destroy` method examples
type: text/vnd.tiddlywiki
!! When using a v-dom library
Virtual DOM libraries manages its internal state and apply state to DOM periodically, this is so called [["controlled" component|https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components]]. When Tiddlywiki remove a DOM element controlled by a v-dom library, it may throws error.
So when creating a plugin providing v-dom library binding, you need to tell v-dom library (for example, React.js) the DOM element is removed. We will use `destroy` method for this.
```js
render() {
// ...other render related code
if (this.root === undefined || this.containerElement === undefined) {
// initialize the v-dom library
this.root = ReactDom.createRoot(document.createElement('div'));
}
}
destroy() {
// end the lifecycle of v-dom library
this.root && this.root.unmount();
}
```
The `destroy` method will be called by parent widget. If you widget don't have any child widget, you can just write your own tear down logic. If it may have some child widget, don't forget to call original `destroy` method in the `Widget` class to destroy children widgets.
```js
Widget.prototype.destroy();
this.root && this.root.unmount();
/** if you are using ESNext
super.destroy();
this.root?.unmount();
*/
```

View File

@ -2,7 +2,7 @@ modified: 20141013085608911
tags: Mechanisms
title: TestingMechanism
TiddlyWiki5 incorporates the Jasmine JavaScript testing framework (see http://pivotal.github.io/jasmine/). It allows the same tests to be run both in the browser and under Node.js.
TiddlyWiki5 incorporates the Jasmine JavaScript testing framework (see https://jasmine.github.io/). It allows the same tests to be run both in the browser and under Node.js.
! TiddlyWiki5 Testing Components

View File

@ -1,7 +1,8 @@
title: WidgetModules
created: 20131101130700000
modified: 20230601130631884
tags: dev moduletypes
created: 201311011307
modified: 201311011307
title: WidgetModules
type: text/vnd.tiddlywiki
! Introduction
@ -78,4 +79,10 @@ The individual methods defined by the widget object are documented in the source
!! Widget `refreshChildren` method
!! Widget `findNextSiblingDomNode` method
!! Widget `findFirstDomNode` method
!! Widget `destroy` method
<<.from-version "5.3.0">> Gets called when any parent widget is unmounted from the widget tree.
[[Examples|Widget `destroy` method examples]]
!! Widget `removeChildDomNodes` method

View File

@ -0,0 +1,3 @@
title: $:/config/WikiParserRules/Inline/wikilink
enable

View File

@ -0,0 +1,40 @@
created: 20150117152612000
modified: 20230325101137075
tags: $:/tags/Stylesheet
title: $:/editions/tw5.com/doc-styles
type: text/vnd.tiddlywiki
a.doc-from-version.tc-tiddlylink {
display: inline-block;
border-radius: 1em;
background: <<colour muted-foreground>>;
color: <<colour background>>;
fill: <<colour background>>;
padding: 0 0.4em;
font-size: 0.7em;
text-transform: uppercase;
font-weight: bold;
line-height: 1.5;
vertical-align: text-bottom;
}
a.doc-deprecated-version.tc-tiddlylink {
display: inline-block;
border-radius: 1em;
background: red;
color: <<colour background>>;
fill: <<colour background>>;
padding: 0 0.4em;
font-size: 0.7em;
text-transform: uppercase;
font-weight: bold;
line-height: 1.5;
vertical-align: text-bottom;
}
.doc-deprecated-version svg,
.doc-from-version svg {
width: 1em;
height: 1em;
vertical-align: text-bottom;
}

View File

@ -0,0 +1,14 @@
code-body: yes
created: 20161008085627406
modified: 20221007122259593
tags: $:/tags/Macro
title: $:/editions/tw5.com/version-macros
type: text/vnd.tiddlywiki
\define .from-version(version)
<$link to={{{ [<__version__>addprefix[Release ]] }}} class="doc-from-version">{{$:/core/images/warning}} New in: <$text text=<<__version__>>/></$link>
\end
\define .deprecated-since(version, superseded:"TODO-Link")
<$link to="Deprecated - What does it mean" class="doc-deprecated-version tc-btn-invisible">{{$:/core/images/warning}} Deprecated since: <$text text=<<__version__>>/></$link> (see <$link to=<<__superseded__>>><$text text=<<__superseded__>>/></$link>)
\end

View File

@ -6,7 +6,7 @@ type: text/vnd.tiddlywiki
TiddlyWiki incorpora código de los siguientes proyectos OpenSource:
* [[The Stanford Javascript Crypto Library|http://bitwiseshiftleft.github.io/sjcl/]]
* [[The Jasmine JavaScript Test Framework|http://pivotal.github.io/jasmine/]]
* [[The Jasmine JavaScript Test Framework|https://jasmine.github.io/]]
* [[Normalize.css by Nicolas Gallagher|http://necolas.github.io/normalize.css/]]
...y materiales de estos otros proyectos:

View File

@ -6,7 +6,7 @@ type: text/vnd.tiddlywiki
TiddlyWiki intègre du code provenant de ces excellents projets OpenSource<<dp>>
* [[The Stanford Javascript Crypto Library|http://bitwiseshiftleft.github.io/sjcl/]]
* [[The Jasmine JavaScript Test Framework|http://pivotal.github.io/jasmine/]]
* [[The Jasmine JavaScript Test Framework|https://jasmine.github.io/]]
* [[Normalize.css by Nicolas Gallagher|http://necolas.github.io/normalize.css/]]
Et des contenus provenenant de ces sources<<dp>>

View File

@ -8,6 +8,6 @@ Tiddlers can contain formatted text:
Formatting is typed with special codes:
<$edit-text tiddler="FormattingDemoText" class="tc-edit-texteditor" minHeight="10px"/>
<$edit-text tiddler="FormattingDemoText" class="tc-edit-texteditor" minHeight="100px"/>
TiddlyWiki is not just for text. [[Images]] are first class citizens, too.

View File

@ -49,14 +49,6 @@
],
"build": {
"index": [
"--rendertiddler","$:/core/save/all","index.html","text/plain"],
"favicon": [
"--savetiddler","$:/favicon.ico","favicon.ico",
"--savetiddler","$:/green_favicon.ico","static/favicon.ico"],
"static": [
"--rendertiddler","$:/core/templates/static.template.html","static.html","text/plain",
"--rendertiddler","$:/core/templates/alltiddlers.template.html","alltiddlers.html","text/plain",
"--rendertiddlers","[!is[system]]","$:/core/templates/static.tiddler.html","static","text/plain",
"--rendertiddler","$:/core/templates/static.template.css","static/static.css","text/plain"]
"--rendertiddler","$:/core/save/all","index.html","text/plain"]
}
}

View File

@ -30,10 +30,15 @@ These changes lay the groundwork for macros and related features to be deprecate
The new transclusion architecture is not by itself sufficient to enable us to fully deprecate macros yet. To handle the remaining use cases we propose a new backtick quoted attribute format that allows for the substitution of variable values. See https://github.com/Jermolene/TiddlyWiki5/issues/6663 for details.
! Defaulting to Disabling CamelCase Links
<<.link-badge-updated "https://github.com/Jermolene/TiddlyWiki5/pull/7513">> CamelCase linking is now disabled by default. (Note that this wiki has CamelCase linking explicitly enabled)
! Plugin Improvements
* <<.link-badge-extended "https://github.com/Jermolene/TiddlyWiki5/pull/7260">> Dynannotate pugin to support three additional search modes
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/7365">> problem with [[BrowserStorage Plugin]] unnecessarily saving shadow tiddlers
* <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/pull/7493">> [[CodeMirror Plugin]] to add an option to make trailing spaces visible
! Translation improvement
@ -55,8 +60,10 @@ Improvements to the following translations:
! Filter improvements
* <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/7511"> new [[deserialize Operator]] for converting various textual representations of tiddlers into JSON data
* <<.link-badge-extended "https://github.com/Jermolene/TiddlyWiki5/pull/7292">> [[format Operator]] to support converting Unix timestamps to TiddlyWiki's native date format
! Hackability Improvements
* <<.link-badge-extended "https://github.com/Jermolene/TiddlyWiki5/pull/7413">> [[Core Icons]] to allow the size to be controlled with a parameter
@ -72,14 +79,20 @@ Improvements to the following translations:
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/7380">> crashes when using an invalid CSS selector for [[WidgetMessage: tm-focus-selector]] and [[WidgetMessage: tm-scroll]]
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/7401">> bug whereby scrolling occurs if the linkcatcher widget triggers an action-navigate and the $scroll attribute is set to "no"
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/7409">> problem switching between LTR and RTL text
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/7448">> bug when checkbox widget's listField attribute was given the name of a date field (like <<.field created>> or <<.field modified>>)
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/issues/7529">> size of buttons in dropdown for editor "link" toolbar button
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/8e132948b6bec623d81d300fbe6dc3a0307bcc6d">> crash when transcluding a lazily loaded tiddler as an attribute value
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/issues/7462">> DiffTextWidget crash with missing or empty attributes
! Developer Improvements
* <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/6699">> support for a `destroy()` method for widgets, giving them a chance to dispose of any resources
*
! Node.js Improvements
* <<.link-badge-extended "https://github.com/Jermolene/TiddlyWiki5/pull/7471">> [[WebServer Parameter: authenticated-user-header]] to require URI encoding of authenticated username header, permitting non-ASCII characters in usernames
* <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/7253">> support for `filepath` source attribute to [[tiddlywiki.files Files]]
* <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/commit/48b22abdaab62c281c207127c66883b50898f9dd">> a warning message for JSON errors in [[tiddlywiki.info Files]] or [[plugin.info Files|PluginFolders]]
! Performance Improvements
@ -91,16 +104,22 @@ Improvements to the following translations:
<<.contributors """
Arlen22
BramChen
btheado
donmor
flibbles
GameDungeon
JoshuaFontany
kookma
linonetwo
Marxsal
mateuszwilczek
michsa
muzimuzhi
pmario
rmunn
saqimtiaz
tavin
twMat
yaisog
""">>

View File

@ -0,0 +1,3 @@
title: $:/config/WikiParserRules/Inline/wikilink
enable

View File

@ -0,0 +1,8 @@
title: dezerializer test data case 6
type: application/json
[
{"created":"20230601125557184","text":"Before you start storing important information in ~TiddlyWiki it is vital to make sure that you can reliably save changes. See https://tiddlywiki.com/#GettingStarted for details\n\n","title":"GettingStarted","modified":"20230601125601619"},
{"created":"20230601125507054","text":"Welcome to \"TiddlyWiki\".\n\nThis is a test tiddler.","tags":"","title":"Hello There \"Welcome\"","modified":"20230601125551144"},
{"title":"TiddlyWiki","created":"20130822170700000","modified":"20170127221451610","tags":"Concepts","type":"text/vnd.tiddlywiki","text":"~TiddlyWiki is a rich, interactive tool for manipulating complex data with structure that doesn't easily fit into conventional tools like spreadsheets or wordprocessors.\n\n~TiddlyWiki is designed to fit around your brain, helping you deal with the things that won't fit."}
]

View File

@ -12,15 +12,15 @@ title: Output
title: Actions
\whitespace trim
<!-- Define the <$$action-mywidget> widget by defining a transcludable variable with that name -->
\widget $$action-mywidget(one:'Jaguar')
<!-- Define the <$action.mywidget> widget by defining a transcludable variable with that name -->
\widget $action.mywidget(one:'Jaguar')
\whitespace trim
<$action-setfield $tiddler="Result" $field="text" $value=<<one>>/>
\end
<$$action-mywidget one="Dingo">
<$action.mywidget one="Dingo">
Crocodile
</$$action-mywidget>
</$action.mywidget>
+
title: ExpectedResult

View File

@ -12,21 +12,21 @@ title: Output
title: TiddlerOne
\whitespace trim
<!-- Define the <$$mywidget> widget by defining a transcludable variable with that name -->
\widget $$mywidget(one:'Jaguar')
<!-- Define the <$my.widget> widget by defining a transcludable variable with that name -->
\widget $my.widget(one:'Jaguar')
\whitespace trim
<$text text=<<one>>/>
<$slot $name="ts-raw">
Whale
</$slot>
\end
<$$mywidget one="Dingo">
<$my.widget one="Dingo">
Crocodile
</$$mywidget>
<$$mywidget one="BumbleBee">
</$my.widget>
<$my.widget one="BumbleBee">
Squirrel
</$$mywidget>
<$$mywidget/>
</$my.widget>
<$my.widget/>
+
title: ExpectedResult

View File

@ -6,13 +6,13 @@ tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
\widget $$mywidget()
\widget $my.widget()
<$slot $name=ts-raw>the body is empty</$slot>
\end
#<$$mywidget/>
#<$$mywidget></$$mywidget>
#<$$mywidget>the body is not empty</$$mywidget>
#<$my.widget/>
#<$my.widget></$my.widget>
#<$my.widget>the body is not empty</$my.widget>
+
title: ExpectedResult

View File

@ -6,21 +6,21 @@ tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
\widget $$mywidget(one:'Jaguar')
\widget $my.widget(one:'Jaguar')
\whitespace trim
<$text text=<<one>>/>
<$slot $name="ts-stuff">
Whale
</$slot>
\end
<$$mywidget one="Dingo">
<$my.widget one="Dingo">
<$fill $name="ts-stuff">
Crocodile
</$fill>
</$$mywidget>
<$$mywidget one="BumbleBee">
</$my.widget>
<$my.widget one="BumbleBee">
Squirrel
</$$mywidget>
</$my.widget>
+
title: ExpectedResult

View File

@ -12,17 +12,17 @@ title: Output
title: TiddlerOne
\whitespace trim
<!-- Redefine the <$$mywidget> widget by defining a transcludable variable with that name -->
\widget $$mywidget($variable:'Jaguar')
<!-- Redefine the <$my.widget> widget by defining a transcludable variable with that name -->
\widget $my.widget($variable:'Jaguar')
\whitespace trim
<$text text=<<$variable>>/>
<$slot $name="ts-raw">
Whale
</$slot>
\end
<$$mywidget $variable="Dingo">
<$my.widget $variable="Dingo">
Crocodile
</$$mywidget>
</$my.widget>
+
title: ExpectedResult

View File

@ -0,0 +1,40 @@
title: Transclude/Macro/Missing
description: Transcluding a missing or blank variable
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
<$macrocall $name="missingmacro">
Fallback content
</$macrocall>
<$transclude $variable="missingmacro">
Fallback content
</$transclude>
<$macrocall $name="">
Fallback content
</$macrocall>
<$transclude $variable="">
Fallback content
</$transclude>
<$let emptyVariable="">
<$macrocall $name="emptyVariable">
Fallback content
</$macrocall>
<$transclude $variable="emptyVariable">
Fallback content
</$transclude>
</$let>
+
title: ExpectedResult
<p>Fallback content</p><p>Fallback content</p><p>Fallback content</p><p>Fallback content</p><p>Fallback content</p><p>Fallback content</p>

View File

@ -56,7 +56,7 @@ Tests the checkbox widget thoroughly.
* Test data for checkbox widget tests
*/
const fieldModeTests = [
var fieldModeTests = [
{
testName: "field mode checked",
tiddlers: [{title: "TiddlerOne", text: "Jolly Old World", expand: "yes"}],
@ -95,16 +95,16 @@ Tests the checkbox widget thoroughly.
},
];
const indexModeTests = fieldModeTests.map(data => {
const newData = {...data};
const newName = data.testName.replace('field mode', 'index mode');
const newTiddlers = data.tiddlers.map(tiddler => {
var indexModeTests = fieldModeTests.map(data => {
var newData = {...data};
var newName = data.testName.replace('field mode', 'index mode');
var newTiddlers = data.tiddlers.map(tiddler => {
return {title: tiddler.title, type: "application/x-tiddler-dictionary", text: `one: a\nexpand: ${tiddler.expand}\ntwo: b`}
});
const newWidgetText = data.widgetText.replace("field='expand'", "index='expand'");
const newChange = {};
for (const key of Object.keys(data.expectedChange)) {
const oldChange = data.expectedChange[key];
var newWidgetText = data.widgetText.replace("field='expand'", "index='expand'");
var newChange = {};
for (var key of Object.keys(data.expectedChange)) {
var oldChange = data.expectedChange[key];
if (oldChange.expand) {
newChange[key] = { text: `one: a\nexpand: ${oldChange.expand}\ntwo: b` }
} else {
@ -119,7 +119,26 @@ Tests the checkbox widget thoroughly.
return newData;
});
const listModeTests = [
var listModeTestsForDateFields = [
{
testName: "list mode created date field",
tiddlers: [{title: "Colors", created: "201304152222", modified: "202301022222"}],
widgetText: "<$checkbox tiddler='Colors' listField='created' checked='green' />",
startsOutChecked: false,
finalValue: false,
expectedChange: { "Colors": { created: new Date("2013-04-15T22:22:00Z")}} // created field should *not* be touched by a listField checkbox
},
{
testName: "list mode modified date field",
tiddlers: [{title: "Colors", created: "201304152222", modified: "202301022222"}],
widgetText: "<$checkbox tiddler='Colors' listField='modified' checked='green' />",
startsOutChecked: false,
finalValue: false,
expectedChange: { "Colors": { modified: new Date("2023-01-02T22:22:00Z")}} // modified field should *not* be touched by a listField checkbox
},
]
var listModeTests = [
{
testName: "list mode add",
tiddlers: [{title: "Colors", colors: "orange yellow"}],
@ -235,11 +254,11 @@ Tests the checkbox widget thoroughly.
];
// https://github.com/Jermolene/TiddlyWiki5/issues/6871
const listModeTestsWithListField = (
var listModeTestsWithListField = (
listModeTests
.filter(data => data.widgetText.includes("listField='colors'"))
.map(data => {
const newData = {
var newData = {
...data,
tiddlers: data.tiddlers.map(tiddler => ({...tiddler, list: tiddler.colors, colors: undefined})),
widgetText: data.widgetText.replace("listField='colors'", "listField='list'"),
@ -250,11 +269,11 @@ Tests the checkbox widget thoroughly.
return newData;
})
);
const listModeTestsWithTagsField = (
var listModeTestsWithTagsField = (
listModeTests
.filter(data => data.widgetText.includes("listField='colors'"))
.map(data => {
const newData = {
var newData = {
...data,
tiddlers: data.tiddlers.map(tiddler => ({...tiddler, tags: tiddler.colors, colors: undefined})),
widgetText: data.widgetText.replace("listField='colors'", "listField='tags'"),
@ -266,20 +285,20 @@ Tests the checkbox widget thoroughly.
})
);
const indexListModeTests = listModeTests.map(data => {
const newData = {...data};
const newName = data.testName.replace('list mode', 'index list mode');
const newTiddlers = data.tiddlers.map(tiddler => {
var indexListModeTests = listModeTests.map(data => {
var newData = {...data};
var newName = data.testName.replace('list mode', 'index list mode');
var newTiddlers = data.tiddlers.map(tiddler => {
if (tiddler.hasOwnProperty('colors')) {
return {title: tiddler.title, type: "application/x-tiddler-dictionary", text: `one: a\ncolors: ${tiddler.colors}\ntwo: b`}
} else if (tiddler.hasOwnProperty('someField')) {
return {title: tiddler.title, type: "application/x-tiddler-dictionary", text: `one: a\nsomeField: ${tiddler.someField}\ntwo: b`}
}
});
const newWidgetText = data.widgetText.replace("listField='colors'", "listIndex='colors'").replace(/\$field/g, '$index').replace("listField='someField'", "listIndex='someField'");
const newChange = {};
for (const key of Object.keys(data.expectedChange)) {
const oldChange = data.expectedChange[key];
var newWidgetText = data.widgetText.replace("listField='colors'", "listIndex='colors'").replace(/\$field/g, '$index').replace("listField='someField'", "listIndex='someField'");
var newChange = {};
for (var key of Object.keys(data.expectedChange)) {
var oldChange = data.expectedChange[key];
if (oldChange.colors) {
newChange[key] = { text: `one: a\ncolors: ${oldChange.colors}\ntwo: b` }
} else if (oldChange.someField !== undefined) {
@ -296,7 +315,7 @@ Tests the checkbox widget thoroughly.
return newData;
});
const filterModeTests = [
var filterModeTests = [
{
testName: "filter mode false -> true",
tiddlers: [{title: "Colors", colors: "red orange yellow"}],
@ -482,9 +501,10 @@ Tests the checkbox widget thoroughly.
},
];
const checkboxTestData = fieldModeTests.concat(
var checkboxTestData = fieldModeTests.concat(
indexModeTests,
listModeTests,
listModeTestsForDateFields,
listModeTestsWithListField,
listModeTestsWithTagsField,
indexListModeTests,
@ -494,7 +514,7 @@ Tests the checkbox widget thoroughly.
/*
* Checkbox widget tests using the test data above
*/
for (const data of checkboxTestData) {
for (var data of checkboxTestData) {
it('checkbox widget test: ' + data.testName, function() {
// Setup
@ -505,7 +525,7 @@ Tests the checkbox widget thoroughly.
// Check initial state
const widget = findNodeOfType('checkbox', widgetNode);
var widget = findNodeOfType('checkbox', widgetNode);
// Verify that the widget is or is not checked as expected
expect(widget.getValue()).toBe(data.startsOutChecked);
@ -519,16 +539,16 @@ Tests the checkbox widget thoroughly.
widget.handleChangeEvent(null);
// Check state again: in most tests, checkbox should be inverse of what it was
const finalValue = data.hasOwnProperty('finalValue') ? data.finalValue : !data.startsOutChecked;
var finalValue = data.hasOwnProperty('finalValue') ? data.finalValue : !data.startsOutChecked;
expect(widget.getValue()).toBe(finalValue);
// Check that tiddler(s) has/have gone through expected change(s)
for (const key of Object.keys(data.expectedChange)) {
const tiddler = wiki.getTiddler(key);
const change = data.expectedChange[key];
for (const fieldName of Object.keys(change)) {
const expectedValue = change[fieldName];
const fieldValue = tiddler.fields[fieldName];
for (var key of Object.keys(data.expectedChange)) {
var tiddler = wiki.getTiddler(key);
var change = data.expectedChange[key];
for (var fieldName of Object.keys(change)) {
var expectedValue = change[fieldName];
var fieldValue = tiddler.fields[fieldName];
expect(fieldValue).toEqual(expectedValue);
}
}

View File

@ -0,0 +1,44 @@
/*\
title: test-deserialize-operator.js
type: application/javascript
tags: [[$:/tags/test-spec]]
Tests deserialize[] filter operator with various core deserializers
\*/
(function(){
/* jslint node: true, browser: true */
/* eslint-env node, browser, jasmine */
/* eslint no-mixed-spaces-and-tabs: ["error", "smart-tabs"]*/
/* global $tw, require */
"use strict";
describe("deserialize operator tests", function() {
it("should support the deserialize[] operator", function() {
//Unknown deserializer as operand
expect($tw.wiki.filterTiddlers("[{dezerializer test data case 4}deserialize[unknown/deserializer]]")).toEqual([$tw.language.getString("Error/DeserializeOperator/UnknownDeserializer")]);
//Missing operand
expect($tw.wiki.filterTiddlers("[{dezerializer test data case 4}deserialize[]]")).toEqual([$tw.language.getString("Error/DeserializeOperator/MissingOperand")]);
//Deserialize TiddlyWiki file
expect($tw.wiki.filterTiddlers("[{dezerializer test data case 4}deserialize[text/html]]")).toEqual(['[{"type":"text/vnd.tiddlywiki","text":"Abacus","title":"Hello \\"There\\""},{"title":"Hello \\"There\\"","text":"Calculator"}]']);
expect($tw.wiki.filterTiddlers("[{dezerializer test data case 5}deserialize[text/html]]")).toEqual(['[{"type":"text/vnd.tiddlywiki","text":"Abacus","title":"Hello \\"There\\""},{"title":"Hello \\"There\\"","text":"Calculator"},{"title":"Hello \\"There\\"","text":"Protractor"}]']);
// Deserialize JSON payload containing tiddlers
expect($tw.wiki.filterTiddlers("[{dezerializer test data case 6}deserialize[application/json]]")).toEqual( [ `[{"created":"20230601125557184","text":"Before you start storing important information in ~TiddlyWiki it is vital to make sure that you can reliably save changes. See https://tiddlywiki.com/#GettingStarted for details\\n\\n","title":"GettingStarted","modified":"20230601125601619"},{"created":"20230601125507054","text":"Welcome to \\"TiddlyWiki\\".\\n\\nThis is a test tiddler.","tags":"","title":"Hello There \\"Welcome\\"","modified":"20230601125551144"},{"title":"TiddlyWiki","created":"20130822170700000","modified":"20170127221451610","tags":"Concepts","type":"text/vnd.tiddlywiki","text":"~TiddlyWiki is a rich, interactive tool for manipulating complex data with structure that doesn't easily fit into conventional tools like spreadsheets or wordprocessors.\\n\\n~TiddlyWiki is designed to fit around your brain, helping you deal with the things that won't fit."}]` ]);
expect($tw.wiki.filterTiddlers("[{dezerializer test data case 6}deserialize[application/json]jsonindexes[]] :map[{dezerializer test data case 6}jsonget<currentTiddler>,[title]]")).toEqual([ 'GettingStarted', 'Hello There "Welcome"', 'TiddlyWiki' ]);
//Deserialize TiddlyWiki file with an mismatched deserializer
expect($tw.wiki.filterTiddlers("[{dezerializer test data case 5}deserialize[application/json]]")).toEqual([jasmine.stringMatching('JSON error')]);
});
});
})();

View File

@ -99,14 +99,14 @@ Tests the filtering mechanism.
},
"TiddlerSix": {
title: "TiddlerSix",
text: "Missing inaction from TiddlerOne",
text: "Missing inaction from [[TiddlerOne]]",
filter: "[[one]] [[a a]] [subfilter{hasList!!list}]",
tags: []
},
"TiddlerSeventh": {
title: "TiddlerSeventh",
text: "",
list: "TiddlerOne [[Tiddler Three]] [[a fourth tiddler]] MissingTiddler",
list: "[[TiddlerOne]] [[Tiddler Three]] [[a fourth tiddler]] [[MissingTiddler]]",
tags: ["one"]
},
"Tiddler8": {
@ -144,7 +144,7 @@ Tests the filtering mechanism.
modified: "201304152211"
},{
title: "Tiddler Three",
text: "The speed of sound in light\n\nThere is no TiddlerZero but TiddlerSix",
text: "The speed of sound in light\n\nThere is no [[TiddlerZero]] but [[TiddlerSix]]",
tags: ["one","two"],
cost: "56",
value: "80",
@ -252,9 +252,9 @@ Tests the filtering mechanism.
});
it("should handle the lookup operator", function() {
expect(wiki.filterTiddlers("Six Seventh 8 +[lookup[Tiddler]]").join(",")).toBe("Missing inaction from TiddlerOne,,Tidd");
expect(wiki.filterTiddlers("Six Seventh 8 +[lookup:8[Tiddler]]").join(",")).toBe("Missing inaction from TiddlerOne,8,Tidd");
expect(wiki.filterTiddlers("Six Seventh 8 +[lookup:8[Tiddler],[text]]").join(",")).toBe("Missing inaction from TiddlerOne,8,Tidd");
expect(wiki.filterTiddlers("Six Seventh 8 +[lookup[Tiddler]]").join(",")).toBe("Missing inaction from [[TiddlerOne]],,Tidd");
expect(wiki.filterTiddlers("Six Seventh 8 +[lookup:8[Tiddler]]").join(",")).toBe("Missing inaction from [[TiddlerOne]],8,Tidd");
expect(wiki.filterTiddlers("Six Seventh 8 +[lookup:8[Tiddler],[text]]").join(",")).toBe("Missing inaction from [[TiddlerOne]],8,Tidd");
expect(wiki.filterTiddlers("Six Seventh 8 +[lookup[Tiddler],[tags]]").join(",")).toBe(",one,one");
});
@ -990,10 +990,10 @@ Tests the filtering mechanism.
expect(wiki.filterTiddlers("[!sortsub:number<sort1>]",anchorWidget).join(",")).toBe("filter regexp test,a fourth tiddler,$:/ShadowPlugin,$:/TiddlerTwo,Tiddler Three,has filter,TiddlerOne,hasList,one");
expect(wiki.filterTiddlers("[sortsub:string<sort1>]",anchorWidget).join(",")).toBe("has filter,TiddlerOne,$:/TiddlerTwo,Tiddler Three,$:/ShadowPlugin,a fourth tiddler,filter regexp test,one,hasList");
expect(wiki.filterTiddlers("[!sortsub:string<sort1>]",anchorWidget).join(",")).toBe("hasList,one,filter regexp test,a fourth tiddler,$:/ShadowPlugin,$:/TiddlerTwo,Tiddler Three,has filter,TiddlerOne");
expect(wiki.filterTiddlers("[sortsub:number<sort2>]",anchorWidget).join(",")).toBe("one,TiddlerOne,hasList,has filter,a fourth tiddler,Tiddler Three,$:/TiddlerTwo,filter regexp test,$:/ShadowPlugin");
expect(wiki.filterTiddlers("[!sortsub:number<sort2>]",anchorWidget).join(",")).toBe("$:/ShadowPlugin,filter regexp test,$:/TiddlerTwo,Tiddler Three,a fourth tiddler,has filter,hasList,TiddlerOne,one");
expect(wiki.filterTiddlers("[sortsub:string<sort2>]",anchorWidget).join(",")).toBe("one,TiddlerOne,hasList,has filter,$:/ShadowPlugin,a fourth tiddler,Tiddler Three,$:/TiddlerTwo,filter regexp test");
expect(wiki.filterTiddlers("[!sortsub:string<sort2>]",anchorWidget).join(",")).toBe("filter regexp test,$:/TiddlerTwo,Tiddler Three,a fourth tiddler,$:/ShadowPlugin,has filter,hasList,TiddlerOne,one");
expect(wiki.filterTiddlers("[sortsub:number<sort2>]",anchorWidget).join(",")).toBe("one,TiddlerOne,hasList,has filter,a fourth tiddler,$:/TiddlerTwo,Tiddler Three,filter regexp test,$:/ShadowPlugin");
expect(wiki.filterTiddlers("[!sortsub:number<sort2>]",anchorWidget).join(",")).toBe("$:/ShadowPlugin,filter regexp test,Tiddler Three,$:/TiddlerTwo,a fourth tiddler,has filter,hasList,TiddlerOne,one");
expect(wiki.filterTiddlers("[sortsub:string<sort2>]",anchorWidget).join(",")).toBe("one,TiddlerOne,hasList,has filter,$:/ShadowPlugin,a fourth tiddler,$:/TiddlerTwo,Tiddler Three,filter regexp test");
expect(wiki.filterTiddlers("[!sortsub:string<sort2>]",anchorWidget).join(",")).toBe("filter regexp test,Tiddler Three,$:/TiddlerTwo,a fourth tiddler,$:/ShadowPlugin,has filter,hasList,TiddlerOne,one");
expect(wiki.filterTiddlers("[[TiddlerOne]] [[$:/TiddlerTwo]] [[Tiddler Three]] [[a fourth tiddler]] +[!sortsub:number<sort3>]",anchorWidget).join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne,a fourth tiddler");
expect(wiki.filterTiddlers("a1 a10 a2 a3 b10 b3 b1 c9 c11 c1 +[sortsub:alphanumeric<sort4>]",anchorWidget).join(",")).toBe("a1,a2,a3,a10,b1,b3,b10,c1,c9,c11");
// #7155. The order of the output is the same as the input when an undefined variable is used in the subfitler
@ -1066,7 +1066,11 @@ Tests the filtering mechanism.
});
it("should handle the deserializers operator", function() {
expect(wiki.filterTiddlers("[deserializers[]]").join(",")).toBe("application/javascript,application/json,application/x-tiddler,application/x-tiddler-html-div,application/x-tiddlers,text/css,text/html,text/plain");
var expectedDeserializers = ["application/javascript","application/json","application/x-tiddler","application/x-tiddler-html-div","application/x-tiddlers","text/css","text/html","text/plain"];
if($tw.browser) {
expectedDeserializers.unshift("(DOM)");
}
expect(wiki.filterTiddlers("[deserializers[]]").join(",")).toBe(expectedDeserializers.join(","));
});
it("should handle the charcode operator", function() {

View File

@ -45,16 +45,6 @@ describe("WikiText tests", function() {
it("should support attributes specified as macro invocations", function() {
expect(wiki.renderTiddler("text/html","TiddlerFour")).toBe("<p><a class=\"tc-tiddlylink tc-tiddlylink-missing\" href=\"#This%20is%20my%20%27%27amazingly%27%27%20groovy%20macro%21\">This is a link</a></p>");
});
it("should identify wikiwords to automatically link", function() {
expect(wiki.renderText("text/html","text/vnd-tiddlywiki","No wikilinks here").indexOf("<a") !== -1).toBe(false);
expect(wiki.renderText("text/html","text/vnd-tiddlywiki","One WikiLink here").indexOf("<a") !== -1).toBe(true);
expect(wiki.renderText("text/html","text/vnd-tiddlywiki","No Wiki-Link here").indexOf("<a") !== -1).toBe(false);
expect(wiki.renderText("text/html","text/vnd-tiddlywiki","No Wiki×Link here").indexOf("<a") !== -1).toBe(false);
expect(wiki.renderText("text/html","text/vnd-tiddlywiki","No Wiki÷Link here").indexOf("<a") !== -1).toBe(false);
expect(wiki.renderText("text/html","text/vnd-tiddlywiki","No xWikiLink here").indexOf("<a") !== -1).toBe(false);
expect(wiki.renderText("text/html","text/vnd-tiddlywiki","No -WikiLink here").indexOf("<a") !== -1).toBe(false);
expect(wiki.renderText("text/html","text/vnd-tiddlywiki","No _WikiLink here").indexOf("<a") !== -1).toBe(false);
});
it("handles style wikitext notation", function() {
expect(wiki.renderText("text/html","text/vnd-tiddlywiki","@@.myclass\n!header\n@@")).toBe("<h1 class=\"myclass\">header</h1>");
expect(wiki.renderText("text/html","text/vnd-tiddlywiki","@@.myclass\n<div>\n\nContent</div>\n@@")).toBe("<div class=\"myclass\"><p>Content</p></div>");

View File

@ -6,6 +6,8 @@ type: text/vnd.tiddlywiki
The edit template body cascade is a [[cascade|Cascades]] used by the default edit template to choose the template for displaying the tiddler body.
The core edit template body cascade can be found in $:/core/ui/EditTemplate/body
The default edit template body cascade consists of:
# If the tiddler has the field ''_canonical_uri'' then use the template $:/core/ui/EditTemplate/body/canonical-uri to display the remote URL
@ -13,4 +15,4 @@ The default edit template body cascade consists of:
You can see the current settings for the view template body cascade in $:/ControlPanel under the ''Info'' -> ''Advanced'' -> ''Cascades'' -> ''Edit Template Body'' tab.
<<list-links "[tag[Edit Template Body Cascade]]">>
<<list-links "[tag[Edit Template Body Cascade]]">>

View File

@ -6,6 +6,8 @@ type: text/vnd.tiddlywiki
The field editor cascade is a [[cascade|Cascades]] used to choose a template for rendering the field editor within the [[EditTemplate|$:/core/ui/EditTemplate/fields]].
The core field editor cascade can be found in $:/core/ui/EditTemplate/fields
The default field editor cascade only contains one element:
# Use the tiddler $:/core/ui/EditTemplate/fieldEditor/default to render the field
@ -14,4 +16,4 @@ See [[Customizing EditTemplate field rendering]] for more details.
You can see the current settings for the field editor cascade in $:/ControlPanel under the ''Info'' -> ''Advanced'' -> ''Cascades'' -> ''Field Editor'' tab.
<<list-links "[tag[Tiddler Field Editor Cascade]]">>
<<list-links "[tag[Tiddler Field Editor Cascade]]">>

View File

@ -9,9 +9,13 @@ tags: Concepts
<$button actions=<<actions>>>$text$</$button>
\end
ShadowTiddlers are tiddlers that are loaded from within [[Plugins]]. Unlike ordinary tiddlers, they don't appear in most lists.
ShadowTiddlers are tiddlers that are loaded from [[Plugins]] at the wiki startup. Unlike ordinary tiddlers, they don't appear in most lists.
ShadowTiddlers can be overridden with an ordinary tiddler of the same name. If that tiddler is subsequently deleted then the original shadow tiddler is automatically restored.
!! Overriding Shadow Tiddlers to modify plugins
A ShadowTiddler can be overridden with an ordinary tiddler of the same name. This leaves the shadow tiddler intact but the plugin will use the overriding tiddler in its place, effectively allowing users to modify the behaviour of plugins.
Users are cautioned against overriding shadow tiddlers because if the shadow tiddler is changed in a plugin update, the overriding tiddler may no longer perform as intended. To remedy this, the overriding tiddler may be modified or deleted. If the overriding tiddler is deleted, then the plugin falls back to using the original shadow tiddler.
!! Overridden Shadow Tiddlers

View File

@ -6,6 +6,8 @@ type: text/vnd.tiddlywiki
"Story tiddler template" refers to the template used to display a tiddler within the story river.
The core story tiddler template can be found in $:/core/ui/StoryTiddlerTemplate
The [[Story Tiddler Template Cascade]] is used to choose the template to be used for a particular tiddler. By default, the edit template is used for tiddlers in draft mode, and the view template used otherwise.
See also:

View File

@ -6,6 +6,8 @@ type: text/vnd.tiddlywiki
The tiddler colour cascade is a [[cascade|Cascades]] used to choose which colour should be used for a particular tiddler.
Core tiddler colour cascades can be found in $:/core/macros/tag, $:/core/ui/Components/tag-link, $:/core/ui/EditTemplate/tags, $:/core/ui/TagPickerTagTemplate, $:/core/ui/TagTemplate and $:/core/ui/ViewTemplate/title
The default tiddler colour cascade consists of:
# If the tiddler has a ''color'' field, use the value as the colour
@ -13,4 +15,4 @@ The default tiddler colour cascade consists of:
You can see the current settings for the tiddler colour cascade in $:/ControlPanel under the ''Info'' -> ''Advanced'' -> ''Cascades'' -> ''Tiddler Colour'' tab.
<<list-links "[tag[Tiddler Colour Cascade]]">>
<<list-links "[tag[Tiddler Colour Cascade]]">>

View File

@ -6,6 +6,8 @@ type: text/vnd.tiddlywiki
The tiddler icon cascade is a [[cascade|Cascades]] used to choose which icon should be used for a particular tiddler.
The core tiddler icon cascade can be found in $:/core/ui/TiddlerIcon
The default tiddler icon cascade consists of:
# If the tiddler has an ''icon'' field, use the value as the title of the icon tiddler
@ -13,4 +15,4 @@ The default tiddler icon cascade consists of:
You can see the current settings for the tiddler icon cascade in $:/ControlPanel under the ''Info'' -> ''Advanced'' -> ''Cascades'' -> ''Tiddler Icon'' tab.
<<list-links "[tag[Tiddler Icon Cascade]]">>
<<list-links "[tag[Tiddler Icon Cascade]]">>

View File

@ -6,6 +6,8 @@ type: text/vnd.tiddlywiki
The view template title cascade is a [[cascade|Cascades]] used by the default view template to choose the template for displaying the tiddler title.
The core view template title cascade can be found in $:/core/ui/ViewTemplate/title
The default view template title cascade consists of:
# If the tiddler title starts with `$:/` then use the template $:/core/ui/ViewTemplate/title/system which causes the `$:/` prefix to be displayed in pale text
@ -13,4 +15,4 @@ The default view template title cascade consists of:
You can see the current settings for the view template title cascade in $:/ControlPanel under the ''Info'' -> ''Advanced'' -> ''Cascades'' -> ''View Template Title'' tab.
<<list-links "[tag[View Template Title Cascade]]">>
<<list-links "[tag[View Template Title Cascade]]">>

View File

@ -0,0 +1,26 @@
caption: deserialize
created: 20230601195749377
from-version: 5.3.0
modified: 20230602105513132
op-input: a selection of strings
op-output: JSON representations of tiddlers extracted from input titles.
op-parameter: the deserializer module to be used to extract tiddlers from the input
op-purpose: extract JSON representation of tiddlers from the input strings
tags: [[Filter Operators]] [[Special Operators]]
title: deserialize Operator
type: text/vnd.tiddlywiki
<<.tip "Deserializer modules parse text in various formats into their JSON representation as tiddlers. You can see the deserializers available in a wiki using the [[deserializers operator|deserializers Operator]].">>
|!Deserializer |!Description |
|(DOM)|Extracts tiddlers from a DOM node, should not be used with the <<.op deserialize[]>> operator |
|application/javascript|Parses a JavaScript module as a tiddler extracting fields from the header comment|
|application/json|Parses [[JSON|JSON in TiddlyWiki]] into tiddlers|
|application/x-tiddler|Parses the [[.tid file format|TiddlerFiles]] as a tiddler|
|application/x-tiddler-html-div|Parses the [[<DIV>.tiddler file format|TiddlerFiles]] as a tiddler|
|application/x-tiddlers|Parses the [[MultiTiddlerFile format|MultiTiddlerFiles]] as tiddlers|
|text/css|Parses CSS as a tiddler extracting fields from the header comment|
|text/html|Parses an HTML file into tiddlers. Supports ~TiddlyWiki Classic HTML files, ~TiddlyWiki5 HTML files and ordinary HTML files|
|text/plain|Parses plain text as a tiddler|
<<.operator-examples "deserialize">>

View File

@ -0,0 +1,29 @@
created: 20230601200356736
modified: 20230602105036887
tags: [[Operator Examples]] [[deserialize Operator]]
title: deserialize Operator (Examples)
type: text/vnd.tiddlywiki
\define html-data()
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test Data</title>
</head>
<body>
<!--~~ Ordinary tiddlers ~~-->
<div id="storeArea" style="display:none;"><div title="Hello &quot;There&quot;" type="text/vnd.tiddlywiki">
<pre>Abacus</pre>
</div>
</div>
<script class="tiddlywiki-tiddler-store" type="application/json">[{"title":"Hello \"There\"","text":"Calculator"},{"title":"Hello \"There\"","text":"Protractor"}]</script>
</body>
</html>
\end
This example uses the predefined variable `html-data`:
<$codeblock code=<<html-data>> language="HTML"/>
<<.operator-example 1 "[<html-data>deserialize[text/html]]">>

View File

@ -21,7 +21,7 @@ Functions can be invoked in several ways:
* Directly transclude functions with the syntax `<<myfn param:"value">>`
* Assign functions to widget attributes with the syntax `<div class=<<myfn param:"value">>>`
* Invoke functions via the [[function Operator]] with the syntax `[function[myfn],[value],...]`
* Directly invoke functions whose names start with a period as custom filter operators with the syntax `[.myfn[value]]`
* Directly invoke functions whose names contain a period as custom filter operators with the syntax `[my.fn[value]]` or `[.myfn[value]]`
!! How Functions Work

View File

@ -0,0 +1,32 @@
created: 20230608121519758
modified: 20230608123444591
tags: [[How to apply custom styles]]
title: Custom tag pill styles
type: text/vnd.tiddlywiki
! Attribute: data-tag-title
<<.from-version "5.2.0">> The attribute <<.attr data-tag-title>> was added to tag pills visible in the tiddler view template.
<<.from-version "5.3.0">> The attribute was added to every tag pill visible in the standard ~TiddlyWiki UI. Especially the edit template tag list, the tag-picker dropdown, the Right sidebar -> More -> Tags tab and the $:/TagManager
The <<.attr data-tag-title>> HTML attribute only contains the tag-title visible in the tag pill. It can be used to style the tag-pill.
If you want to style the whole tiddler have a look at: [[Custom styles by data-tiddler-title]]
!! Examples
If you use the following CSS in a new tiddler tagged: `$:/tags/Stylesheet` every tag that starts with a `#` will have a new border radius. So those tags stand out in contrast to the default tags.
''You have to define both CSS rules'', due to the existing UI structure to catch all tag-pills in the existing TW UI.
```
[data-tag-title^="#"] .tc-tag-label,
[data-tag-title^="#"].tc-tag-label {
border-radius: 3px;
}
```
!! More Possibilities
{{Attribute Selectors}}

View File

@ -1,22 +1,18 @@
created: 20160810122928198
modified: 20160810122934291
modified: 20230505104214168
tags: [[Editor toolbar]]
title: Using Excise
type: text/vnd.tiddlywiki
! Excise text
From the EditorToolbar you can export selected text to a new tiddler and insert a [[link|Linking in WikiText]] [[Transclusion]] or [[macro|Macros]] in its place. Click ''Excise text'' (<<.icon $:/core/images/excise>>), input name of the new tiddler, and choose excise method.
From the EditorToolbar you can export selected text to a new tiddler and insert a [[link|Linking in WikiText]], [[Transclusion]] or [[macro|Macros]] in its place. Click ''Excise text'' (<<.icon $:/core/images/excise>>), input name of the new tiddler, and choose excise method.
!! How to excise text
# Highlight the relevant piece of text
#Click ''Excise text'' (<<.icon $:/core/images/excise>>)
# Click ''Excise text'' (<<.icon $:/core/images/excise>>)
# Give the new tiddler a title.
# Chosse if the new tiddler will be tagged with the title of the current tiddler''*''.
# Choose replacing method. [[link|Linking in WikiText]] [[Transclusion]] or [[macro|Macros]].
# Choose if the new tiddler will be tagged with the title of the current tiddler (see note below).
# Choose replacing method: [[link|Linking in WikiText]], [[transclusion|Transclusion]], or [[macro|Macros]].
# Click the ''{{$:/language/Buttons/Excise/Caption/Excise}}'' button
''*NOTE:'' If you choose tic the option to `Tag new tiddler with the title of this tiddler`. The tag will be the'' draft title''. If you create a new tiddler (or clone an existing one), the draft title and the tag, will be `New Tiddler`. __You have to save the tiddler and re-edit it to get the new title as tag.__
<<.strong Note!>> If you choose the option to `Tag new tiddler with the title of this tiddler`, the new tiddler will be tagged with the name of the current tiddler before it has been edited. If you have changed the title of the current tiddler, save it first and edit it again to perform excision with this option.

View File

@ -1,5 +1,5 @@
created: 20140919155729620
modified: 20220819093733569
modified: 20230427125500432
tags: Macros [[Core Macros]]
title: Table-of-Contents Macros
type: text/vnd.tiddlywiki
@ -53,15 +53,21 @@ These two parameters are combined into a single [[filter expression|Filter Expre
<<.var toc-tabbed-internal-nav>> and <<.var toc-tabbed-external-nav>> take additional parameters:
;selectedTiddler
; selectedTiddler
: The title of the [[state tiddler|StateMechanism]] for noting the currently selected tiddler, defaulting to `$:/temp/toc/selectedTiddler`. It is recommended that this be a [[system tiddler|SystemTiddlers]]
;unselectedText
; unselectedText
: The text to display when no tiddler is selected in the tree
;missingText
; missingText
: The text to display if the selected tiddler doesn't exist
;template
; template
: Optionally, the title of a tiddler to use as a [[template|TemplateTiddlers]] for transcluding the selected tiddler into the right-hand panel
; exclude <<.from-version "5.3.0">>
: This optional parameter can be used to exclude tiddlers from the TOC list. It allows a [[Title List]] or a <<.olink subfilter>>. Eg: `exclude:"HelloThere [[Title with spaces]]"` or `exclude:"[has[excludeTOC]]"`. Where the former will exclude two tiddlers and the later would exclude every tiddler that has a field <<.field excludeTOC>> independent of its value.<br>''Be aware'' that eg: `[prefix[H]]` is a shortcut for `[all[tiddlers]prefix[H]]`, which can have a performance impact, if used carelessly. So use $:/AdvancedSearch -> ''Filters'' tab to test the <<.param exclude>> parameter
!! Custom Icons
<<.from-version "5.2.4">>

View File

@ -0,0 +1,21 @@
created: 20230505090333510
modified: 20230505090333510
tags: Macros [[Core Macros]]
title: translink Macro
type: text/vnd.tiddlywiki
caption: translink
The <<.def translink>> [[macro|Macros]] returns a frame with the title and [[transcluded|Transclusion]] text of a chosen tiddler. The title links to the transcluded tiddler.
If the chosen tiddler is missing, an appropriate message will be shown instead of the transcluded text.
This is the default macro used when [[excising|Using Excise]] text and replacing it with a macro.
!! Parameters
; title
: The title of the tiddler to be transcluded
; mode
: The mode of the [[transclude widget|TranscludeWidget]] used inside the macro, defaults to `block`
<<.macro-examples "translink">>

View File

@ -0,0 +1,9 @@
created: 20230505092952569
modified: 20230505092952569
tags: [[translink Macro]] [[Macro Examples]]
title: translink Macro (Examples)
type: text/vnd.tiddlywiki
<$macrocall $name=".example" n="1" eg="""<<translink "Philosophy of Tiddlers">>"""/>
<$macrocall $name=".example" n="2" eg="""<<translink "Philosophy of Tiddlers" inline>>"""/>
<$macrocall $name=".example" n="3" eg="""<<translink Foo>>"""/>

View File

@ -3,6 +3,7 @@ modified: 20220301180818011
tags: Messages
title: WidgetMessage: tm-close-all-windows
type: text/vnd.tiddlywiki
caption: tm-close-all-windows
<<.from-version 5.2.2>>
The `tm-close-all-windows` [[message|Messages]] closes all additional //browser// window that were opened with [[tm-open-window|WidgetMessage: tm-open-window]].

View File

@ -13,7 +13,7 @@ Excises the currently selected text into a new tiddler and replaces it with a li
|!Name |!Description |
|title |Title of the new tiddler the selected content is excised to|
|type |Type of the replacement to be inserted: Can be one of <<.value "transclude">>, <<.value "link">> or <<.value "macro">>|
|macro |In case //type=<<.value "macro">>//, specifies the name of the macro to be inserted. The title of the new tiddler is provided as the first parameter to the macro. Defaults to the ''translink'' macro|
|macro |In case //type=<<.value "macro">>//, specifies the name of the macro to be inserted. The title of the new tiddler is provided as the first parameter to the macro. Defaults to the [[translink macro|translink Macro]]|
|tagnew |If '<<.value "yes">>', will tag the new tiddler with the title of the tiddler currently being edited |
</div>

View File

@ -0,0 +1,12 @@
caption: tm-http-cancel-all-requests
created: 20230429161453032
modified: 20230429161453032
tags: Messages
title: WidgetMessage: tm-http-cancel-all-requests
type: text/vnd.tiddlywiki
The ''tm-http-cancel-all-requests'' message is used to cancel all outstanding HTTP requests initiated with [[WidgetMessage: tm-http-request]].
Note that the state tiddler $:/state/http-requests contains a number representing the number of outstanding HTTP requests in progress.
It does not take any parameters.

View File

@ -0,0 +1,115 @@
title: WidgetMessage: tm-http-request Example - Zotero
tags: $:/tags/Macro
\procedure select-zotero-group()
Specify the Zotero group ID to import
<$edit-text tiddler="$:/config/zotero-group" tag="input"/> or
<$select tiddler="$:/config/zotero-group">
<option value="4813312">com216</option>
<option value="4913310">pos252</option>
<option value="4747244">idt575</option>
</$select>
\end
\procedure zotero-save-item(item)
<$action-createtiddler
$basetitle={{{ =[[_zotero_import ]] =[<item>jsonget[key]] =[[ ]] =[<item>jsonget[title]] +[join[]] }}}
text={{{ [<item>jsonget[title]] }}}
tags="$:/tags/ZoteroImport"
>
<$action-setmultiplefields $tiddler=<<createTiddler-title>> $fields="[<item>jsonindexes[]addprefix[zotero-]]" $values="[<item>jsonindexes[]] :map[<item>jsonget<currentTiddler>else[.XXXXX.]]"/>
<$list filter="[<item>jsonindexes[creators]]" variable="creatorIndex">
<$action-setmultiplefields $tiddler=<<createTiddler-title>> $fields="[<item>jsonget[creators],<creatorIndex>,[creatorType]addprefix[zotero-]]" $values="[<item>jsonget[creators],<creatorIndex>,[lastName]] [<item>jsonget[creators],<creatorIndex>,[firstName]] +[join[, ]] :else[<item>jsonget[creators],<creatorIndex>,[name]] "/>
</$list>
</$action-createtiddler>
\end zotero-save-item
\procedure zotero-save-items(data)
<$list filter="[<data>jsonindexes[]] :map[<data>jsonextract<currentTiddler>,[data]]" variable="item">
<$macrocall $name="zotero-save-item" item=<<item>>/>
</$list>
\end zotero-save-items
\procedure zotero-get-items(start:"0",limit:"25")
\procedure completion()
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
<$action-log msg="In completion"/>
<$action-log/>
<!-- Success -->
<$list filter="[<status>compare:number:gteq[200]compare:number:lteq[299]]" variable="ignore">
<!-- Import these items -->
<$macrocall $name="zotero-save-items" data=<<data>>/>
<!-- Check if there are any more items to download -->
<$list filter="[<headers>jsonget[total-results]subtract<start>subtract<limit>compare:number:gt[0]]" variable="ignore">
<$macrocall $name="zotero-get-items" start={{{ [<start>add<limit>] }}} limit=<<limit>>/>
</$list>
</$list>
\end completion
\procedure progress()
\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
<$action-log message="In progress-actions"/>
\end progress
\procedure request-url()
\rules only transcludeinline transcludeblock filteredtranscludeinline filteredtranscludeblock
https://api.zotero.org/groups/{{$:/config/zotero-group}}/items/
\end request-url
<$wikify name="url" text=<<request-url>>>
<$action-sendmessage
$message="tm-http-request"
url=<<url>>
method="GET"
query-format="json"
query-sort="title"
query-start=<<start>>
query-limit=<<limit>>
header-accept="application/json"
bind-status="$:/temp/zotero/status"
bind-progress="$:/temp/zotero/progress"
oncompletion=<<completion>>
onprogress=<<progress>>
var-start=<<start>>
var-limit=<<limit>>
/>
</$wikify>
\end
\procedure zotero-actions()
<$macrocall $name="zotero-get-items" start="0" limit="50"/>
\end
<<select-zotero-group>>
<$button actions=<<zotero-actions>>>
Start import from Zotero group
</$button>
<$button message="tm-http-cancel-all-requests">
Cancel all HTTP requests
</$button> Outstanding requests: {{$:/state/http-requests}}
<$list filter="[tag[$:/tags/ZoteroImport]limit[1]]" variable="ignore">
!! Imported Tiddlers
<$button>
<$action-deletetiddler $filter="[tag[$:/tags/ZoteroImport]]"/>
Delete these tiddlers
</$button>
Export: <$macrocall $name="exportButton" exportFilter="[tag[$:/tags/ZoteroImport]]" lingoBase="$:/language/Buttons/ExportTiddlers/"/>
</$list>
<ol>
<$list filter="[tag[$:/tags/ZoteroImport]]">
<li>
<$link>
<$view field="title"/>
</$link>
</li>
</$list>
</ol>

View File

@ -0,0 +1,51 @@
caption: tm-http-request
created: 20230429161453032
modified: 20230429161453032
tags: Messages
title: WidgetMessage: tm-http-request
type: text/vnd.tiddlywiki
The ''tm-http-request'' message is used to make an HTTP request to a server.
It uses the following properties on the `event` object:
|!Name |!Description |
|param |Not used |
|paramObject |Hashmap of parameters (see below) |
The following parameters are used:
|!Name |!Description |
|method |HTTP method (eg "GET", "POST") |
|body |String data to be sent with the request |
|query-* |Query string parameters with string values |
|header-* |Headers with string values |
|password-header-* |Headers with values taken from the password store |
|password-query-* |Query string parameters with values taken from the password store |
|var-* |Variables to be passed to the completion and progress handlers (without the "var-" prefix) |
|bind-status |Title of tiddler to which the status of the request ("pending", "complete", "error") should be bound |
|bind-progress |Title of tiddler to which the progress of the request (0 to 100) should be bound |
|oncompletion |Action strings to be executed when the request completes |
|onprogress |Action strings to be executed when progress is reported |
The following variables are passed to the completion handler:
|!Name |!Description |
|status |HTTP result status code (see [[MDN|https://developer.mozilla.org/en-US/docs/Web/HTTP/Status]]) |
|statusText |HTTP result status text |
|error |Error string |
|data |Returned data |
|headers |Response headers as a JSON object |
The following variables are passed to the progress handler:
|!Name |!Description |
|lengthComputable |Whether the progress loaded and total figures are valid - "yes" or "no" |
|loaded |Number of bytes loaded so far |
|total |Total number bytes to be loaded |
Note that the state tiddler $:/state/http-requests contains a number representing the number of outstanding HTTP requests in progress.
!! Examples
* [[Zotero's|https://www.zotero.org/]] API for retrieving reference items: [[WidgetMessage: tm-http-request Example - Zotero]]

View File

@ -0,0 +1,2 @@
title: $:/config/zotero-group
text: 4813312

View File

@ -1,10 +1,10 @@
created: 20220917113154900
modified: 20230419103154329
modified: 20230518143557045
tags: Pragmas
title: Pragma: \parameters
type: text/vnd.tiddlywiki
<<.from-version "5.3.0">> The ''\parameters'' [[pragma|Pragmas]] is used within [[procedure|Procedure Definitions]] and [[widget|Widget Definitions]] definitions to declare the parameters that are expected, and their default values. It is a shortcut syntax for the ParametersWidget.
<<.from-version "5.3.0">> The ''\parameters'' [[pragma|Pragmas]] is used within [[procedure|Procedure Definitions]] and [[widget|Custom Widgets]] definitions to declare the parameters that are expected, and their default values. It is a shortcut syntax for the ParametersWidget.
```
\parameters (<name>[:<default-value>],<name>[:<default-value>]...)
@ -16,3 +16,11 @@ For example:
\parameters (firstname:"Joe",lastname:"Blogs")
```
To illustrate the use of ''\parameters'' pragma, see [[Core Icons]] which are parameterised. The first parameter `size` specified the size at which the icon should be rendered. For example see the text of [[$:/core/images/print-button]] tiddler. The first line defines the size parameter as `\parameters (size:"22pt")`
<<wikitext-example-without-html """{{$:/core/images/print-button|16px}}
<$transclude $tiddler="$:/core/images/print-button" size="32px"/>
""">>
In the above example, the first line shows a simple transclusion of [[$:/core/images/print-button]] icon with `size` parameter passed by position and is set to 16px. The second line is a transclusion of image with `size` parameter passed by name and is set to 32px.

View File

@ -1,5 +1,5 @@
created: 20221007132845007
modified: 20230419103154329
modified: 20230518152756112
tags: Pragmas
title: Pragma: \procedure
type: text/vnd.tiddlywiki
@ -52,4 +52,59 @@ Procedure definitions can be nested by specifying the name of the procedure in t
\end special-button
<<special-button>>
""">>
! Use of Parameters Inside Procedures
The parameters can be declared inside procedures. The parameters widget is necessary in a procedure if you want to use computed default values. For example:
<<wikitext-example-without-html
src:"""\procedure myproc()
<$parameters name={{$:/SiteTitle}} desc={{$:/SiteSubtitle}}>
This is <<name>> demonstrates <<desc>>.
</$parameters>
\end
<<myproc>>
""">>
!! Caution in Using Positional Parameters
Procedures are a shortcut syntax for the SetVariableWidget with an implicit ParametersWidget, so generally there is no reason to have multiple parameters widgets within a definition. In the below example when passing `x` to `myproc`, it will also be set to `a`:
<<wikitext-example-without-html
src:"""\procedure myproc(x:10)
\parameters (a:100, b:200)
x=<<x>>, a=<<a>>, b=<<b>>
\end
<<myproc 50>>
""">>
The reason for that result is clearer if we consider an equivalent with explicit parameters widgets.
<$macrocall $name=wikitext-example-without-html
src='<$let myprog="""
\parameters (x:10)
\parameters (a:100, b:200)
x=<<x>>, a=<<a>>, b=<<b>>
""">
<<myprog 50>>
</$let>'
/>
This is because those two parameters widgets are entirely independent. They are both processed as if the other parameter widget is not there.
<<.tip "The positional parameters are only required when using the parameterised transclusion shortcut syntax, and that in other cases it is generally clearer to use named parameters.">>
To prevent such situation of above example, pass parameters by name as below.
<<wikitext-example-without-html
src:"""\procedure myproc(x:10)
\parameters (a:100, b:200)
x=<<x>>, a=<<a>>, b=<<b>>
\end
<<myproc x:50>>
""">>

View File

@ -6,15 +6,15 @@ type: text/vnd.tiddlywiki
!! Introduction
This tiddler describes the different ways in which [[macros|Procedures]] can be defined.
This tiddler describes the different ways in which [[Procedures|Procedures]] can be defined.
!! Procedure Definition Pragma
Macros are created using the [[Pragma: \procedure]] at the start of a tiddler. The definitions are available in the rest of the tiddler that defines them, plus any tiddlers that it transcludes.
Procedures are created using the [[Pragma: \procedure]] at the start of a tiddler. The definitions are available in the rest of the tiddler that defines them, plus any tiddlers that it transcludes.
```
\define my-procedure(param)
This is the macro text (param=<<param>>)
This is the procedure text (param=<<param>>)
\end
```

View File

@ -0,0 +1,3 @@
title: $:/config/WikiParserRules/Inline/wikilink
enable

View File

@ -1,17 +1,17 @@
created: 20150117152607000
modified: 20220227210111054
modified: 20230617183916622
tags: $:/tags/Macro
title: $:/editions/tw5.com/operator-macros
\define .operator-examples(op,text:"Examples") <$link to="$op$ Operator (Examples)">$text$</$link>
\define .operator-example-tryit-actions() <$action-setfield $tiddler=<<.state>> text="show" filter=<<__eg__>>/>
\define .operator-example(n,eg,ie)
\procedure .operator-example-tryit-actions() <$action-setfield $tiddler=<<.state>> text="show" filter=<<eg>>/>
\procedure .operator-example(n,eg,ie)
<div class="doc-example">
<$list filter="[title<.state-prefix>addsuffix{!!title}addsuffix[/]addsuffix[$n$]]" variable=".state">
<$list filter="[title<.state-prefix>addsuffix{!!title}addsuffix[/]addsuffix<n>]" variable=".state">
<$reveal state=<<.state>> type="nomatch" text="show">
`$eg$`
<$macrocall $name=".if" cond="""$ie$""" then="""<dd>&rarr; $ie$</dd>"""/>
<code><$text text=<<eg>>/></code>
<$macrocall $name=".if" cond=<<ie>> then={{{[[<dd>&rarr; ]addsuffix<ie>addsuffix[</dd>]]}}}/>
<dl>
<dd><$button actions=<<.operator-example-tryit-actions>>>Try it</$button></dd>
</dl>
@ -21,7 +21,7 @@ title: $:/editions/tw5.com/operator-macros
<dl>
<dd>
<$button set=<<.state>> setTo="">Hide</$button>
<$reveal stateTitle=<<.state>> stateField="filter" type="nomatch" text=<<__eg__>>>
<$reveal stateTitle=<<.state>> stateField="filter" type="nomatch" text=<<eg>>>
<$button actions=<<.operator-example-tryit-actions>>>Reset</$button>
</$reveal>
</dd>

View File

@ -1,6 +1,6 @@
created: 20150203173506000
list-before: $:/core/ui/ViewTemplate/body
modified: 20220316121232243
modified: 20230602181119360
tags: $:/tags/ViewTemplate
title: $:/editions/tw5.com/operator-template
@ -72,10 +72,10 @@ title: $:/editions/tw5.com/operator-template
<!-- -->
</table>
[[Learn more about how to use Filters|Filters]]
<p>[[Learn more about how to use Filters|Filters]]</p>
<$list filter="[all[current]has[from-version]]" variable="listItem">
<$macrocall $name=".from-version" version={{!!from-version}}/>
<p><$macrocall $name=".from-version" version={{!!from-version}}/></p>
</$list>
</$list>
</$set>

View File

@ -17,14 +17,6 @@ It looks like this browser doesn't run JavaScript. You can use one of these stat
---
{{HelloThere}}
{{TiddlyWiki}}
{{Features}}
{{Community}}
{{HelpingTiddlyWiki}}
</$reveal>

View File

@ -150,5 +150,5 @@ Below is an example macro, procedure and function definition. All three forms o
*''tiddler titles'' - tiddlers are uniquely identified by their title. The namespace for tiddler titles and variable names are completely separate.
*''variables'' - \define, <<.wlink SetWidget>>, <<.wlink LetWidget>>, <<.wlink VarsWidget>>, \procedure, \widget, \function all create variables. If the same name is used, then later define will overwrite earlier defined
*''<<.op function>> filter operator parameter'' - only variables defined using \function can be called using the <<.olink function>> operator
*''filter operators'' - only the [[javascript defined filter operators|Filter Operators]] and variables defined using \function with name starting with a dot can be called
*''widgets'' - variables defined using \widget can be invoked using `<$widget/>` syntax ONLY if the name starts a dollar sign (to override existing javascript defined widgets) or double dollar sign (to define [[custom widgets|Custom Widgets]]). Without the dollar sign prefix, defining variables using \widget is no different than using \procedure.
*''filter operators'' - only the [[javascript defined filter operators|Filter Operators]] and variables defined using \function with name containing a dot can be called
*''widgets'' - variables defined using \widget can be invoked using `<$widget/>` syntax ONLY if the name starts a dollar sign. Without the dollar sign prefix, defining variables using \widget is no different than using \procedure.

Some files were not shown because too many files have changed in this diff Show More