mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
5d893397c4
41
boot/boot.js
41
boot/boot.js
@ -357,8 +357,13 @@ $tw.utils.parseVersion = function(version) {
|
||||
Returns true if the version string A is greater than the version string B
|
||||
*/
|
||||
$tw.utils.checkVersions = function(versionStringA,versionStringB) {
|
||||
var versionA = $tw.utils.parseVersion(versionStringA),
|
||||
versionB = $tw.utils.parseVersion(versionStringB),
|
||||
var defaultVersion = {
|
||||
major: 0,
|
||||
minor: 0,
|
||||
patch: 0
|
||||
},
|
||||
versionA = $tw.utils.parseVersion(versionStringA) || defaultVersion,
|
||||
versionB = $tw.utils.parseVersion(versionStringB) || defaultVersion,
|
||||
diff = [
|
||||
versionA.major - versionB.major,
|
||||
versionA.minor - versionB.minor,
|
||||
@ -791,7 +796,8 @@ Construct a wiki store object
|
||||
*/
|
||||
$tw.Wiki = function() {
|
||||
this.tiddlers = {};
|
||||
this.plugins = []; // Array of registered plugins, ordered by priority
|
||||
this.pluginTiddlers = []; // Array of tiddlers containing registered plugins, ordered by priority
|
||||
this.pluginInfo = {}; // Hashmap of parsed plugin content
|
||||
this.shadowTiddlers = {}; // Hashmap by title of {source:, tiddler:}
|
||||
};
|
||||
|
||||
@ -810,6 +816,18 @@ $tw.Wiki.prototype.addTiddlers = function(tiddlers) {
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Read plugin info for all plugins
|
||||
*/
|
||||
$tw.Wiki.prototype.readPluginInfo = function() {
|
||||
var self = this;
|
||||
$tw.utils.each(this.tiddlers,function(tiddler,title) {
|
||||
if(tiddler && tiddler.fields.type === "application/json" && tiddler.hasField("plugin-type")) {
|
||||
self.pluginInfo[tiddler.fields.title] = JSON.parse(tiddler.fields.text);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
Register the plugin tiddlers of a particular type, optionally restricting registration to an array of tiddler titles. Return the array of titles affected
|
||||
*/
|
||||
@ -819,7 +837,7 @@ $tw.Wiki.prototype.registerPluginTiddlers = function(pluginType,titles) {
|
||||
// Go through the provided titles, or the entire tiddler list, looking for plugins of this type
|
||||
var checkTiddler = function(tiddler) {
|
||||
if(tiddler && tiddler.fields.type === "application/json" && tiddler.fields["plugin-type"] === pluginType) {
|
||||
self.plugins.push(tiddler);
|
||||
self.pluginTiddlers.push(tiddler);
|
||||
registeredTitles.push(tiddler.fields.title);
|
||||
}
|
||||
};
|
||||
@ -842,11 +860,11 @@ $tw.Wiki.prototype.unregisterPluginTiddlers = function(pluginType) {
|
||||
var self = this,
|
||||
titles = [];
|
||||
// Remove any previous registered plugins of this type
|
||||
for(var t=this.plugins.length-1; t>=0; t--) {
|
||||
var tiddler = this.plugins[t];
|
||||
for(var t=this.pluginTiddlers.length-1; t>=0; t--) {
|
||||
var tiddler = this.pluginTiddlers[t];
|
||||
if(tiddler.fields["plugin-type"] === pluginType) {
|
||||
titles.push(tiddler.fields.title);
|
||||
this.plugins.splice(t,1);
|
||||
this.pluginTiddlers.splice(t,1);
|
||||
}
|
||||
}
|
||||
return titles;
|
||||
@ -858,7 +876,7 @@ Unpack the currently registered plugins, creating shadow tiddlers for their cons
|
||||
$tw.Wiki.prototype.unpackPluginTiddlers = function() {
|
||||
var self = this;
|
||||
// Sort the plugin titles by the `plugin-priority` field
|
||||
this.plugins.sort(function(a,b) {
|
||||
this.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) {
|
||||
@ -875,11 +893,9 @@ $tw.Wiki.prototype.unpackPluginTiddlers = function() {
|
||||
});
|
||||
// Now go through the plugins in ascending order and assign the shadows
|
||||
this.shadowTiddlers = {};
|
||||
$tw.utils.each(this.plugins,function(tiddler) {
|
||||
// Get the plugin information
|
||||
var pluginInfo = JSON.parse(tiddler.fields.text);
|
||||
$tw.utils.each(this.pluginTiddlers,function(tiddler) {
|
||||
// Extract the constituent tiddlers
|
||||
$tw.utils.each(pluginInfo.tiddlers,function(constituentTiddler,constituentTitle) {
|
||||
$tw.utils.each(self.pluginInfo[tiddler.fields.title].tiddlers,function(constituentTiddler,constituentTitle) {
|
||||
// Save the tiddler object
|
||||
if(constituentTitle) {
|
||||
self.shadowTiddlers[constituentTitle] = {
|
||||
@ -1535,6 +1551,7 @@ $tw.boot.startup = function(options) {
|
||||
$tw.loadTiddlersNode();
|
||||
}
|
||||
// Unpack plugin tiddlers
|
||||
$tw.wiki.readPluginInfo();
|
||||
$tw.wiki.registerPluginTiddlers("plugin");
|
||||
$tw.wiki.unpackPluginTiddlers();
|
||||
// Register typed modules from the tiddlers we've just loaded
|
||||
|
@ -1,5 +1,14 @@
|
||||
title: $:/language/TiddlerInfo/
|
||||
|
||||
Advanced/Caption: Advanced
|
||||
Advanced/PluginInfo/Empty/Hint: none
|
||||
Advanced/PluginInfo/Heading: Plugin Details
|
||||
Advanced/PluginInfo/Hint: This plugin contains the following shadow tiddlers:
|
||||
Advanced/ShadowInfo/Heading: Shadow Status
|
||||
Advanced/ShadowInfo/NotShadow/Hint: The tiddler <$link to=<<infoTiddler>>><$text text=<<infoTiddler>>/></$link> is not a shadow tiddler
|
||||
Advanced/ShadowInfo/Shadow/Hint: The tiddler <$link to=<<infoTiddler>>><$text text=<<infoTiddler>>/></$link> is a shadow tiddler
|
||||
Advanced/ShadowInfo/Shadow/Source: It is defined in the plugin <$link to=<<pluginTiddler>>><$text text=<<pluginTiddler>>/></$link>
|
||||
Advanced/ShadowInfo/OverriddenShadow/Hint: It is overridden by an ordinary tiddler
|
||||
Fields/Caption: Fields
|
||||
List/Caption: List
|
||||
List/Empty: This tiddler does not have a list
|
||||
|
47
core/modules/filters/plugintiddlers.js
Normal file
47
core/modules/filters/plugintiddlers.js
Normal file
@ -0,0 +1,47 @@
|
||||
/*\
|
||||
title: $:/core/modules/filters/plugintiddlers.js
|
||||
type: application/javascript
|
||||
module-type: filteroperator
|
||||
|
||||
Filter operator for returning the titles of the shadow tiddlers within a plugin
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Export our filter function
|
||||
*/
|
||||
exports.plugintiddlers = function(source,operator,options) {
|
||||
var results = [],
|
||||
pushShadows;
|
||||
switch(operator.operand) {
|
||||
default:
|
||||
pushShadows = function(title) {
|
||||
var pluginInfo = options.wiki.pluginInfo[title];
|
||||
if(pluginInfo) {
|
||||
$tw.utils.each(pluginInfo.tiddlers,function(fields,title) {
|
||||
results.push(title);
|
||||
});
|
||||
}
|
||||
};
|
||||
break;
|
||||
}
|
||||
// Iterate through the source tiddlers
|
||||
if($tw.utils.isArray(source)) {
|
||||
$tw.utils.each(source,function(title) {
|
||||
pushShadows(title);
|
||||
});
|
||||
} else {
|
||||
$tw.utils.each(source,function(element,title) {
|
||||
pushShadows(title);
|
||||
});
|
||||
}
|
||||
results.sort();
|
||||
return results;
|
||||
};
|
||||
|
||||
})();
|
40
core/modules/filters/shadowsource.js
Normal file
40
core/modules/filters/shadowsource.js
Normal file
@ -0,0 +1,40 @@
|
||||
/*\
|
||||
title: $:/core/modules/filters/shadowsource.js
|
||||
type: application/javascript
|
||||
module-type: filteroperator
|
||||
|
||||
Filter operator for returning the source plugins for shadow tiddlers
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Export our filter function
|
||||
*/
|
||||
exports.shadowsource = function(source,operator,options) {
|
||||
var results = [],
|
||||
pushShadowSource = function(title) {
|
||||
var shadowInfo = options.wiki.shadowTiddlers[title];
|
||||
if(shadowInfo) {
|
||||
$tw.utils.pushTop(results,shadowInfo.source);
|
||||
}
|
||||
};
|
||||
// Iterate through the source tiddlers
|
||||
if($tw.utils.isArray(source)) {
|
||||
$tw.utils.each(source,function(title) {
|
||||
pushShadowSource(title);
|
||||
});
|
||||
} else {
|
||||
$tw.utils.each(source,function(element,title) {
|
||||
pushShadowSource(title);
|
||||
});
|
||||
}
|
||||
results.sort();
|
||||
return results;
|
||||
};
|
||||
|
||||
})();
|
8
core/ui/TiddlerInfo/Advanced.tid
Normal file
8
core/ui/TiddlerInfo/Advanced.tid
Normal file
@ -0,0 +1,8 @@
|
||||
title: $:/core/ui/TiddlerInfo/Advanced
|
||||
tags: $:/tags/TiddlerInfo
|
||||
caption: {{$:/language/TiddlerInfo/Advanced/Caption}}
|
||||
|
||||
<$list filter="[is[shadow]!has[draft.of]tag[$:/tags/TiddlerInfo/Advanced]] [!is[shadow]!has[draft.of]tag[$:/tags/TiddlerInfo/Advanced]] +[tag[$:/tags/TiddlerInfo/Advanced]]" variable="listItem">
|
||||
<$transclude tiddler=<<listItem>>/>
|
||||
|
||||
</$list>
|
20
core/ui/TiddlerInfo/Advanced/PluginInfo.tid
Normal file
20
core/ui/TiddlerInfo/Advanced/PluginInfo.tid
Normal file
@ -0,0 +1,20 @@
|
||||
title: $:/core/ui/TiddlerInfo/Advanced/PluginInfo
|
||||
tags: $:/tags/TiddlerInfo/Advanced
|
||||
|
||||
\define lingo-base() $:/language/TiddlerInfo/Advanced/PluginInfo/
|
||||
<$list filter="[is[current]has[plugin-type]]">
|
||||
|
||||
! <<lingo Heading>>
|
||||
|
||||
<<lingo Hint>>
|
||||
<ul>
|
||||
<$list filter="[is[current]plugintiddlers[]sort[title]]" emptyMessage=<<lingo Empty/Hint>>>
|
||||
<li>
|
||||
<$link to={{!!title}}>
|
||||
<$view field="title"/>
|
||||
</$link>
|
||||
</li>
|
||||
</$list>
|
||||
</ul>
|
||||
|
||||
</$list>
|
35
core/ui/TiddlerInfo/Advanced/ShadowInfo.tid
Normal file
35
core/ui/TiddlerInfo/Advanced/ShadowInfo.tid
Normal file
@ -0,0 +1,35 @@
|
||||
title: $:/core/ui/TiddlerInfo/Advanced/ShadowInfo
|
||||
tags: $:/tags/TiddlerInfo/Advanced
|
||||
|
||||
\define lingo-base() $:/language/TiddlerInfo/Advanced/ShadowInfo/
|
||||
<$set name="infoTiddler" value=<<currentTiddler>>>
|
||||
|
||||
! <<lingo Heading>>
|
||||
|
||||
<$list filter="[is[current]!is[shadow]]">
|
||||
|
||||
<<lingo NotShadow/Hint>>
|
||||
|
||||
</$list>
|
||||
|
||||
<$list filter="[is[current]is[shadow]]">
|
||||
|
||||
<<lingo Shadow/Hint>>
|
||||
|
||||
<$list filter="[is[current]shadowsource[]]">
|
||||
|
||||
<$set name="pluginTiddler" value=<<currentTiddler>>>
|
||||
<<lingo Shadow/Source>>
|
||||
</$set>
|
||||
|
||||
</$list>
|
||||
|
||||
<$list filter="[is[current]is[shadow]is[tiddler]]">
|
||||
|
||||
<<lingo OverriddenShadow/Hint>>
|
||||
|
||||
</$list>
|
||||
|
||||
|
||||
</$list>
|
||||
</$set>
|
2
core/wiki/tags/TiddlerInfoAdvanced.tid
Normal file
2
core/wiki/tags/TiddlerInfoAdvanced.tid
Normal file
@ -0,0 +1,2 @@
|
||||
title: $:/tags/TiddlerInfo/Advanced
|
||||
list: [[$:/core/ui/TiddlerInfo/Advanced/ShadowInfo]] [[$:/core/ui/TiddlerInfo/Advanced/PluginInfo]]
|
@ -5,6 +5,13 @@ hack-to-give-us-something-to-compare-against: yes
|
||||
<!-- For Google, and people without JavaScript-->
|
||||
<$reveal state="!!hack-to-give-us-something-to-compare-against" type="nomatch" text=<<savingEmpty>>>
|
||||
|
||||
It looks like this browser doesn't run JavaScript. You can use one of these static HTML versions to browse the same content:
|
||||
|
||||
* http://tiddlywiki.com/static.html - browse individual tiddlers as separate pages
|
||||
* http://tiddlywiki.com/alltiddlers.html#HelloThere - single file containing all tiddlers
|
||||
|
||||
---
|
||||
|
||||
{{HelloThere}}
|
||||
|
||||
{{TiddlyWiki}}
|
||||
|
Loading…
Reference in New Issue
Block a user