1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-09-27 14:48:19 +00:00

More permalink tweaks

And more documentation this time!
This commit is contained in:
Jermolene 2014-05-29 23:17:21 +01:00
parent 412cde6f53
commit 3f25db0abe
2 changed files with 20 additions and 3 deletions

View File

@ -61,8 +61,8 @@ defaultToCurrentStory: If true, the current story is retained as the default, in
*/
function openStartupTiddlers(options) {
options = options || {};
// Decode the hash portion of our URL
var target,
// Work out the target tiddler and the story filter. "null" means "unspecified"
var target = null,
storyFilter = null;
if($tw.locationHash.length > 1) {
var hash = $tw.locationHash.substr(1),
@ -80,9 +80,14 @@ function openStartupTiddlers(options) {
var currStoryList = $tw.wiki.getTiddlerList(DEFAULT_STORY_TITLE);
storyFilter = $tw.utils.stringifyList(currStoryList);
} else {
storyFilter = "";
if(target && target !== "") {
storyFilter = "";
} else {
storyFilter = $tw.wiki.getTiddlerText(DEFAULT_TIDDLERS_TITLE);
}
}
}
// Process the story filter to get the story list
var storyList = $tw.wiki.filterTiddlers(storyFilter);
// If the target tiddler isn't included then splice it in at the top
if(target && storyList.indexOf(target) === -1) {

View File

@ -48,3 +48,15 @@ Two important aspects of TiddlyWiki's behaviour with permalinks can be controlle
* Whether the updates to the address bar should affect browser history. The default is ''no''; when switched to ''yes'' you can rewind navigation between tiddlers using the browser back and forward buttons
Note that typing or navigating to a permalink will always cause the permalink to be processed, and tiddlers opened and closed as appropriate.
!! Technical Details
When TiddlyWiki starts up it processes permalinks according to the following steps; the same steps are repeated if the permalink changes dynamically (this happens in response to the user editing the address bar, for example).
# If the permalink contains a colon, treat the string before as the ''target'' and the string after it as the ''story filter''
# If the permalink doesn't contain a colon, treat the entire string as the ''target'' and mark the ''story filter'' as //unspecified//
# If the ''story filter'' was unspecified and we're in the process of starting up, then set the ''story filter'' to the empty string if the ''target'' is specified, or to the default tiddlers if the ''target'' is unspecified
# If the ''story filter'' was unspecified and we're not starting up, then set the ''story filter'' to the current story list
# Evaluate the ''story filter'' as the ''story list''
# If the ''target'' is specified and not present in the ''story list'' then add it at the top
# If the ''target'' is specified then navigate to it, otherwise navigate to the first tiddler in the ''story list''