1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-01-24 11:54:41 +00:00

Compare commits

..

76 Commits

Author SHA1 Message Date
Jeremy Ruston
6983564194 Merge branch 'master' into demo-alternate-store 2023-12-11 20:39:57 +00:00
Jeremy Ruston
4897248809 Fix indentation
Thanks @pmario
2023-11-10 21:29:40 +00:00
Jeremy Ruston
5d20e983b6 Refactor filter compilation into its own source file 2023-11-08 09:29:57 +00:00
Jeremy Ruston
6997c61bc1 Refactor filter compilation to allow SQL engine to optimise queries 2023-11-07 21:08:58 +00:00
Jeremy Ruston
d7f0c5cb6b Minor refactoring 2023-11-07 20:44:55 +00:00
Jeremy Ruston
02f3065e4f Revert attempt at optimising filter execution
At the moment the optimiser returns a list of chainable functions, it would be simpler to just return a single function
2023-11-07 10:34:56 +00:00
Jeremy Ruston
9493084f95 Merge branch 'master' into demo-alternate-store 2023-11-07 10:26:53 +00:00
Jeremy Ruston
8c1f7a6928 SQL Console: Add number of rows returned 2023-10-30 10:03:14 +00:00
Jeremy Ruston
d98265868e Remove all plugins to simplify benchmarking 2023-10-27 14:11:07 +01:00
Jeremy Ruston
e4af21a169 Don't use LEFT JOIN unless we have to 2023-10-27 14:10:30 +01:00
Jeremy Ruston
a58f119c50 Enable performance instrumentation 2023-10-27 10:31:58 +01:00
Jeremy Ruston
01e1882083 More indexes 2023-10-27 10:31:39 +01:00
Jeremy Ruston
e9d640b61b Fix sqlAllTitles wrongly including shadow tiddlers 2023-10-25 18:02:56 +01:00
Jeremy Ruston
3a4f5b8cfc Cache allTitles and allShadowTitles 2023-10-25 18:02:39 +01:00
Jeremy Ruston
dc94ed8be8 Refactor indexer implementation
Previously, we were using the existing addIndexer method to piggyback adding our own internal indexers.
2023-10-25 17:49:13 +01:00
Jeremy Ruston
12c6cb35a0 Add indexes for columns used in joins
Doesn't actually appear to make any appreciable difference
2023-10-25 11:38:08 +01:00
Jeremy Ruston
f49b9faab0 Move tags into their own tables
This roughly halves the bootup time of the prerelease wiki
2023-10-25 11:29:38 +01:00
Jeremy Ruston
d4dec0ca65 Use the empty string as special plugin name for ordinary tiddlers
Using NULL was working against the grain of SQL
2023-10-24 18:41:34 +01:00
Jeremy Ruston
863066d41f Merge branch 'master' into demo-alternate-store 2023-10-23 10:13:44 +01:00
Jeremy Ruston
fd3d8aef36 Merge branch 'master' into demo-alternate-store 2023-10-21 21:10:08 +01:00
Jeremy Ruston
c52014c66f Simplify the SQL schema
And introduce some very simple tests
2023-10-21 12:00:51 +01:00
Jeremy Ruston
1754be279f Merge branch 'master' into demo-alternate-store 2023-10-15 18:11:28 +01:00
Jeremy Ruston
25138ecd04 Merge branch 'master' into demo-alternate-store 2023-09-19 21:58:33 +01:00
Jeremy Ruston
66cba18e0f Merge branch 'master' into demo-alternate-store 2023-08-22 17:47:57 +01:00
Jeremy Ruston
e6309e95c9 Fix tag collation syntax 2023-07-29 11:48:35 +01:00
Jeremy Ruston
bb41ae0c9b Merge branch 'master' into demo-alternate-store 2023-07-28 11:42:40 +01:00
Jeremy Ruston
7eeaa20e7e Merge branch 'master' into demo-alternate-store 2023-07-22 11:06:06 +01:00
Jeremy Ruston
39d04517dd Experiment with optimising specific filters with direct SQL equivalents 2023-07-21 13:21:04 +01:00
Jeremy Ruston
b9245da91f Sort tag lookups according to TW semantics
Perhaps it would be better to keep the tags in the desired order in the database...
2023-07-20 19:30:02 +01:00
Jeremy Ruston
7fd2dd5a3e Wire up the tag indexer properly
Improves rendering performance by a factor of 4, but we're still 5 times slower than the plain JS store
2023-07-19 21:52:28 +01:00
Jeremy Ruston
2d3027faab Sql console styling 2023-07-19 19:52:44 +01:00
Jeremy Ruston
2cd2a057f8 Fix tag saving 2023-07-19 19:52:34 +01:00
Jeremy Ruston
09b0e2815c Style update for sql console 2023-07-19 19:19:57 +01:00
Jeremy Ruston
b4fe89657b Styling for SQL console 2023-07-19 18:08:35 +01:00
Jeremy Ruston
88c8c2c9f3 SQL console - process query on enter key 2023-07-19 09:04:38 +01:00
Jeremy Ruston
979a1f746d Introduce sql console
Very bare bones, but functional. Results are displayed in JSON for the moment. The console should also perhaps be hidden by default, with a keyboard shortcut, and a setting in local storage.
2023-07-18 21:54:01 +01:00
Jeremy Ruston
83e7d32c8e Merge branch 'master' into demo-alternate-store 2023-07-18 19:33:31 +01:00
Jeremy Ruston
cc2cd20e32 Add tags tables and tag indexer and make custom collator be optional
This commit (a) is very much work in progress (b) improves performance significantly and (c) is actually broken

Right now, theme stylesheets don't get loaded for some reason.

I plan to spend some time improving debuggability by adding a SQL console
2023-07-18 19:33:21 +01:00
Jeremy Ruston
709669b714 Merge branch 'master' into demo-alternate-store 2023-07-14 12:42:14 +01:00
Jeremy Ruston
f48bddb167 Merge branch 'master' into demo-alternate-store 2023-07-13 19:28:02 +01:00
Jeremy Ruston
e3255a4d2a Merge branch 'master' into demo-alternate-store 2023-07-13 17:57:42 +01:00
Jeremy Ruston
b557deac79 Update comment 2023-07-07 10:15:40 +01:00
Jeremy Ruston
64ffa52da9 Write tiddlers with string fields
Otherwise date fields will get saved as JS date objects, which are not properly defined in JSON.
2023-07-07 08:22:36 +01:00
Jeremy Ruston
d2e21ddd3c Add a custom collator that matches JS ordering 2023-07-07 08:20:57 +01:00
jeremy@jermolene.com
f3bc32a2e9 Merge branch 'master' into demo-alternate-store 2023-07-06 11:55:38 +01:00
jeremy@jermolene.com
21ef2d7646 Make the tests work in the browser 2023-07-06 11:55:32 +01:00
jeremy@jermolene.com
9e190a46db Use a temporary database so that multiple wiki stores can coexist 2023-07-06 11:54:03 +01:00
jeremy@jermolene.com
2d229e2159 Add logging utility 2023-07-06 11:53:41 +01:00
Jeremy Ruston
71c02e57c0 Merge branch 'master' into demo-alternate-store 2023-07-01 14:38:47 +01:00
jeremy@jermolene.com
687b1df0c3 Merge branch 'master' into demo-alternate-store 2023-06-30 10:50:38 +01:00
jeremy@jermolene.com
1f4be3e92f I experimented with custom collations to match JS sort order, but 5x slower 2023-06-30 10:46:27 +01:00
Jeremy Ruston
b29af447e5 Fix typo 2023-06-29 22:49:08 +01:00
jeremy@jermolene.com
6ded5e68bf Merge branch 'master' into demo-alternate-store 2023-06-29 15:49:04 +01:00
Jeremy Ruston
87213f2c65 Refactpr sql-wiki-store into two files 2023-06-29 07:55:59 +01:00
Jeremy Ruston
12a19bb9cf Remove instrumentation
Makes the code complex and is hard to keep up to date
2023-06-28 17:27:01 +01:00
jeremy@jermolene.com
2099c4f9a8 Turn on performance instrumentation for testing 2023-06-28 15:04:44 +01:00
jeremy@jermolene.com
8399538814 Merge branch 'master' into demo-alternate-store 2023-06-28 11:45:42 +01:00
jeremy@jermolene.com
ede5f1e9ad Prepare the save tiddler query 2023-06-28 11:43:57 +01:00
jeremy@jermolene.com
9cb8721343 Use sql functions for processing shadow tiddlers 2023-06-27 19:10:42 +01:00
jeremy@jermolene.com
7e6072611e Wire the sql functions into the wiki object
At this point, the result is incredibly, painfully slow – the wiki will probably fail to load entirely on mobile
2023-06-25 21:05:28 +01:00
jeremy@jermolene.com
9ac21f167f Simplify the plain JS store implementation
Removing indexers and title cache
2023-06-25 17:03:28 +01:00
jeremy@jermolene.com
9427cf7ac6 Additional method to retrieve all titles 2023-06-23 17:33:35 +01:00
jeremy@jermolene.com
8690936805 Cleanup and clarify 2023-06-23 16:58:46 +01:00
jeremy@jermolene.com
831fb3996d Tiddler sql function tests should show custom field 2023-06-23 14:52:14 +01:00
jeremy@jermolene.com
c43bc8f92a Start prototyping some tiddler operations in sql 2023-06-23 14:47:35 +01:00
jeremy@jermolene.com
6f24f33a3d Include sqlite3 in the empty edition
Makes for an empty size of 4.1MB
2023-06-23 12:42:32 +01:00
jeremy@jermolene.com
449e2274e2 Test code to exercise the database 2023-06-23 12:40:59 +01:00
jeremy@jermolene.com
146a22b894 Make rawmarkup code dynamically load dependencies
empty.html with the plugin is now 4.1MB
2023-06-22 15:24:39 +01:00
jeremy@jermolene.com
0546a14201 Restructure the sqlite3 store as a separate plugin 2023-06-22 15:04:55 +01:00
jeremy@jermolene.com
544e079033 Proof of concept of instantiating sqlite3 without needing external dependencies
We get a reference to sqlite3 but we're not yet doing anything with it

Also note that this approach leads to duplication - there will be two copies of sqlite3.js and sqlite3.wasm in each generated HTML file. The plan is to dynamically retrieve those tiddlers from the store area rather than baking them into the raw markup area
2023-06-22 14:27:37 +01:00
jeremy@jermolene.com
1d0b9280d8 Incorporate @joshuafontany's plain JS wiki implementation
And make the demo storage areas switchable

@joshuafontany's implementation was in #7521
2023-06-22 09:36:25 +01:00
jeremy@jermolene.com
3561318515 Merge branch 'master' into demo-alternate-store 2023-06-22 09:17:55 +01:00
jeremy@jermolene.com
b6bc197f76 Remove unneeded override
See https://github.com/Jermolene/TiddlyWiki5/pull/7329/files#r1126709318
2023-05-10 22:27:40 +01:00
jeremy@jermolene.com
62337101c3 Merge branch 'master' into demo-alternate-store 2023-05-10 22:23:35 +01:00
jeremy@jermolene.com
7fdd8a5164 Merge branch 'master' into demo-alternate-store 2023-05-10 22:11:55 +01:00
jeremy@jermolene.com
fdec12f43b Initial commit
This is the very barebones beginnings of a demo implementation of an alternate tiddler store. It is not functional. If using the Vercel builds, open developer tools in the browser to see it failing due to the absence of basic wiki methods.

The plan is to build it up into the smallest possible plain JS wiki store implementation, sharing as much implementation as possible with the existing core implementation with as little code duplication as possible. It could then serve as the basis for future experiments with wiki stores based on SQLite (@linonetwo), or a custom append only database (@yaisog).
2023-03-04 21:08:00 +00:00
113 changed files with 13805 additions and 1018 deletions

View File

@@ -5,7 +5,7 @@
# Default to the current version number for building the plugin library
if [ -z "$TW5_BUILD_VERSION" ]; then
TW5_BUILD_VERSION=v5.3.3
TW5_BUILD_VERSION=v5.3.2
fi
echo "Using TW5_BUILD_VERSION as [$TW5_BUILD_VERSION]"

View File

@@ -1096,6 +1096,39 @@ $tw.Tiddler.prototype.isEqual = function(tiddler,excludeFields) {
return differences.length === 0;
};
$tw.Tiddler.prototype.getFieldString = function(field,defaultValue) {
var value = this.fields[field];
// Check for a missing field
if(value === undefined || value === null) {
return defaultValue || "";
}
// Stringify the field with the associated tiddler field module (if any)
var fieldModule = $tw.Tiddler.fieldModules[field];
if(fieldModule && fieldModule.stringify) {
return fieldModule.stringify.call(this,value);
} else {
return value.toString();
}
};
/*
Get all the fields as a hashmap of strings. Options:
exclude: an array of field names to exclude
*/
$tw.Tiddler.prototype.getFieldStrings = function(options) {
options = options || {};
var exclude = options.exclude || [];
var fields = {};
for(var field in this.fields) {
if($tw.utils.hop(this.fields,field)) {
if(exclude.indexOf(field) === -1) {
fields[field] = this.getFieldString(field);
}
}
}
return fields;
};
/*
Register and install the built in tiddler field modules
*/
@@ -1132,7 +1165,7 @@ Wiki constructor. State is stored in private members that only a small number of
options include:
enableIndexers - Array of indexer names to enable, or null to use all available indexers
*/
$tw.Wiki = function(options) {
$tw.Wiki = $tw.Wiki || function(options) {
options = options || {};
var self = this,
tiddlers = Object.create(null), // Hashmap of tiddlers
@@ -1494,7 +1527,7 @@ $tw.Wiki.prototype.clearGlobalCache =
$tw.Wiki.prototype.enqueueTiddlerEvent = function() {};
// Add an array of tiddlers
$tw.Wiki.prototype.addTiddlers = function(tiddlers) {
$tw.Wiki.prototype.addTiddlers = $tw.Wiki.prototype.addTiddlers || function(tiddlers) {
for(var t=0; t<tiddlers.length; t++) {
this.addTiddler(tiddlers[t]);
}
@@ -1503,7 +1536,7 @@ $tw.Wiki.prototype.addTiddlers = function(tiddlers) {
/*
Define all modules stored in ordinary tiddlers
*/
$tw.Wiki.prototype.defineTiddlerModules = function() {
$tw.Wiki.prototype.defineTiddlerModules = $tw.Wiki.prototype.defineTiddlerModules || function() {
this.each(function(tiddler,title) {
if(tiddler.hasField("module-type")) {
switch (tiddler.fields.type) {
@@ -1527,7 +1560,7 @@ $tw.Wiki.prototype.defineTiddlerModules = function() {
/*
Register all the module tiddlers that have a module type
*/
$tw.Wiki.prototype.defineShadowModules = function() {
$tw.Wiki.prototype.defineShadowModules = $tw.Wiki.prototype.defineShadowModules || function() {
var self = this;
this.eachShadow(function(tiddler,title) {
// Don't define the module if it is overidden by an ordinary tiddler
@@ -1541,7 +1574,7 @@ $tw.Wiki.prototype.defineShadowModules = function() {
/*
Enable safe mode by deleting any tiddlers that override a shadow tiddler
*/
$tw.Wiki.prototype.processSafeMode = function() {
$tw.Wiki.prototype.processSafeMode = $tw.Wiki.prototype.processSafeMode || function() {
var self = this,
overrides = [];
// Find the overriding tiddlers
@@ -1572,7 +1605,7 @@ $tw.Wiki.prototype.processSafeMode = function() {
/*
Extracts tiddlers from a typed block of text, specifying default field values
*/
$tw.Wiki.prototype.deserializeTiddlers = function(type,text,srcFields,options) {
$tw.Wiki.prototype.deserializeTiddlers = $tw.Wiki.prototype.deserializeTiddlers || function(type,text,srcFields,options) {
srcFields = srcFields || Object.create(null);
options = options || {};
var deserializer = $tw.Wiki.tiddlerDeserializerModules[options.deserializer],
@@ -2438,6 +2471,7 @@ $tw.boot.initStartup = function(options) {
$tw.utils.registerFileType("image/svg+xml","utf8",".svg",{flags:["image"]});
$tw.utils.registerFileType("image/vnd.microsoft.icon","base64",".ico",{flags:["image"]});
$tw.utils.registerFileType("image/x-icon","base64",".ico",{flags:["image"]});
$tw.utils.registerFileType("application/wasm","base64",".wasm");
$tw.utils.registerFileType("application/font-woff","base64",".woff");
$tw.utils.registerFileType("application/x-font-ttf","base64",".woff");
$tw.utils.registerFileType("application/font-woff2","base64",".woff2");

View File

@@ -4,7 +4,7 @@ type: text/plain
TiddlyWiki created by Jeremy Ruston, (jeremy [at] jermolene [dot] com)
Copyright (c) 2004-2007, Jeremy Ruston
Copyright (c) 2007-2024, UnaMesa Association
Copyright (c) 2007-2023, UnaMesa Association
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@@ -4,7 +4,6 @@ _canonical_uri: The full URI of an external image tiddler
author: Name of the author of a plugin
bag: The name of the bag from which a tiddler came
caption: The text to be displayed on a tab or button
class: The CSS class applied to a tiddler when rendering it - see [[Custom styles by user-class]]. Also used for [[Modals]]
code-body: The view template will display the tiddler as code if set to ''yes''
color: The CSS color value associated with a tiddler
component: The name of the component responsible for an [[alert tiddler|AlertMechanism]]

View File

@@ -171,7 +171,7 @@ exports.parseFilter = function(filterString) {
}
if(match[3]) {
operation.suffixes = [];
$tw.utils.each(match[3].split(":"),function(subsuffix) {
$tw.utils.each(match[3].split(":"),function(subsuffix) {
operation.suffixes.push([]);
$tw.utils.each(subsuffix.split(","),function(entry) {
entry = $tw.utils.trim(entry);
@@ -179,7 +179,7 @@ exports.parseFilter = function(filterString) {
operation.suffixes[operation.suffixes.length -1].push(entry);
}
});
});
});
}
}
if(match[4]) { // Opening square bracket
@@ -225,13 +225,17 @@ source: an iterator function for the source tiddlers, called source(iterator), w
widget: an optional widget node for retrieving the current tiddler etc.
*/
exports.compileFilter = function(filterString) {
var self = this;
// Set up the filter function cache
if(!this.filterCache) {
this.filterCache = Object.create(null);
this.filterCacheCount = 0;
}
// Use the cached version of this filter function if it exists
if(this.filterCache[filterString] !== undefined) {
return this.filterCache[filterString];
}
// Parse the filter string
var filterParseTree;
try {
filterParseTree = this.parseFilter(filterString);
@@ -241,10 +245,42 @@ exports.compileFilter = function(filterString) {
return [$tw.language.getString("Error/Filter") + ": " + e];
};
}
// Get the filter function
var fnFilter = this.optimiseFilter && this.optimiseFilter(filterString,filterParseTree);
if(!fnFilter) {
fnFilter = this.compileFilterToJavaScript(filterParseTree);
}
// Add recursion detection
var fnGuardedFilter = function guardedFilterFunction(source,widget) {
var results;
self.filterRecursionCount = (self.filterRecursionCount || 0) + 1;
if(self.filterRecursionCount < MAX_FILTER_DEPTH) {
results = fnFilter(source,widget);
} else {
results = ["/**-- Excessive filter recursion --**/"];
}
self.filterRecursionCount = self.filterRecursionCount - 1;
return results;
}
// Add performance measurement
var fnMeasured = $tw.perf.measure("filter: " + filterString,fnGuardedFilter);
// Cache the final filter function
if(this.filterCacheCount >= 2000) {
// To prevent memory leak, we maintain an upper limit for cache size.
// Reset if exceeded. This should give us 95% of the benefit
// that no cache limit would give us.
this.filterCache = Object.create(null);
this.filterCacheCount = 0;
}
this.filterCache[filterString] = fnMeasured;
this.filterCacheCount++;
return fnMeasured;
};
exports.compileFilterToJavaScript = function(filterParseTree) {
var operationFunctions = [];
// Get the hashmap of filter operator functions
var filterOperators = this.getFilterOperators();
// Assemble array of functions, one for each operation
var operationFunctions = [];
// Step through the operations
var self = this;
$tw.utils.each(filterParseTree,function(operation) {
@@ -334,8 +370,8 @@ exports.compileFilter = function(filterString) {
}
})());
});
// Return a function that applies the operations to a source iterator of tiddler titles
var fnMeasured = $tw.perf.measure("filter: " + filterString,function filterFunction(source,widget) {
// Make the filter function
return function filterFunction(source,widget) {
if(!source) {
source = self.each;
} else if(typeof source === "object") { // Array or hashmap
@@ -345,27 +381,12 @@ exports.compileFilter = function(filterString) {
widget = $tw.rootWidget;
}
var results = new $tw.utils.LinkedList();
self.filterRecursionCount = (self.filterRecursionCount || 0) + 1;
if(self.filterRecursionCount < MAX_FILTER_DEPTH) {
$tw.utils.each(operationFunctions,function(operationFunction) {
operationFunction(results,source,widget);
});
} else {
results.push("/**-- Excessive filter recursion --**/");
}
self.filterRecursionCount = self.filterRecursionCount - 1;
$tw.utils.each(operationFunctions,function(operationFunction) {
operationFunction(results,source,widget);
});
return results.toArray();
});
if(this.filterCacheCount >= 2000) {
// To prevent memory leak, we maintain an upper limit for cache size.
// Reset if exceeded. This should give us 95% of the benefit
// that no cache limit would give us.
this.filterCache = Object.create(null);
this.filterCacheCount = 0;
}
this.filterCache[filterString] = fnMeasured;
this.filterCacheCount++;
return fnMeasured;
};
};
})();

View File

@@ -49,11 +49,11 @@ exports.parse = function() {
if(this.match[3]) {
params = $tw.utils.parseParameterDefinition(this.match[4]);
}
// Is the remainder of the line blank after the parameter close paren?
// Is this a multiline definition?
var reEnd;
if(this.match[5]) {
// If so, it is a multiline definition and the end of the body is marked with \end
reEnd = new RegExp("((:?^|\\r?\\n)[^\\S\\n\\r]*\\\\end[^\\S\\n\\r]*(?:" + $tw.utils.escapeRegExp(this.match[2]) + ")?(?:$|\\r?\\n))","mg");
// If so, the end of the body is marked with \end
reEnd = new RegExp("(\\r?\\n[^\\S\\n\\r]*\\\\end[^\\S\\n\\r]*(?:" + $tw.utils.escapeRegExp(this.match[2]) + ")?(?:$|\\r?\\n))","mg");
} else {
// Otherwise, the end of the definition is marked by the end of the line
reEnd = /($|\r?\n)/mg;

View File

@@ -54,11 +54,11 @@ exports.parse = function() {
paramMatch = reParam.exec(paramString);
}
}
// Is the remainder of the \define line blank after the parameter close paren?
// Is this a multiline definition?
var reEnd;
if(this.match[3]) {
// If so, it is a multiline definition and the end of the body is marked with \end
reEnd = new RegExp("((?:^|\\r?\\n)[^\\S\\n\\r]*\\\\end[^\\S\\n\\r]*(?:" + $tw.utils.escapeRegExp(this.match[1]) + ")?(?:$|\\r?\\n))","mg");
// If so, the end of the body is marked with \end
reEnd = new RegExp("(\\r?\\n[^\\S\\n\\r]*\\\\end[^\\S\\n\\r]*(?:" + $tw.utils.escapeRegExp(this.match[1]) + ")?(?:$|\\r?\\n))","mg");
} else {
// Otherwise, the end of the definition is marked by the end of the line
reEnd = /($|\r?\n)/mg;

View File

@@ -216,8 +216,6 @@ WikiParser.prototype.parsePragmas = function() {
subTree[0].children = [];
currentTreeBranch = subTree[0].children;
}
// Skip whitespace after the pragma
this.skipWhitespace();
}
return currentTreeBranch;
};

View File

@@ -635,7 +635,7 @@ SyncFromServerTask.prototype.run = function(callback) {
callback(null);
};
if(this.syncer.syncadaptor.getUpdatedTiddlers) {
this.syncer.syncadaptor.getUpdatedTiddlers(self.syncer,function(err,updates) {
this.syncer.syncadaptor.getUpdatedTiddlers(self,function(err,updates) {
if(err) {
self.syncer.displayError($tw.language.getString("Error/RetrievingSkinny"),err);
return callback(err);

View File

@@ -24,21 +24,6 @@ exports.isDraft = function() {
return this.hasField("draft.of");
};
exports.getFieldString = function(field,defaultValue) {
var value = this.fields[field];
// Check for a missing field
if(value === undefined || value === null) {
return defaultValue || "";
}
// Stringify the field with the associated tiddler field module (if any)
var fieldModule = $tw.Tiddler.fieldModules[field];
if(fieldModule && fieldModule.stringify) {
return fieldModule.stringify.call(this,value);
} else {
return value.toString();
}
};
/*
Get the value of a field as a list
*/
@@ -51,24 +36,6 @@ exports.getFieldList = function(field) {
return $tw.utils.parseStringArray(value);
};
/*
Get all the fields as a hashmap of strings. Options:
exclude: an array of field names to exclude
*/
exports.getFieldStrings = function(options) {
options = options || {};
var exclude = options.exclude || [];
var fields = {};
for(var field in this.fields) {
if($tw.utils.hop(this.fields,field)) {
if(exclude.indexOf(field) === -1) {
fields[field] = this.getFieldString(field);
}
}
}
return fields;
};
/*
Get all the fields as a name:value block. Options:
exclude: an array of field names to exclude

View File

@@ -90,7 +90,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
EditWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
// Refresh if an attribute has changed, or the type associated with the target tiddler has changed
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tabindex || changedAttributes.cancelPopups || changedAttributes.inputActions || changedAttributes.refreshTitle || changedAttributes.autocomplete || (this.getEditorType() !== this.editorType)) {
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tabindex || changedAttributes.cancelPopups || changedAttributes.inputActions || changedAttributes.refreshTitle || changedAttributes.autocomplete || (changedTiddlers[this.editTitle] && this.getEditorType() !== this.editorType)) {
this.refreshSelf();
return true;
} else {

View File

@@ -217,7 +217,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
*/
LinkWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if($tw.utils.count(changedAttributes) > 0 || changedTiddlers[this.to]) {
if($tw.utils.count(changedAttributes) > 0) {
this.refreshSelf();
return true;
}

View File

@@ -109,7 +109,6 @@ ListWidget.prototype.findExplicitTemplates = function() {
this.explicitJoinTemplate = null;
this.hasTemplateInBody = false;
var searchChildren = function(childNodes) {
var foundInlineTemplate = false;
$tw.utils.each(childNodes,function(node) {
if(node.type === "list-template") {
self.explicitListTemplate = node.children;
@@ -119,14 +118,12 @@ ListWidget.prototype.findExplicitTemplates = function() {
self.explicitJoinTemplate = node.children;
} else if(node.type === "element" && node.tag === "p") {
searchChildren(node.children);
foundInlineTemplate = true;
} else {
foundInlineTemplate = true;
self.hasTemplateInBody = true;
}
});
return foundInlineTemplate;
};
this.hasTemplateInBody = searchChildren(this.parseTreeNode.children);
searchChildren(this.parseTreeNode.children);
}
ListWidget.prototype.getTiddlerList = function() {

View File

@@ -42,24 +42,31 @@ Compute the internal state of the widget
*/
ParametersWidget.prototype.execute = function() {
var self = this;
this.parametersDepth = Math.max(parseInt(this.getAttribute("$depth","1"),10) || 1,1);
// Find the parent transclusions
var pointer = this.getContainingTransclude();
var pointer = this.parentWidget,
depth = this.parametersDepth;
while(pointer) {
if(pointer instanceof TranscludeWidget) {
depth--;
if(depth <= 0) {
break;
}
}
pointer = pointer.parentWidget;
}
// Process each parameter
if(pointer) {
// It's important to remember this, because when we refresh, we'll need to make sure this widget is starting at the same index.
this.initialParameterIndex = pointer.parameterIndex;
if(pointer instanceof TranscludeWidget) {
// Get the value for each defined parameter
$tw.utils.each($tw.utils.getOrderedAttributesFromParseTreeNode(self.parseTreeNode),function(attr) {
$tw.utils.each($tw.utils.getOrderedAttributesFromParseTreeNode(self.parseTreeNode),function(attr,index) {
var name = attr.name;
// If the attribute name starts with $$ then reduce to a single dollar
if(name.substr(0,2) === "$$") {
name = name.substr(1);
}
var value = pointer.getTransclusionParameter(name,self.getAttribute(attr.name,""));
var value = pointer.getTransclusionParameter(name,index,self.getAttribute(attr.name,""));
self.setVariable(name,value);
});
// We remember where we left the unnamed parameter index.
this.finalParameterIndex = pointer.parameterIndex;
// Assign any metaparameters
$tw.utils.each(pointer.getTransclusionMetaParameters(),function(getValue,name) {
var variableName = self.getAttribute("$" + name);
@@ -77,29 +84,13 @@ Refresh the widget by ensuring our attributes are up to date
*/
ParametersWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
var pointer = this.getContainingTransclude();
var currentParameterIndex;
if(pointer) {
currentParameterIndex = pointer.parameterIndex;
}
if(Object.keys(changedAttributes).length || currentParameterIndex !== this.initialParameterIndex) {
if(Object.keys(changedAttributes).length) {
this.refreshSelf();
return true;
} else if(pointer) {
// We set the index for unnamed parameters for our $transclude widget in case any later $parameters show up. They need to be able to confirm their indices are starting in the right place, because if not, they need to refresh.
pointer.parameterIndex = this.finalParameterIndex;
}
return this.refreshChildren(changedTiddlers);
};
ParametersWidget.prototype.getContainingTransclude = function() {
var pointer = this.parentWidget;
while(pointer && !(pointer instanceof TranscludeWidget)) {
pointer = pointer.parentWidget;
}
return pointer;
};
exports.parameters = ParametersWidget;
})();

View File

@@ -43,7 +43,7 @@ SelectWidget.prototype.render = function(parent,nextSibling) {
//Create element
var domNode = this.document.createElement("select");
if(this.selectClass) {
domNode.className = this.selectClass;
domNode.classname = this.selectClass;
}
// Assign data- attributes
this.assignAttributes(domNode,{
@@ -62,8 +62,8 @@ SelectWidget.prototype.render = function(parent,nextSibling) {
if(this.selectTooltip) {
domNode.setAttribute("title",this.selectTooltip);
}
this.renderChildren(domNode,nextSibling);
this.parentDomNode.insertBefore(domNode,nextSibling);
this.renderChildren(domNode,null);
this.domNodes.push(domNode);
this.setSelectValue();
if(this.selectFocus == "yes") {

View File

@@ -358,26 +358,14 @@ TranscludeWidget.prototype.getOrderedTransclusionParameters = function() {
};
/*
The parameter index indicates is used by internal $parameter widgets to sequentially assign unnamed parameters.
Fetch the value of a parameter
*/
Object.defineProperty(TranscludeWidget.prototype, 'parameterIndex', {
get: function() { return this.claimedIndices || 0; },
set: function(value) { this.claimedIndices = value; }
});
/*
Fetch the value of a parameter given either its name or index
*/
TranscludeWidget.prototype.getTransclusionParameter = function(name,defaultValue) {
TranscludeWidget.prototype.getTransclusionParameter = function(name,index,defaultValue) {
if(name in this.stringParametersByName) {
return this.stringParametersByName[name];
} else {
// Let's see if this name was already assigned an index
var index = this.parameterIndex;
var name = "" + index;
if(name in this.stringParametersByName) {
// This parameter now corresponds to this index. No other parameters may correspond to it.
this.claimedIndices = index + 1;
return this.stringParametersByName[name];
}
}
@@ -460,8 +448,6 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
*/
TranscludeWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
// Reset the parameter index so that internal $parameter widgets can double-check their unnamed parameter indices.
this.parameterIndex = 0;
if(($tw.utils.count(changedAttributes) > 0) || (this.transcludeVariableIsFunction && this.functionNeedsRefresh()) || (!this.transcludeVariable && changedTiddlers[this.transcludeTitle] && this.parserNeedsRefresh())) {
this.refreshSelf();
return true;

View File

@@ -153,7 +153,7 @@ Widget.prototype.getVariableInfo = function(name,options) {
} else if(variable.isFunctionDefinition) {
// Function evaluations
params = self.resolveVariableParameters(variable.params,actualParams);
var variables = options.variables || Object.create(null);
var variables = Object.create(null);
// Apply default parameter values
$tw.utils.each(variable.params,function(param,index) {
if(param["default"]) {

View File

@@ -1,3 +1,3 @@
title: $:/core/templates/html-json-skinny-tiddler
<$text text=<<join>>/><$jsontiddler tiddler=<<currentTiddler>> exclude="text" escapeUnsafeScriptChars="yes"/>
<$jsontiddler tiddler=<<currentTiddler>> exclude="text" escapeUnsafeScriptChars="yes"/>

View File

@@ -9,7 +9,9 @@ title: $:/core/templates/store.area.template.html
<$let newline={{{ [charcode[10]] }}} join=`,$(newline)$`>
<$text text=<<newline>>/>
<$list filter=<<saveTiddlerFilter>> join=<<join>> template="$:/core/templates/html-json-tiddler"/>
<$list filter="[subfilter<skinnySaveTiddlerFilter>]" template="$:/core/templates/html-json-skinny-tiddler"/>
<$vars numTiddlers={{{ [subfilter<saveTiddlerFilter>count[]] }}}>
<$list filter={{{ [<skinnySaveTiddlerFilter>] }}} join=<<join>> template="$:/core/templates/html-json-skinny-tiddler"/>
</$vars>
<$text text=<<newline>>/>
</$let>
`]</script>`
@@ -20,8 +22,8 @@ title: $:/core/templates/store.area.template.html
<!-- Old-style DIV/PRE-based store area -->
<$reveal type="nomatch" state="$:/isEncrypted" text="yes">
`<div id="storeArea" style="display:none;">`
<$list filter={{{ [<saveTiddlerFilter>] }}} template="$:/core/templates/html-div-tiddler"/>
<$list filter="[subfilter<skinnySaveTiddlerFilter>]" template="$:/core/templates/html-div-skinny-tiddler"/>
<$list filter=<<saveTiddlerFilter>> template="$:/core/templates/html-div-tiddler"/>
<$list filter={{{ [<skinnySaveTiddlerFilter>] }}} template="$:/core/templates/html-div-skinny-tiddler"/>
`</div>`
</$reveal>
</$list>

View File

@@ -1,5 +1,9 @@
title: $:/core/ui/EditTemplate/body/default
\function edit-preview-state()
[{$:/config/ShowEditPreview/PerTiddler}!match[yes]then[$:/state/showeditpreview]] :else[<qualify "$:/state/showeditpreview">] +[get[text]] :else[[no]]
\end
\define config-visibility-title()
$:/config/EditorToolbarButtons/Visibility/$(currentTiddler)$
\end
@@ -10,16 +14,15 @@ $:/config/EditorToolbarButtons/Visibility/$(currentTiddler)$
\whitespace trim
<$let
editPreviewStateTiddler={{{ [{$:/config/ShowEditPreview/PerTiddler}!match[yes]then[$:/state/showeditpreview]] :else[<qualify "$:/state/showeditpreview">] }}}
importTitle=<<qualify $:/ImportImage>>
importState=<<qualify $:/state/ImportImage>> >
<$dropzone importTitle=<<importTitle>> autoOpenOnImport="no" contentTypesFilter={{$:/config/Editor/ImportContentTypesFilter}} class="tc-dropzone-editor" enable={{{ [{$:/config/DragAndDrop/Enable}match[no]] :else[subfilter{$:/config/Editor/EnableImportFilter}then[yes]else[no]] }}} filesOnly="yes" actions=<<importFileActions>> >
<div>
<div class={{{ [<editPreviewStateTiddler>get[text]match[yes]then[tc-tiddler-preview]else[tc-tiddler-preview-hidden]] [[tc-tiddler-editor]] +[join[ ]] }}}>
<div class={{{ [function[edit-preview-state]match[yes]then[tc-tiddler-preview]else[tc-tiddler-preview-hidden]] [[tc-tiddler-editor]] +[join[ ]] }}}>
<$transclude tiddler="$:/core/ui/EditTemplate/body/editor" mode="inline"/>
<$list filter="[<editPreviewStateTiddler>get[text]match[yes]]" variable="ignore">
<$list filter="[function[edit-preview-state]match[yes]]" variable="ignore">
<div class="tc-tiddler-preview-preview" data-tiddler-title={{!!draft.title}} data-tags={{!!tags}}>

View File

@@ -9,8 +9,17 @@ button-classes: tc-text-editor-toolbar-item-start-group
shortcuts: ((preview))
\whitespace trim
<span>
<$transclude $tiddler={{{ [<editPreviewStateTiddler>get[text]match[yes]then[$:/core/images/preview-open]else[$:/core/images/preview-closed]] }}} />
</span>
<$action-setfield $tiddler=<<editPreviewStateTiddler>> $value={{{ [<editPreviewStateTiddler>get[text]toggle[yes],[no]] }}} />
<$action-sendmessage $message="tm-edit-text-operation" $param="focus-editor"/>
<$let
edit-preview-state={{{ [{$:/config/ShowEditPreview/PerTiddler}!match[yes]then[$:/state/showeditpreview]] :else[<qualify "$:/state/showeditpreview">] }}}
>
<$reveal state=<<edit-preview-state>> type="match" text="yes" tag="span">
{{$:/core/images/preview-open}}
<$action-setfield $tiddler=<<edit-preview-state>> $value="no"/>
<$action-sendmessage $message="tm-edit-text-operation" $param="focus-editor"/>
</$reveal>
<$reveal state=<<edit-preview-state>> type="nomatch" text="yes" tag="span">
{{$:/core/images/preview-closed}}
<$action-setfield $tiddler=<<edit-preview-state>> $value="yes"/>
<$action-sendmessage $message="tm-edit-text-operation" $param="focus-editor"/>
</$reveal>
</$let>

View File

@@ -1,6 +1,6 @@
title: $:/config/OfficialPluginLibrary
tags: $:/tags/PluginLibrary
url: https://tiddlywiki.com/library/v5.3.3/index.html
url: https://tiddlywiki.com/library/v5.3.2/index.html
caption: {{$:/language/OfficialPluginLibrary}}
{{$:/language/OfficialPluginLibrary/Hint}}

View File

@@ -1,2 +1,2 @@
title: $:/config/Performance/Instrumentation
text: no
text: yes

View File

@@ -1,6 +1,7 @@
{
"description": "Empty edition",
"plugins": [
"tiddlywiki/sqlite3store"
],
"themes": [
"tiddlywiki/vanilla",

View File

@@ -1,19 +1,13 @@
caption: 5.3.2
created: 20231213080637781
modified: 20231213080637781
released: 20231213080637781
created: 20231016122502955
modified: 20231016122502955
tags: ReleaseNotes
title: Release 5.3.2
type: text/vnd.tiddlywiki
description: Under development
//[[See GitHub for detailed change history of this release|https://github.com/Jermolene/TiddlyWiki5/compare/v5.3.1...v5.3.2]]//
//[[See GitHub for detailed change history of this release|https://github.com/Jermolene/TiddlyWiki5/compare/v5.3.1...master]]//
<<.banner-credits
credit:"""Congratulations to [[catter-fly|https://talk.tiddlywiki.org/u/catter-fly]] for their winning design for the banner for this release (here is the [[competition thread|https://talk.tiddlywiki.org/t/banner-image-competition-for-v5-3-2/8569]]).
"""
url:"https://raw.githubusercontent.com/Jermolene/TiddlyWiki5/51862f812851afda0ed3540f8463f51def0d4f9a/editions/tw5.com/tiddlers/images/New%20Release%20Banner.png"
>>
! Major Improvements
!! Conditional Shortcut Syntax

View File

@@ -1,61 +0,0 @@
caption: 5.3.4
created: 20231223102229103
modified: 20231223102229103
tags: ReleaseNotes
title: Release 5.3.4
type: text/vnd.tiddlywiki
description: Under development
//[[See GitHub for detailed change history of this release|https://github.com/Jermolene/TiddlyWiki5/compare/v5.3.3...master]]//
! Major Improvements
! Translation improvements
Improvements to the following translations:
*
! Plugin Improvements
*
! Widget Improvements
*
! Usability Improvements
*
! Hackability Improvements
*
! Bug Fixes
*
! Node.js Improvements
*
! Performance Improvements
*
! Developer Improvements
*
! Infrastructure Improvements
*
! Acknowledgements
[[@Jermolene|https://github.com/Jermolene]] would like to thank the contributors to this release who have generously given their time to help improve TiddlyWiki:
<<.contributors """
""">>

View File

@@ -1,6 +1,6 @@
title: $:/config/OfficialPluginLibrary
tags: $:/tags/PluginLibrary
url: https://tiddlywiki.com/prerelease/library/v5.3.3/index.html
url: https://tiddlywiki.com/prerelease/library/v5.3.2/index.html
caption: {{$:/language/OfficialPluginLibrary}} (Prerelease)
The prerelease version of the official ~TiddlyWiki plugin library at tiddlywiki.com. Plugins, themes and language packs are maintained by the core team.

View File

@@ -0,0 +1,2 @@
title: $:/config/Performance/Instrumentation
text: yes

View File

@@ -1,31 +1,11 @@
{
"description": "Content for the current prerelease",
"plugins": [
"tiddlywiki/browser-sniff",
"tiddlywiki/help",
"tiddlywiki/stacked-view",
"tiddlywiki/powered-by-tiddlywiki",
"tiddlywiki/internals",
"tiddlywiki/highlight",
"tiddlywiki/bibtex",
"tiddlywiki/savetrail",
"tiddlywiki/external-attachments",
"tiddlywiki/dynaview",
"tiddlywiki/dynannotate",
"tiddlywiki/codemirror",
"tiddlywiki/menubar",
"tiddlywiki/jszip"
"tiddlywiki/sqlite3store"
],
"themes": [
"tiddlywiki/vanilla",
"tiddlywiki/snowwhite",
"tiddlywiki/starlight",
"tiddlywiki/seamless",
"tiddlywiki/centralised",
"tiddlywiki/heavier",
"tiddlywiki/tight",
"tiddlywiki/tight-heavier",
"tiddlywiki/readonly"
"tiddlywiki/snowwhite"
],
"languages": [
],

View File

@@ -1,24 +0,0 @@
title: Functions/FunctionFilterrunVariables
description: Functions in filter runs that set variables
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Idiosyncrasy
caption: Idiosyncrasy Caption Field
+
title: Output
\whitespace trim
\procedure demo-subfilter() [<currentTiddler>]
\function .demo-function() [<currentTiddler>]
<$let currentTiddler="Idiosyncrasy">
<$text text={{{ [<currentTiddler>get[caption]!is[blank]else<currentTiddler>] :map[subfilter<demo-subfilter>] }}}/>,
<$text text={{{ [<currentTiddler>get[caption]!is[blank]else<currentTiddler>] :map[.demo-function[]] }}}/>
</$let>
+
title: ExpectedResult
<p>Idiosyncrasy Caption Field,Idiosyncrasy Caption Field</p>

View File

@@ -1,20 +0,0 @@
title: Functions/FunctionFilterrunVariables2
description: Functions in filter runs that set variables
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Apple
cost: 5
+
title: Output
\whitespace trim
\function .doublecost() [<currentTiddler>get[cost]multiply[2]]
<$text text={{{ [[Apple]] :map[.doublecost[]] }}}/>
+
title: ExpectedResult
10

View File

@@ -1,13 +0,0 @@
title: ListWidget/WithEmptyParagraphTemplate
description: List widget with an empty paragraph as inline template
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
+
title: Output
<$list filter="1"><p/></$list>
+
title: ExpectedResult
<p><p></p></p>

View File

@@ -1,16 +0,0 @@
title: Macros/EndInBody
description: \end line starting with non-whitespace is part of macro body
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define hello()
hello \end
\end
Out: <<hello>>
+
title: ExpectedResult
<p>Out: hello \end</p>

View File

@@ -1,16 +0,0 @@
title: Macros/IndentedEnd
description: \end line starting with whitespace ends a macro body
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define hello()
hello \end
\end
Out: <<hello>>
+
title: ExpectedResult
<p>Out: hello \end</p>

View File

@@ -1,16 +0,0 @@
title: Macros/MismatchedNamedEnd
description: Mismatched named end is part of the body
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define hello()
\end goodbye
\end
Out: <<hello>>
+
title: ExpectedResult
<p>Out: \end goodbye</p>

View File

@@ -1,18 +0,0 @@
title: Macros/WhitespaceOnlyWithEnd
description: The /end should be detected when macro definition contains only whitespace
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define max()
\end
Nothing
\end
Out: <<max>>
+
title: ExpectedResult
<p>Nothing
\end</p><p>Out: </p>

View File

@@ -1,15 +0,0 @@
title: Macros/WhitespaceOnlyWithEnd2
description: Line with \end can start with whitespace
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\define empty()
\end
Out: <<empty>>
+
title: ExpectedResult
<p>Out: </p>

View File

@@ -1,64 +0,0 @@
title: Pragmas/WhitespaceAfterPragma
description: parsermode pragma
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
<$wikify name="parsetree" text={{Text}} mode="inline" output="parsetree">
<$text text=<<parsetree>>/>
</$wikify>
+
title: Text
\procedure this-is-a-definition() Something
Now!
+
title: ExpectedResult
<p>
[
{
"type": "set",
"attributes": {
"name": {
"name": "name",
"type": "string",
"value": "this-is-a-definition"
},
"value": {
"name": "value",
"type": "string",
"value": "Something"
}
},
"children": [
{
"type": "text",
"text": "Now!\n",
"start": 48,
"end": 53
}
],
"params": [],
"orderedAttributes": [
{
"name": "name",
"type": "string",
"value": "this-is-a-definition"
},
{
"name": "value",
"type": "string",
"value": "Something"
}
],
"isProcedureDefinition": true
}
]
</p>

View File

@@ -1,32 +0,0 @@
title: Pragmas/WhitespaceNoPragma
description: parsermode pragma
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
<$wikify name="parsetree" text={{Text}} mode="inline" output="parsetree">
<$text text=<<parsetree>>/>
</$wikify>
+
title: Text
Now!
+
title: ExpectedResult
<p>
[
{
"type": "text",
"text": "\n\n\n\nNow!\n",
"start": 0,
"end": 9
}
]
</p>

View File

@@ -1,16 +0,0 @@
title: Procedures/EndInBody
description: \end line starting with non-whitespace is part of procedure body
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\procedure hello()
hello \end
\end
Out: <<hello>>
+
title: ExpectedResult
<p>Out: hello \end</p>

View File

@@ -1,16 +0,0 @@
title: Procedures/IndentedEnd
description: \end line starting with whitespace ends a procedure body
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\procedure hello()
hello \end
\end
Out: <<hello>>
+
title: ExpectedResult
<p>Out: hello \end</p>

View File

@@ -1,16 +0,0 @@
title: Procedures/MismatchedNamedEnd
description: Mismatched named end is part of the body
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\procedure hello()
\end goodbye
\end
Out: <<hello>>
+
title: ExpectedResult
<p>Out: \end goodbye</p>

View File

@@ -1,18 +0,0 @@
title: Procedures/WhitespaceOnlyWithEnd
description: The /end should be detected when procedure definition contains only whitespace
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\procedure max()
\end
Nothing
\end
Out: <<max>>
+
title: ExpectedResult
<p>Nothing
\end</p><p>Out: </p>

View File

@@ -1,15 +0,0 @@
title: Procedures/WhitespaceOnlyWithEnd2
description: Line with \end can start with whitespace
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\procedure empty()
\end
Out: <<empty>>
+
title: ExpectedResult
<p>Out: </p>

View File

@@ -1,38 +0,0 @@
title: Transclude/Parameterised/ConditionalParameters/Refreshed
description: Parameterised transclusion when conditional parameters are changed by a refresh
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
\procedure elephant(filler)
<$let name={{Canary}}>
<% if [<name>match[yes]] %>
<$parameters A=defaultA>
A/<$text text=<<filler>>/>/<$text text=<<A>>/>/<$text text=<<B>>/>
</$parameters>
<% else %>
<$parameters B=defaultB>
B/<$text text=<<filler>>/>/<$text text=<<A>>/>/<$text text=<<B>>/>
</$parameters>
<% endif %>
\end elephant
-
<<elephant ignore A:myA B:myB>>
&#32;&#32;
<<elephant ignore myA myB>>
+
title: Canary
no
+
title: Actions
<$action-setfield $tiddler="Canary" text="yes"/>
+
title: ExpectedResult
<p>-A/ignore/myA/ A/ignore/myA/</p>

View File

@@ -1,30 +0,0 @@
title: Transclude/Parameterised/ConditionalParameters
description: Parameterised transclusion with conditional parameters
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\procedure elephant(filler)
\whitespace trim
<% if [[no]match[yes]] %>
<$parameters A=defaultA>
A/<$text text=<<filler>>/>/<$text text=<<A>>/>/<$text text=<<B>>/>
</$parameters>
<% else %>
<$parameters B=defaultB>
B/<$text text=<<filler>>/>/<$text text=<<A>>/>/<$text text=<<B>>/>
</$parameters>
<% endif %>
\end elephant
\whitespace trim
-
<<elephant ignore A:myA B:myB>>
&#32;&#32;
<<elephant ignore myB not-used>>
+
title: ExpectedResult
<p>-B/ignore//myB B/ignore//myB</p>

View File

@@ -0,0 +1,34 @@
title: Transclude/Parameterised/Depth
description: Parameterised transclusion using the $depth attribute
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
<$transclude $tiddler='TiddlerOne' one='Ferret'/>
|
<$transclude $tiddler='TiddlerOne'/>
|
<$transclude $tiddler='TiddlerOne' one='Ferret' $$two="Osprey"/>
|
<$transclude $tiddler='TiddlerOne' $$two="Falcon"/>
+
title: TiddlerOne
\whitespace trim
{{TiddlerTwo}}
+
title: TiddlerTwo
\whitespace trim
<$parameters one='Jaguar' $$two='Piranha' $depth="2">
<$text text=<<one>>/>:<$text text=<<$two>>/>
</$parameters>
<$parameters one='Leopard' $$two='Coelacanth'>
(<$text text=<<one>>/>|<$text text=<<$two>>/>)
</$parameters>
+
title: ExpectedResult
<p>Ferret:Piranha(Leopard|Coelacanth)|Jaguar:Piranha(Leopard|Coelacanth)|Ferret:Osprey(Leopard|Coelacanth)|Jaguar:Falcon(Leopard|Coelacanth)</p>

View File

@@ -1,38 +0,0 @@
title: Transclude/Parameterised/GenesisChangingCount
description: Parameterised transclusion using genesis can handle refreshes that change number of parameters
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\procedure elephant(filler)
\whitespace trim
<$text text=<<filler>>/>-
<$let args={{Canary}}>
<$genesis $type=$parameters $names="[enlist<args>]" $values="[enlist<args>addsuffix[-default]]">
<$text text=`($(argA)$-$(argB)$-$(argC)$)` />
</$genesis>
</$let>
<$parameters other=other-default>
-<$text text=<<other>>/>
\end elephant
-
<<elephant filler argA:myA argB:myB argC:myC other:myOther>>
<<elephant filler myA myB myC myOther>>
+
title: Canary
argA argB
+
title: Actions
<$action-setfield $tiddler="Canary" text="argA argB argC"/>
+
title: ExpectedResult
<p>-
filler-(myA-myB-myC)-myOther
filler-(myA-myB-myC)-myOther
</p>

View File

@@ -1,34 +0,0 @@
title: Transclude/Parameterised/GenesisChangingNames
description: Parameterised transclusion using genesis can handle refreshes that change parameter names
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\procedure elephant(filler)
\whitespace trim
<$let name={{Canary}}>
<$genesis $type=$parameters $names="[<name>]" $values="default">
<$text text=<<First>>/>/<$text text=<<Second>>/>
</$genesis>
</$let>
\end elephant
\whitespace trim
-
<<elephant ignore First:init Second:var>>
-
<<elephant ignore var>>
+
title: Canary
First
+
title: Actions
<$action-setfield $tiddler="Canary" text="Second"/>
+
title: ExpectedResult
<p>-/var-/var</p>

View File

@@ -1,44 +0,0 @@
title: Transclude/Parameterised/NestedParameters/Refreshed
description: Parameterised transclusion with nested parameter widgets and a refresh cycle
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\procedure elephant(first:"one",second:"two")
\whitespace trim
\parameters (third:"three")
<$let variable={{Canary}}>
<$parameters fourth=four>
<$text text=<<first>>/>/<$text text=<<second>>/>/<$text text=<<third>>/>/<$text text=<<fourth>>/>
</$parameters>
</$let>
\end elephant
Begin
<<elephant>>
<<elephant "a" "b" "c" "d">>
<<elephant second:named a c d>>
<<elephant third:3rd second:2nd a d>>
<<elephant fourth:4th>>
<<elephant a fourth:4th>>
+
title: Canary
Else
+
title: Actions
<$action-setfield $tiddler="Canary" text="Something"/>
+
title: ExpectedResult
<p>Begin
one/two/three/four
a/b/c/d
a/named/c/d
a/2nd/3rd/d
one/two/three/4th
a/two/three/4th
</p>

View File

@@ -1,34 +0,0 @@
title: Transclude/Parameterised/NestedParameters
description: Parameterised transclusion with nested parameter widgets
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\procedure elephant(first:"one",second:"two")
\whitespace trim
\parameters (third:"three")
<$parameters fourth=four>
<$text text=<<first>>/>/<$text text=<<second>>/>/<$text text=<<third>>/>/<$text text=<<fourth>>/>
</$parameters>
\end elephant
Begin
<<elephant>>
<<elephant "a" "b" "c" "d">>
<<elephant second:named a c d>>
<<elephant third:3rd second:2nd a d>>
<<elephant fourth:4th>>
<<elephant a fourth:4th>>
+
title: ExpectedResult
<p>Begin
one/two/three/four
a/b/c/d
a/named/c/d
a/2nd/3rd/d
one/two/three/4th
a/two/three/4th
</p>

View File

@@ -6,7 +6,7 @@ tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
<$select tiddler='New Tiddler' class="myclass" field='text' default='Choose a new text' data-title={{Temp}} style.color={{{ [[Temp]get[color]] }}} onclick="clicked">
<$select tiddler='New Tiddler' field='text' default='Choose a new text' data-title={{Temp}} style.color={{{ [[Temp]get[color]] }}} onclick="clicked">
<option disabled>Choose a new text</option>
<option>A Tale of Two Cities</option>
<option>A New Kind of Science</option>
@@ -24,4 +24,4 @@ Title1
+
title: ExpectedResult
<p><select class="myclass" data-title="Title2" value="Choose a new text" style="color:red;"><option disabled="true">Choose a new text</option><option>A Tale of Two Cities</option><option>A New Kind of Science</option><option>The Dice Man</option></select></p>
<p><select data-title="Title2" value="Choose a new text" style="color:red;"><option disabled="true">Choose a new text</option><option>A Tale of Two Cities</option><option>A New Kind of Science</option><option>The Dice Man</option></select></p>

View File

@@ -1,7 +1,8 @@
{
"description": "TiddlyWiki core tests",
"plugins": [
"tiddlywiki/jasmine"
"tiddlywiki/jasmine",
"tiddlywiki/sqlite3store"
],
"themes": [
"tiddlywiki/vanilla",

View File

@@ -1,15 +1,9 @@
created: 20140211171341271
modified: 20230922094937115
modified: 20230419103154328
tags: Concepts Reference
title: Macros
type: text/vnd.tiddlywiki
!! Important
<<.from-version "5.3.0">> Macros have been [[superseded|Macro Pitfalls]] by [[Procedures]], [[Functions]] and [[Custom Widgets]] which together provide more robust and flexible ways to encapsulate and re-use code.
For text substitutions it is now recommended to use: [[Substituted Attribute Values]], [[substitute Operator]] and [[Transclusion and Substitution]]
!! Introduction
A <<.def macro>> is a named snippet of text. They are typically defined with the [[Pragma: \define]]:
@@ -32,6 +26,8 @@ The parameters that are specified in the macro call are substituted for special
* `$parameter-name$` is replaced with the value of the named parameter
* `$(variable-name)$` is replaced with the value of the named [[variable|Variables]]).
<<.from-version "5.3.0">> Macros have been [[superseded|Macro Pitfalls]] by [[Procedures]], [[Custom Widgets]] and [[Functions]] which together provide more robust and flexible ways to encapsulate and re-use code. It is now recommended to only use macros when textual substitution is specifically required.
!! How Macros Work
Macros are implemented as a special kind of [[variable|Variables]]. The only thing that distinguishes them from ordinary variables is the way that the parameters are handled.

View File

@@ -24,7 +24,7 @@ The standard fields are:
Other fields used by the core are:
|!Field Name |!Description |
|`class` |<<.from-version "5.1.16">> <<lingo class>> |
|`class` |<<lingo class>> |
|`code-body` |<<.from-version "5.2.1">> <<lingo code-body>> |
|`color` |<<lingo color>> |
|`description` |<<lingo description>> |

View File

@@ -1,5 +1,5 @@
created: 20150117152418000
modified: 20231019155036098
modified: 20220523075540462
tags: Concepts
title: Title List
type: text/vnd.tiddlywiki
@@ -15,7 +15,3 @@ Title lists are used in various places, including PermaLinks and the ListField.
They are in fact the simplest case of a [[filter|Filters]], and are thus a way of expressing a [[selection of titles|Title Selection]].
<<.warning """The [[Title List]] format cannot reliably represent items that contain certain specific character sequences such as `]] `. Thus it should not be used where there is a possibility of such sequences occurring.""">>
See also:
* The [[format Operator]] with the 'titlelist' suffix conditionally wraps double square brackets around a string if it contains whitespace

View File

@@ -1,11 +0,0 @@
created: 20230922121858167
modified: 20230922122333325
tags: [[Operator Examples]] [[jsonstringify Operator]]
title: jsonstringify Operator (Examples)
type: text/vnd.tiddlywiki
Compare the encoding of quotes and control characters in the first example with the analogue [[example for the stringify operator|stringify Operator (Examples)]].
<<.operator-example 1 """[[Backslash \, double quote ", single quote ', tab , line feed
]] +[jsonstringify[]]""">>
<<.operator-example 2 """[[Accents and emojis -> äñøßπ ⌛🎄🍪🍓 without suffix]] +[jsonstringify[]]""">>
<<.operator-example 3 """[[Accents and emojis -> äñøßπ ⌛🎄🍪🍓 with rawunicode suffix]] +[jsonstringify:rawunicode[]]""">>

View File

@@ -1,11 +1,9 @@
created: 20161017154944352
modified: 20230922122319674
modified: 20230919124059118
tags: [[Operator Examples]] [[stringify Operator]]
title: stringify Operator (Examples)
type: text/vnd.tiddlywiki
Compare the encoding of quotes and control characters in the first example with the analogue [[example for the jsonstringify operator|jsonstringify Operator (Examples)]].
<<.operator-example 1 """[[Backslash \, double quote ", single quote ', tab , line feed
]] +[stringify[]]""">>
<<.operator-example 1 """[[Title with "double quotes" and single ' and \backslash]] +[stringify[]]""">>
<<.operator-example 2 """[[Accents and emojis -> äñøßπ ⌛🎄🍪🍓 without suffix]] +[stringify[]]""">>
<<.operator-example 3 """[[Accents and emojis -> äñøßπ ⌛🎄🍪🍓 with rawunicode suffix]] +[stringify:rawunicode[]]""">>

View File

@@ -1,35 +1,12 @@
caption: jsonstringify
created: 20171029155051467
from-version: 5.1.14
modified: 20230922121404577
op-input: a [[selection of titles|Title Selection]]
op-output: the input with JSON string encodings applied
modified: 20230919124826880
op-parameter:
op-parameter-name:
op-purpose: apply JSON string encoding to a string, see also the similar <<.olink stringify>>
op-suffix: <<.from-version "5.1.23">> optionally, the keyword `rawunicode`
op-purpose: deprecated, use <<.olink stringify>> instead
op-suffix-name: R
tags: [[Filter Operators]] [[String Operators]]
title: jsonstringify Operator
type: text/vnd.tiddlywiki
The following substitutions are made:
|!Character |!Replacement |!Condition |
|`\` |`\\` |Always |
|`"` |`\"` |Always |
|Carriage return (0x0d) |`\r` |Always |
|Line feed (0x0a) |`\n` |Always |
|Backspace (0x08) |`\b` |Always |
|Form field (0x0c) |`\f` |Always |
|Tab (0x09) |`\t` |Always|
|Characters from 0x00 to 0x1f, except listed above |`\u####` where #### is four hex digits |Always |
|Characters from from 0x80 to 0xffff|`\u####` where #### is four hex digits |If `rawunicode` suffix is not present (default) |
|Characters from 0x80 to 0xffff|<<.from-version "5.1.23">> Unchanged |If `rawunicode` suffix is present |
<<.from-version "5.1.23">> If the suffix `rawunicode` is present, Unicode characters above 0x80 (such as ß, ä, ñ or 🎄) will be passed through unchanged. Without the suffix, they will be substituted with `\u` codes, which was the default behavior before 5.1.23. Characters outside the Basic Multilingual Plane, such as 🎄 and other emojis, will be encoded as a UTF-16 surrogate pair, i.e. with two `\u` sequences.
<<.note """Mind the differences compared to <<.olink stringify>> in encoding of single quotes and control characters (0x00 to 0x1f).
""">>
<<.operator-examples "jsonstringify">>

View File

@@ -1,12 +1,12 @@
caption: stringify
created: 20161017153038029
from-version: 5.1.14
modified: 20230922121406947
modified: 20230919130847809
op-input: a [[selection of titles|Title Selection]]
op-output: the input with ~JavaScript string encodings applied
op-parameter:
op-parameter-name:
op-purpose: apply ~JavaScript string encoding to a string, see also the similar <<.olink jsonstringify>>
op-purpose: apply ~JavaScript string encoding to a string
op-suffix: <<.from-version "5.1.23">> optionally, the keyword `rawunicode`
op-suffix-name: R
tags: [[Filter Operators]] [[String Operators]]
@@ -18,16 +18,19 @@ The following substitutions are made:
|!Character |!Replacement |!Condition |
|`\` |`\\` |Always |
|`"` |`\"` |Always |
|`'` |`\'` |Always |
|Line feed (0x0a) |`\n` |Always |
|Carriage return (0x0d) |`\r` |Always |
|Characters from 0x00 to 0x1f, except listed above |`\x##` where ## is two hex digits |Always |
|Line feed (0x0a) |`\n` |Always |
|Backspace (0x08) |`\b` |Always |
|Form field (0x0c) |`\f` |Always |
|Tab (0x09) |`\t` |Always |
|Characters from 0x00 to 0x1f |`\x##` where ## is two hex digits |Always |
|Characters from 0x80 to 0xffff|`\u####` where #### is four hex digits |If `rawunicode` suffix is not present (default) |
|Characters from 0x80 to 0xffff|<<.from-version "5.1.23">> Unchanged |If `rawunicode` suffix is present |
<<.from-version "5.1.23">> If the suffix `rawunicode` is present, Unicode characters above 0x80 (such as ß, ä, ñ or 🎄) will be passed through unchanged. Without the suffix, they will be substituted with `\u` codes, which was the default behavior before 5.1.23. Characters outside the Basic Multilingual Plane, such as 🎄 and other emojis, will be encoded as a UTF-16 surrogate pair, i.e. with two `\u` sequences.
<<.from-version "5.1.23">> If the suffix `rawunicode` is present, Unicode characters above 0x80 (such as ß, ä, ñ or 🎄) will be passed through unchanged. Without the suffix, they will be substituted with `\u` codes, which was the default behavior before 5.1.23.
<<.note """Mind the differences compared to <<.olink jsonstringify>> in encoding of single quotes and control characters (0x00 to 0x1f).
""">>
<<.note """Characters outside the Basic Multilingual Plane, such as 🎄 and other emojis, will be encoded as a UTF-16 surrogate pair, i.e. with two `\u` sequences.""">>
<<.olink jsonstringify>> is considered deprecated, as it duplicates the functionality of <<.op stringify>>.
<<.operator-examples "stringify">>

View File

@@ -1,6 +1,6 @@
created: 20130822170200000
list: [[A Gentle Guide to TiddlyWiki]] [[Discover TiddlyWiki]] [[Some of the things you can do with TiddlyWiki]] [[Ten reasons to switch to TiddlyWiki]] Examples [[What happened to the original TiddlyWiki?]]
modified: 20231223102201587
modified: 20230820112855583
tags: TableOfContents
title: HelloThere
type: text/vnd.tiddlywiki
@@ -20,7 +20,7 @@ TiddlyWiki lets you choose where to keep your data, guaranteeing that in the dec
</div>
<div class="tc-cards tc-small">
<$link to="中文社区 - Chinese Community" class="tc-btn-big-green tc-card">
中文社区<br/>Chinese Community
中文社区 - Chinese Community
</$link>
</div>

View File

@@ -1,5 +1,5 @@
created: 20220427174702859
modified: 20230922122551197
modified: 20230809113620964
tags: [[JSON in TiddlyWiki]] Learning
title: Constructing JSON tiddlers
@@ -13,4 +13,4 @@ At a high level, we have several ways to generate JSON data in TiddlyWiki's own
* [[jsontiddler Macro]]
* [[jsontiddlers Macro]]
When constructing JSON data manually, the [[jsonstringify Operator]] is needed to ensure that any special characters are properly escaped.
When constructing JSON data manually, the [[stringify Operator]] is needed to ensure that any special characters are properly escaped.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 102 KiB

View File

@@ -5,4 +5,4 @@ type: text/vnd.tiddlywiki
The following [[macros|Macros]] are built into ~TiddlyWiki's core:
<<list-links "[tag[Core Macros]]" class:"multi-columns">>
<<list-links "[tag[Core Macros]]">>

View File

@@ -11,6 +11,4 @@ The `tm-delete-tiddler` message deletes the specified tiddler and removes it fro
|param |Title of the tiddler that is to be deleted |
|tiddlerTitle |Fallback title that is used if ''param'' isn't specified (automatically set by the ButtonWidget) |
The delete tiddler message is usually generated with the ButtonWidget and is handled by the NavigatorWidget.
Use the [[ActionDeleteTiddlerWidget]] to delete a named tiddler without getting the "Do you wish to delete the tiddler" prompt.
The delete tiddler message is usually generated with the ButtonWidget and is handled by the NavigatorWidget.

View File

@@ -1,5 +1,5 @@
created: 20220917112233317
modified: 20231217185535715
modified: 20230419103154328
tags: Pragmas
title: Pragma: \define
type: text/vnd.tiddlywiki
@@ -48,6 +48,4 @@ $caption$
<<special-button>>
""">>
<<.warning """If macros are nested, textual substitution will only occur for the outermost macro. Thi is because by the time the inner macros are processed all the substitutions will have already occurred""">>
A more formal [[presentation|Macro Definition Syntax]] of this syntax is also available.

View File

@@ -67,35 +67,8 @@ This is <<name>> demonstrates <<desc>>.
<<myproc>>
""">>
!! When Using Positional Parameters
It is uncommon to require multiple parameters pragma in a definition, but if you do so, the positions for parameters are assigned sequentially in the order of discovery. In the below example, `a` is the second positional parameter, because it comes after `x`:
<$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 73>>
</$let>'
/>
This behavior is the same when parameters are defined in the procedure's declaration.
<<wikitext-example-without-html
src:"""\procedure myproc(x:10)
\parameters (a:100, b:200)
x=<<x>>, a=<<a>>, b=<<b>>
\end
<<myproc 50 73>>
""">>
This is because a procedures are a shortcut syntax for the <<.wlink SetWidget>> widget with an implicit <<.wlink ParametersWidget>> widget.
<<.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.">>
!! 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)
@@ -104,5 +77,34 @@ src:"""\procedure myproc(x:10)
x=<<x>>, a=<<a>>, b=<<b>>
\end
<<myproc a:73>>
<<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

@@ -1,9 +1,9 @@
created: 20131109105400007
modified: 20231220113054682
modified: 20211117230125737
tags: Releases BetaReleaseNotes
title: BetaReleases
type: text/vnd.tiddlywiki
Here are the details of the beta releases of TiddlyWiki5. See [[TiddlyWiki5 Versioning]] for details of how releases are named.
<<tabs "[tag[BetaReleaseNotes]!sort[created]] -[<currentTiddler>]" "Release 5.0.18-beta" "$:/state/tab2" "tc-vertical" "ReleaseTemplate">>
<<tabs "[tag[BetaReleaseNotes]!sort[created]]" "Release 5.0.18-beta" "$:/state/tab2" "tc-vertical" "ReleaseTemplate">>

View File

@@ -1,30 +0,0 @@
caption: 5.3.3
created: 20231223102201587
modified: 20231223102201587
released: 20231223102201587
tags: ReleaseNotes
title: Release 5.3.3
type: text/vnd.tiddlywiki
description: Under development
//[[See GitHub for detailed change history of this release|https://github.com/Jermolene/TiddlyWiki5/compare/v5.3.2...v5.3.3]]//
<<.banner-credits
credit:"""Congratulations to [[catter-fly|https://talk.tiddlywiki.org/u/catter-fly]] for their winning design for the banner for this release (here is the [[competition thread|https://talk.tiddlywiki.org/t/banner-image-competition-for-v5-3-2/8569]]).
"""
url:"https://raw.githubusercontent.com/Jermolene/TiddlyWiki5/5cb31b7adb0a6b226c0c215ddbed62e297ce89e1/editions/tw5.com/tiddlers/images/New%20Release%20Banner.png"
>>
This is a bug fix release to address a number of bugs that were introduced with [[Release 5.3.2]].
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/7903">> handling of a list widget with an empty paragraph as inline template
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/7900">> broken per-tiddler previews
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/7897">> missing comma before skinny tiddlers in JSON store area
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/7895">> handling of whitespace immediately after pragmas
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/7905">> SelectWidget handling of classes and rendering typo
Since v5.3.3 replaces v5.3.2 after only a couple of weeks, here is the release note for v5.3.2.
! Release Note for v5.3.2
{{Release 5.3.2}}

View File

@@ -1,9 +1,9 @@
created: 20131109105400007
modified: 20231220113044942
modified: 20211117225858830
tags: Releases AlphaReleaseNotes
title: AlphaReleases
type: text/vnd.tiddlywiki
Here are the details of the alpha releases of TiddlyWiki5. See [[TiddlyWiki5 Versioning]] for details of how releases are named.
<<tabs "[tag[AlphaReleaseNotes]!sort[created]] -[<currentTiddler>]" "Release 5.0.1-alpha" "$:/state/tab2" "tc-vertical" "ReleaseTemplate">>
<<tabs "[tag[AlphaReleaseNotes]!sort[created]]" "Release 5.0.1-alpha" "$:/state/tab2" "tc-vertical" "ReleaseTemplate">>

View File

@@ -0,0 +1,2 @@
title: $:/config/Performance/Instrumentation
text: yes

View File

@@ -148,7 +148,6 @@ type: text/vnd.tiddlywiki
}
.tc-cards.tc-small {
text-align: center;
font-size: 0.7em;
}

View File

@@ -1,6 +1,6 @@
caption: genesis
created: 20221101100729587
modified: 20231214093716044
modified: 20230115101800345
tags: Widgets
title: GenesisWidget
type: text/vnd.tiddlywiki
@@ -15,7 +15,6 @@ The content of the <<.wid genesis>> widget is used as the content of the dynamic
|!Attribute |!Description |
|$type |The type of widget or element to create (an initial `$` indicates a widget, otherwise an HTML element will be created) |
|$remappable |Set to "no" to prevent the generated widget from being affected by any custom widget overrides. Needed when invoking the original widget within a custom widget definition |
|$names |An optional filter evaluating to the names of a list of attributes to be applied to the widget |
|$values |An optional filter evaluating to the values corresponding to the list of names specified in <<.attr $names>> |
|$mode |An optional override of the parsing mode. May be "inline" or "block" |

View File

@@ -13,13 +13,17 @@ There are shortcuts for common scenarios that can often make it unnecessary to u
* the [[Pragma: \procedure]] for declaring procedure
* the [[Pragma: \widget]] for declaring custom widgets
The <<.wlink ParametersWidget>> widget must be used directly when the default value of a parameter must be computed dynamically.
The <<.wlink ParametersWidget>> widget must be used directly in the following situations:
* When the default value of a parameter must be computed dynamically
* When the `$depth` attribute is used to retrieve parameters from a parent transclusion (see below)
! Content and Attributes
The content of the <<.wlink ParametersWidget>> widget is the scope within which the values of the parameters can be accessed as ordinary variables.
|!Attribute |!Description |
|$depth |The index of the parent transclusion from which to obtain the parameters (defaults to 1). See below |
|$parseMode |Optional name of a variable in which is made available the parse mode of the content of the parent transclusion (the parse mode can be "inline" or "block") |
|$parseTreeNodes |Optional name of a variable in which is made available the JSON representation of the parse tree nodes contained within the parent transclusion |
|$slotFillParseTreeNodes |Optional name of a variable in which is made available the JSON representation of the parse tree nodes corresponding to each fill widget contained within the parent transclusion (as an object where the keys are the slot names and the values are the parse tree nodes) |
@@ -30,6 +34,9 @@ The content of the <<.wlink ParametersWidget>> widget is the scope within which
<<.note "Note the special treatment required for parameters names that start with a `$`; this can be avoided by using one of the pragmas">>
!! `$depth` Attribute
By default, the <<.wlink ParametersWidget>> widget retrieves parameters from the immediate parent transclusion. The `$depth` attribute permits access to the parameters of parent transclusions by specifying an index to the parent to be inspected ("1" is the immediate parent, "2" is the parent of that parent, etc.). This is useful in some situations where an intervening transclusion prevents immediate access to desired parameters.
!! `$parseMode`, `$parseTreeNodes`, `$slotFillParseTreeNodes` and `$params` Attributes

View File

@@ -60,16 +60,6 @@ This wiki text shows how to display a list within the scrollable widget:
Set current scroll position to 100,100
</$button>
<$button>
<$action-setfield $tiddler="$:/my-scroll-position" scroll-top={{{ [{$:/my-scroll-position!!scroll-top}subtract[10]] }}}/>
Scroll up by 10 pixels
</$button>
<$button>
<$action-setfield $tiddler="$:/my-scroll-position" scroll-top={{{ [{$:/my-scroll-position!!scroll-top}add[10]] }}}/>
Scroll down by 10 pixels
</$button>
<<wikitext-example-without-html "<$scrollable class='tc-scrollable-demo' bind='$:/my-scroll-position'>
<$list filter='[tag[Reference]]'>

View File

@@ -1,6 +1,6 @@
caption: set
created: 20131115182700000
modified: 20230720174707977
modified: 20220523075522407
tags: Widgets
title: SetWidget
type: text/vnd.tiddlywiki
@@ -120,19 +120,3 @@ src='<$set name="myTiddler" value="HelloThere">
</$set>'/>
<<<
!! Using the Set Widget to Create Global Variables
There are times when it makes sense to use the features of the [[SetWidget]] rather than procedures or functions to create global variables. This can be accomplished by placing the set variable widget in a tiddler that is tagged [[$:/tags/Global|SystemTag: $:/tags/Global]]. If multiple variables are required, the set variable widget can be nested as shown here:
<<<
<div class="doc-example">
```
<$set name="myGlobalVariable" value="I am global">
<$set name="myOtherGlobalVariable" value="I am also a global variable.">
</$set>
</$set>
```
</div>
<<<

View File

@@ -24,7 +24,8 @@ In this simple form, parameters passed by position not by name. So the first val
''Remarks''
# Passing parameter by name is good practice and is recommended for clarity. So for parameterized transclusions, the use of <<.wid transclude>> is recommended over simple form transclusion.
# However, if parameter values are passed by position, parameters get assigned sequentially based on the order <<.wlink ParametersWidget>> widgets are discovered.
# When passing parameters value by position, you cannot pass the second parameter while the first one has not been passed.
''Example iv'': Here the <<.wlink ParametersWidget>> widget is used to declare a parameter whose default value is transcluded from another tiddler.
@@ -35,17 +36,4 @@ My name is <<name>> and my age is <<age>>.
\end
<$transclude $variable="myproc" age="19"/>
"""/>
''Example v'': Here the <<.wlink ParametersWidget>> widget is used in addition to other parameter declarations, because later parameters depend on the value of earlier parameters. Positional values are assigned sequentially.
<$macrocall $name=".example" n="5" eg="""\procedure myproc(age: 22)
<$parameters acceptable-age={{{ [<age>divide[2]add[7]] }}} >
If you're <<age>>, you can date a <<acceptable-age>>-year-old and it's not weird.
</$parameters>
\end
<<myproc>>
<<myproc 30>>
<<myproc 35 70>>
""" />
"""/>

View File

@@ -1,5 +1,5 @@
created: 20141018090608643
modified: 20231030124224424
modified: 20230419103154329
tags: WikiText
title: Transclusion and Substitution
type: text/vnd.tiddlywiki
@@ -55,6 +55,6 @@ As described in [[Introduction to filter notation]], you can also transclude a v
! Textual Substitution
Textual substitution occurs when the value of a macro/variable is used. It is described in [[Substituted Attribute Values]] and [[substitute Operator]]
Textual substitution occurs when the value of a macro/variable is used. It is described in [[Macros]].
The key difference between substitution and transclusion is that substitution occurs before WikiText parsing. This means that you can use substitution to build ~WikiText constructions. Transclusions are processed independently, and cannot be combined with adjacent text to define ~WikiText constructions.
The key difference between substitution and transclusion is that substitution occurs before WikiText parsing. This means that you can use substitution to build WikiText constructions. Transclusions are processed independently, and cannot be combined with adjacent text to define WikiText constructions.

View File

@@ -1,24 +1,11 @@
{
"description": "Documentation from https://tiddlywiki.com",
"plugins": [
"tiddlywiki/nodewebkitsaver",
"tiddlywiki/browser-sniff",
"tiddlywiki/railroad",
"tiddlywiki/evernote",
"tiddlywiki/internals",
"tiddlywiki/menubar",
"tiddlywiki/qrcode"
"tiddlywiki/sqlite3store"
],
"themes": [
"tiddlywiki/vanilla",
"tiddlywiki/snowwhite",
"tiddlywiki/starlight",
"tiddlywiki/seamless",
"tiddlywiki/centralised",
"tiddlywiki/tight",
"tiddlywiki/heavier",
"tiddlywiki/tight-heavier",
"tiddlywiki/readonly"
"tiddlywiki/snowwhite"
],
"languages": [
],

View File

@@ -5,7 +5,6 @@ author: 一个插件作者的姓名
bag: 条目的来源集的名称
caption: 显示于页签或按钮上的标题文字
code-body: 若设置为 ''yes'',视图模板将以程式码形式显示条目
class: 渲染条目时,套用到条目的 CSS 类别 - 请参阅[[依自订类别的自订样式|Custom styles by user-class]]。也适用于[[互动窗口|Modals]]
color: 条目的 CSS 颜色值
component: 负责[[提醒条目|AlertMechanism]]的组件名称
core-version: 对于一个插件,表示与其兼容的 TiddlyWiki 版本

View File

@@ -4,7 +4,6 @@ _canonical_uri: 外部圖片條目的完整的 URI
author: 一個插件作者的姓名
bag: 條目的來源集的名稱
caption: 顯示於頁籤或按鈕上的標題文字
class: 渲染條目時,套用到條目的 CSS 類別 - 請參閱[[依自訂類別的自訂樣式|Custom styles by user-class]]。也適用於[[互動視窗|Modals]]
code-body: 若設定為 ''yes'',檢視範本將以程式碼形式顯示條目
color: 條目的 CSS 顏色值
component: 負責[[警示條目|AlertMechanism]]的元件名稱

View File

@@ -1,7 +1,7 @@
TiddlyWiki created by Jeremy Ruston, (jeremy [at] jermolene [dot] com)
Copyright (c) 2004-2007, Jeremy Ruston
Copyright (c) 2007-2024, UnaMesa Association
Copyright (c) 2007-2023, UnaMesa Association
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@@ -553,9 +553,3 @@ BuckarooBanzay, @BuckarooBanzay, 2023/09/01
Timur, @T1mL3arn, 2023/10/04
Wang Ke, @Gk0Wk, 2023/10/17
@frittro, 2023/10/27
@etardiff, 2023/12/10
John Long, @drevarr, 2023/12/12

View File

@@ -1,7 +1,7 @@
{
"name": "tiddlywiki",
"preferGlobal": "true",
"version": "5.3.4-prerelease",
"version": "5.3.2-prerelease",
"author": "Jeremy Ruston <jeremy@jermolene.com>",
"description": "a non-linear personal web notebook",
"contributors": [

View File

@@ -69,15 +69,6 @@ exports["text/vnd.tiddlywiki2-recipe"] = function(text,fields) {
},
sourcePath = fields.title; // Bit of a hack to take advantage of the default title being the path to the tiddler file
processRecipe(sourcePath,text);
// Add a $:/RecipeTiddlers tiddler with the titles of the loaded tiddlers in order
var titles = [];
$tw.utils.each(tiddlers,function(tiddler) {
titles.push(tiddler.title);
});
tiddlers.push({
title: "$:/RecipeTiddlers",
list: $tw.utils.stringifyList(titles)
});
return tiddlers;
};

View File

@@ -1,7 +1,7 @@
title: $:/core/templates/tiddlywiki2.externaljs.template.html
{{{ [list[$:/RecipeTiddlers]prefix[{prejs}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
{{{ [list[$:/RecipeTiddlers]prefix[{js}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
{{{ [list[$:/RecipeTiddlers]prefix[{postjs}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
{{{ [list[$:/RecipeTiddlers]prefix[{jsext}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
{{{ [prefix[{prejs}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
{{{ [prefix[{js}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
{{{ [prefix[{postjs}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
{{{ [prefix[{jsext}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}

View File

@@ -6,35 +6,35 @@ title: $:/core/templates/tiddlywiki2.template.html
<head>
<script id="versionArea" type="text/javascript">
//<![CDATA[
{{{ [list[$:/RecipeTiddlers]prefix[{version}]] ||$:/core/templates/plain-text-tiddler}}}
{{{ [prefix[{version}]] ||$:/core/templates/plain-text-tiddler}}}
//]]>
</script>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="copyright" content="
{{{ [list[$:/RecipeTiddlers]prefix[{copyright}]] ||$:/core/templates/plain-text-tiddler}}}
{{{ [prefix[{copyright}]] ||$:/core/templates/plain-text-tiddler}}}
" />
<!--PRE-HEAD-START-->
{{{ [list[$:/RecipeTiddlers]prefix[{prehead}]] ||$:/core/templates/plain-text-tiddler}}}
{{{ [prefix[{prehead}]] ||$:/core/templates/plain-text-tiddler}}}
<!--PRE-HEAD-END-->
<title>
{{{ [list[$:/RecipeTiddlers]prefix[{title}]] ||$:/core/templates/plain-text-tiddler}}}
{{{ [prefix[{title}]] ||$:/core/templates/plain-text-tiddler}}}
</title>
<style id="styleArea" type="text/css">
{{{ [list[$:/RecipeTiddlers]prefix[{style}]] ||$:/core/templates/plain-text-tiddler}}}
{{{ [prefix[{style}]] ||$:/core/templates/plain-text-tiddler}}}
</style>
<!--POST-HEAD-START-->
{{{ [list[$:/RecipeTiddlers]prefix[{posthead}]] ||$:/core/templates/plain-text-tiddler}}}
{{{ [prefix[{posthead}]] ||$:/core/templates/plain-text-tiddler}}}
<!--POST-HEAD-END-->
</head>
<body onload="main();" onunload="if(window.unload) unload();">
<!--PRE-BODY-START-->
{{{ [list[$:/RecipeTiddlers]prefix[{prebody}]] ||$:/core/templates/plain-text-tiddler}}}
{{{ [prefix[{prebody}]] ||$:/core/templates/plain-text-tiddler}}}
<!--PRE-BODY-END-->
<div id="copyright">
Welcome to TiddlyWiki created by Jeremy Ruston; Copyright &copy; 2004-2007 Jeremy Ruston, Copyright &copy; 2007-2011 UnaMesa Association
</div>
<noscript>
{{{ [list[$:/RecipeTiddlers]prefix[{noscript}]] ||$:/core/templates/plain-text-tiddler}}}
{{{ [prefix[{noscript}]] ||$:/core/templates/plain-text-tiddler}}}
</noscript>
<div id="saveTest"></div>
<div id="backstageCloak"></div>
@@ -46,39 +46,39 @@ Welcome to TiddlyWiki created by Jeremy Ruston; Copyright &copy; 2004-2007 Jerem
<div id="contentWrapper"></div>
<div id="contentStash"></div>
<div id="shadowArea">
{{{ [list[$:/RecipeTiddlers]prefix[{shadow}]] +[sortcs[title]] ||$:/core/templates/html-div-tiddler-remove-prefix}}}
{{{ [prefix[{shadow}]] +[sortcs[title]] ||$:/core/templates/html-div-tiddler-remove-prefix}}}
</div>
<!--POST-SHADOWAREA-->
<div id="storeArea">
{{{ [list[$:/RecipeTiddlers]prefix[{tiddler}]] +[sortcs[title]] ||$:/core/templates/html-div-tiddler-remove-prefix}}}
{{{ [list[$:/RecipeTiddlers]prefix[{plugin}]] ||$:/core/templates/plain-text-tiddler}}}
{{{ [list[$:/RecipeTiddlers]prefix[{posttiddlers}]] ||$:/core/templates/plain-text-tiddler}}}
{{{ [prefix[{tiddler}]] +[sortcs[title]] ||$:/core/templates/html-div-tiddler-remove-prefix}}}
{{{ [prefix[{plugin}]] ||$:/core/templates/plain-text-tiddler}}}
{{{ [prefix[{posttiddlers}]] ||$:/core/templates/plain-text-tiddler}}}
</div>
<!--POST-STOREAREA-->
<!--POST-BODY-START-->
{{{ [list[$:/RecipeTiddlers]prefix[{postbody}]] ||$:/core/templates/plain-text-tiddler}}}
{{{ [prefix[{postbody}]] ||$:/core/templates/plain-text-tiddler}}}
<!--POST-BODY-END-->
<script id="jsArea" type="text/javascript">
//<![CDATA[
{{{ [list[$:/RecipeTiddlers]prefix[{prejs}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
{{{ [list[$:/RecipeTiddlers]prefix[{js}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
{{{ [list[$:/RecipeTiddlers]prefix[{postjs}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
{{{ [prefix[{prejs}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
{{{ [prefix[{js}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
{{{ [prefix[{postjs}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
//]]>
</script>
{{{ [list[$:/RecipeTiddlers]prefix[{jsext}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
{{{ [prefix[{jsext}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
<script id="jsdeprecatedArea" type="text/javascript">
//<![CDATA[
{{{ [list[$:/RecipeTiddlers]prefix[{jsdeprecated}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
{{{ [prefix[{jsdeprecated}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
//]]>
</script>
<script id="jslibArea" type="text/javascript">
//<![CDATA[
{{{ [list[$:/RecipeTiddlers]prefix[{jslib}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
{{{ [prefix[{jslib}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
//]]>
</script>
<script id="jqueryArea" type="text/javascript">
//<![CDATA[
{{{ [list[$:/RecipeTiddlers]prefix[{jquery}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
{{{ [prefix[{jquery}]] ||$:/core/templates/plain-text-tiddler-strip-comments}}}
//]]>
</script>
<script type="text/javascript">
@@ -88,7 +88,7 @@ if(useJavaSaver)
//]]>
</script>
<!--POST-SCRIPT-START-->
{{{ [list[$:/RecipeTiddlers]prefix[{postscript}]] ||$:/core/templates/plain-text-tiddler}}}
{{{ [prefix[{postscript}]] ||$:/core/templates/plain-text-tiddler}}}
<!--POST-SCRIPT-END-->
</body>
</html>

View File

@@ -0,0 +1,6 @@
{
"title": "$:/plugins/tiddlywiki/demo-alternate-store",
"name": "Demo alternate store",
"description": "Developer demo of an alternate wiki store implementation",
"list": "readme"
}

View File

@@ -0,0 +1,357 @@
/*\
title: $:/plugins/tiddlywiki/demo-alternate-store/rawmarkup.js
type: text/plain
tags: $:/tags/AlternateStoreArea
Startup code injected as raw markup
\*/
(function() {
// Need to initialise these because we run before bootprefix.js and boot.js
$tw = window.$tw || Object.create(null);
$tw.hooks = $tw.hooks || { names: {}};
$tw.boot = $tw.boot || {};
$tw.boot.preloadDirty = $tw.boot.preloadDirty || [];
$tw.Wiki = function(options) {
options = options || {};
var self = this,
tiddlers = Object.create(null), // Hashmap of tiddlers
getTiddlerTitles = function() {
return Object.keys(tiddlers).sort(function(a,b) {return a.localeCompare(b);});
},
pluginTiddlers = [], // Array of tiddlers containing registered plugins, ordered by priority
pluginInfo = Object.create(null), // Hashmap of parsed plugin content
shadowTiddlers = Object.create(null), // Hashmap by title of {source:, tiddler:}
getShadowTiddlerTitles = function() {
return Object.keys(shadowTiddlers);
};
//$tw.utils replacements
var eachObj = function(object,callback) {
var next,f,length;
if(object) {
if(Object.prototype.toString.call(object) == "[object Array]") {
for (f=0, length=object.length; f<length; f++) {
next = callback(object[f],f,object);
if(next === false) {
break;
}
}
} else {
var keys = Object.keys(object);
for (f=0, length=keys.length; f<length; f++) {
var key = keys[f];
next = callback(object[key],key,object);
if(next === false) {
break;
}
}
}
}
},
hop = function(object,property) {
return object ? Object.prototype.hasOwnProperty.call(object,property) : false;
},
insertSortedArray = function(array,value) {
var low = 0, high = array.length - 1, mid, cmp;
while(low <= high) {
mid = (low + high) >> 1;
cmp = value.localeCompare(array[mid]);
if(cmp > 0) {
low = mid + 1;
} else if(cmp < 0) {
high = mid - 1;
} else {
return array;
}
}
array.splice(low,0,value);
return array;
},
parseJSONSafe = function(text,defaultJSON) {
try {
return JSON.parse(text);
} catch(e) {
if(typeof defaultJSON === "function") {
return defaultJSON(e);
} else {
return defaultJSON || {};
}
}
};
this.addIndexer = function(indexer,name) {
return;
};
this.getIndexer = function(name) {
return null;
};
// Add a tiddler to the store
this.addTiddler = function(tiddler) {
if(!(tiddler instanceof $tw.Tiddler)) {
tiddler = new $tw.Tiddler(tiddler);
}
// Save the tiddler
if(tiddler) {
var title = tiddler.fields.title;
if(title) {
// Save the new tiddler
tiddlers[title] = tiddler;
// Update caches
this.clearCache(title);
this.clearGlobalCache();
// Queue a change event
this.enqueueTiddlerEvent(title);
}
}
};
// Delete a tiddler
this.deleteTiddler = function(title) {
// Uncomment the following line for detailed logs of all tiddler deletions
// console.log("Deleting",title)
if(hop(tiddlers,title)) {
// Delete the tiddler
delete tiddlers[title];
// Update caches
this.clearCache(title);
this.clearGlobalCache();
// Queue a change event
this.enqueueTiddlerEvent(title,true);
}
};
// Get a tiddler from the store
this.getTiddler = function(title) {
if(title) {
var t = tiddlers[title];
if(t !== undefined) {
return t;
} else {
var s = shadowTiddlers[title];
if(s !== undefined) {
return s.tiddler;
}
}
}
return undefined;
};
// Get an array of all tiddler titles
this.allTitles = function() {
return getTiddlerTitles();
};
// Iterate through all tiddler titles
this.each = function(callback) {
var titles = getTiddlerTitles(),
index,titlesLength,title;
for(index = 0, titlesLength = titles.length; index < titlesLength; index++) {
title = titles[index];
callback(self.getTiddler(title),title);
}
};
// Get an array of all shadow tiddler titles
this.allShadowTitles = function() {
return getShadowTiddlerTitles();
};
// Iterate through all shadow tiddler titles
this.eachShadow = function(callback) {
var titles = getShadowTiddlerTitles(),
index,titlesLength,title;
for(index = 0, titlesLength = titles.length; index < titlesLength; index++) {
title = titles[index];
if(self.tiddlerExists(title)) {
callback(self.getTiddler(title),title);
} else {
var shadowInfo = shadowTiddlers[title];
callback(shadowInfo.tiddler,title);
}
}
};
// Iterate through all tiddlers and then the shadows
this.eachTiddlerPlusShadows = function(callback) {
var index,titlesLength,title,
titles = getTiddlerTitles();
for(index = 0, titlesLength = titles.length; index < titlesLength; index++) {
title = titles[index];
callback(self.getTiddler(title),title);
}
titles = getShadowTiddlerTitles();
for(index = 0, titlesLength = titles.length; index < titlesLength; index++) {
title = titles[index];
if(!self.tiddlerExists(title)) {
var shadowInfo = shadowTiddlers[title];
callback(shadowInfo.tiddler,title);
}
}
};
// Iterate through all the shadows and then the tiddlers
this.eachShadowPlusTiddlers = function(callback) {
var index,titlesLength,title,
titles = getShadowTiddlerTitles();
for(index = 0, titlesLength = titles.length; index < titlesLength; index++) {
title = titles[index];
if(self.tiddlerExists(title)) {
callback(self.getTiddler(title),title);
} else {
var shadowInfo = shadowTiddlers[title];
callback(shadowInfo.tiddler,title);
}
}
titles = getTiddlerTitles();
for(index = 0, titlesLength = titles.length; index < titlesLength; index++) {
title = titles[index];
if(!shadowTiddlers[title]) {
callback(self.getTiddler(title),title);
}
}
};
this.tiddlerExists = function(title) {
return !!hop(tiddlers,title);
};
this.isShadowTiddler = function(title) {
return hop(shadowTiddlers,title);
};
this.getShadowSource = function(title) {
if(hop(shadowTiddlers,title)) {
return shadowTiddlers[title].source;
}
return null;
};
// Get an array of all the currently recognised plugin types
this.getPluginTypes = function() {
var types = [];
eachObj(pluginTiddlers,function(pluginTiddler) {
var pluginType = pluginTiddler.fields["plugin-type"];
if(pluginType && types.indexOf(pluginType) === -1) {
types.push(pluginType);
}
});
return types;
};
// Read plugin info for all plugins, or just an array of titles. Returns the number of plugins updated or deleted
this.readPluginInfo = function(titles) {
var results = {
modifiedPlugins: [],
deletedPlugins: []
};
eachObj(titles || getTiddlerTitles(),function(title) {
var tiddler = self.getTiddler(title);
if(tiddler) {
if(tiddler.fields.type === "application/json" && tiddler.hasField("plugin-type") && tiddler.fields.text) {
pluginInfo[tiddler.fields.title] = parseJSONSafe(tiddler.fields.text);
results.modifiedPlugins.push(tiddler.fields.title);
}
} else {
if(pluginInfo[title]) {
delete pluginInfo[title];
results.deletedPlugins.push(title);
}
}
});
return results;
};
// Get plugin info for a plugin
this.getPluginInfo = function(title) {
return pluginInfo[title];
};
// Register the plugin tiddlers of a particular type, or null/undefined for any type, optionally restricting registration to an array of tiddler titles. Return the array of titles affected
this.registerPluginTiddlers = function(pluginType,titles) {
var self = this,
registeredTitles = [],
checkTiddler = function(tiddler,title) {
if(tiddler && tiddler.fields.type === "application/json" && tiddler.fields["plugin-type"] && (!pluginType || tiddler.fields["plugin-type"] === pluginType)) {
var disablingTiddler = self.getTiddler("$:/config/Plugins/Disabled/" + title);
if(title === "$:/core" || !disablingTiddler || (disablingTiddler.fields.text || "").trim() !== "yes") {
self.unregisterPluginTiddlers(null,[title]); // Unregister the plugin if it's already registered
pluginTiddlers.push(tiddler);
registeredTitles.push(tiddler.fields.title);
}
}
};
if(titles) {
eachObj(titles,function(title) {
checkTiddler(self.getTiddler(title),title);
});
} else {
this.each(function(tiddler,title) {
checkTiddler(tiddler,title);
});
}
return registeredTitles;
};
// Unregister the plugin tiddlers of a particular type, or null/undefined for any type, optionally restricting unregistering to an array of tiddler titles. Returns an array of the titles affected
this.unregisterPluginTiddlers = function(pluginType,titles) {
var self = this,
unregisteredTitles = [];
// Remove any previous registered plugins of this type
for(var t=pluginTiddlers.length-1; t>=0; t--) {
var tiddler = pluginTiddlers[t];
if(tiddler.fields["plugin-type"] && (!pluginType || tiddler.fields["plugin-type"] === pluginType) && (!titles || titles.indexOf(tiddler.fields.title) !== -1)) {
unregisteredTitles.push(tiddler.fields.title);
pluginTiddlers.splice(t,1);
}
}
return unregisteredTitles;
};
// Unpack the currently registered plugins, creating shadow tiddlers for their constituent tiddlers
this.unpackPluginTiddlers = function() {
var self = this;
// Sort the plugin titles by the `plugin-priority` field
pluginTiddlers.sort(function(a,b) {
if("plugin-priority" in a.fields && "plugin-priority" in b.fields) {
return a.fields["plugin-priority"] - b.fields["plugin-priority"];
} else if("plugin-priority" in a.fields) {
return -1;
} else if("plugin-priority" in b.fields) {
return +1;
} else if(a.fields.title < b.fields.title) {
return -1;
} else if(a.fields.title === b.fields.title) {
return 0;
} else {
return +1;
}
});
// Now go through the plugins in ascending order and assign the shadows
shadowTiddlers = Object.create(null);
eachObj(pluginTiddlers,function(tiddler) {
// Extract the constituent tiddlers
if(hop(pluginInfo,tiddler.fields.title)) {
eachObj(pluginInfo[tiddler.fields.title].tiddlers,function(constituentTiddler,constituentTitle) {
// Save the tiddler object
if(constituentTitle) {
shadowTiddlers[constituentTitle] = {
source: tiddler.fields.title,
tiddler: new $tw.Tiddler(constituentTiddler,{title: constituentTitle})
};
}
});
}
});
shadowTiddlerTitles = null;
this.clearCache(null);
this.clearGlobalCache();
};
};
})();
//# sourceURL=$:/plugins/tiddlywiki/demo-alternate-store/rawmarkup.js

View File

@@ -0,0 +1,6 @@
title: $:/plugins/tiddlywiki/demo-alternate-store/rawmarkup
tags: $:/tags/RawMarkupWikified
`<script>`
{{$:/plugins/tiddlywiki/demo-alternate-store/rawmarkup.js}}
`</script>`

View File

@@ -0,0 +1,3 @@
title: $:/plugins/tiddlywiki/demo-alternate-store/readme
Developer demo of an alternate wiki store implementation

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -0,0 +1,19 @@
{
"tiddlers": [
{
"file": "sqlite3.js",
"fields": {
"type": "text/plain",
"title": "$:/plugins/tiddlywiki/sqlite3store/sqlite3.js"
}
},
{
"file": "sqlite3.wasm",
"encoding": "base64",
"fields": {
"type": "application/wasm",
"title": "$:/plugins/tiddlywiki/sqlite3store/sqlite3.wasm"
}
}
]
}

View File

@@ -0,0 +1,66 @@
/*\
title: $:/plugins/tiddlywiki/sqlite3store/init-sqlite3.js
type: application/javascript
Initialise sqlite3 and then boot TiddlyWiki
This file is spliced into the HTML file to be executed after the boot kernel has been loaded.
\*/
(function() {
// Get the main tiddler store out of the HTML file
var storeEl = document.querySelector("script.tiddlywiki-tiddler-store"),
tiddlerStore = JSON.parse(storeEl.textContent);
// Helper to get a tiddler from the store by title
function getTiddler(title) {
for(var t=0; t<tiddlerStore.length; t++) {
var tiddler = tiddlerStore[t];
if(tiddler.title === title) {
return tiddler;
}
}
return undefined;
}
// Get the shadow tiddlers of this plugin
var thisPlugin = getTiddler("$:/plugins/tiddlywiki/sqlite3store"),
thisPluginTiddlers = JSON.parse(thisPlugin.text).tiddlers;
// Execute the sqlite3 module
var sqlite3js = thisPluginTiddlers["$:/plugins/tiddlywiki/sqlite3store/sqlite3.js"].text,
context = {
exports: {}
};
$tw.utils.evalSandboxed(sqlite3js,context,"$:/plugins/tiddlywiki/sqlite3store/sqlite3.js",true);
// Create a Blob URL for the wasm data
var sqlite3wasm = thisPluginTiddlers["$:/plugins/tiddlywiki/sqlite3store/sqlite3.wasm"].text;
var decodedData = window.atob(sqlite3wasm),
uInt8Array = new Uint8Array(decodedData.length);
for (var i = 0; i < decodedData.length; ++i) {
uInt8Array[i] = decodedData.charCodeAt(i);
}
var blobUrl = URL.createObjectURL(new Blob([uInt8Array],{type: "application/wasm"}));
// Pass sqlite an URLSearchParams object containing the Blob URL of our wasm data
self.sqlite3InitModuleState.urlParams = new URLSearchParams();
self.sqlite3InitModuleState.urlParams.set("sqlite3.wasm",blobUrl);
// Initialise sqlite
self.sqlite3InitModule().then((sqlite3)=>{
// Save a reference to the sqlite3 object
$tw.sqlite3 = sqlite3;
var capi = $tw.sqlite3.capi, // C-style API
oo = $tw.sqlite3.oo1; // High-level OO API
// Boot the console
$tw.sqlConsole = new $tw.SqlConsole();
// Get version numbers
console.log("sqlite3 version",capi.sqlite3_libversion());
// Run tests
if($tw.testSqlFunctions) {
$tw.testSqlFunctions();
}
// Boot TiddlyWiki
$tw.boot.boot();
});
})();
//# sourceURL=$:/plugins/tiddlywiki/sqlite3store/init-sqlite3.js

View File

@@ -0,0 +1,6 @@
{
"title": "$:/plugins/tiddlywiki/sqlite3store",
"name": "Sqlite3-based store",
"description": "Sqlite3-based wiki store implementation",
"list": "readme"
}

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