mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 09:00:27 +00:00
Make permalink behaviour configurable
In the process introducing a new advanced settings tab Fixes #600
This commit is contained in:
parent
4e07b3335b
commit
ad43958571
@ -4,6 +4,17 @@ Advanced/Caption: Advanced
|
||||
Advanced/Hint: Internal information about this TiddlyWiki
|
||||
Advanced/LoadedModules/Caption: Loaded Modules
|
||||
Advanced/LoadedModules/Hint: These are the currently loaded tiddler modules linked to their source tiddlers. Any italicised modules lack a source tiddler, typically because they were setup during the boot process.
|
||||
Advanced/Settings/Caption: Settings
|
||||
Advanced/Settings/Hint: These advanced settings let you customise the behaviour of TiddlyWiki.
|
||||
Advanced/Settings/NavigationAddressBar/Caption: Navigation Address Bar
|
||||
Advanced/Settings/NavigationAddressBar/Hint: Behaviour of the browser address bar when navigating to a tiddler:
|
||||
Advanced/Settings/NavigationAddressBar/No/Description: Do not update the address bar
|
||||
Advanced/Settings/NavigationAddressBar/Permalink/Description: Include the target tiddler
|
||||
Advanced/Settings/NavigationAddressBar/Permaview/Description: Include the target tiddler and the current story sequence
|
||||
Advanced/Settings/NavigationHistory/Caption: Navigation History
|
||||
Advanced/Settings/NavigationHistory/Hint: Update browser history when navigating to a tiddler:
|
||||
Advanced/Settings/NavigationHistory/No/Description: Do not update history
|
||||
Advanced/Settings/NavigationHistory/Yes/Description: Update history
|
||||
Advanced/TiddlerFields/Caption: Tiddler Fields
|
||||
Advanced/TiddlerFields/Hint: This is the full set of TiddlerFields in use in this wiki (including system tiddlers but excluding shadow tiddlers).
|
||||
Appearance/Caption: Appearance
|
||||
|
@ -24,6 +24,10 @@ var DEFAULT_HISTORY_TITLE = "$:/HistoryList";
|
||||
// Default tiddlers
|
||||
var DEFAULT_TIDDLERS_TITLE = "$:/DefaultTiddlers";
|
||||
|
||||
// Config
|
||||
var CONFIG_UPDATE_ADDRESS_BAR = "$:/config/Navigation/UpdateAddressBar"; // Can be "no", "permalink", "permaview"
|
||||
var CONFIG_UPDATE_HISTORY = "$:/config/Navigation/UpdateHistory"; // Can be "yes" or "no"
|
||||
|
||||
exports.startup = function() {
|
||||
// Open startup tiddlers
|
||||
openStartupTiddlers();
|
||||
@ -97,6 +101,8 @@ function openStartupTiddlers(options) {
|
||||
}
|
||||
|
||||
function updateLocationHash() {
|
||||
var updateAddressBar = $tw.wiki.getTiddlerText(CONFIG_UPDATE_ADDRESS_BAR,"permaview").trim();
|
||||
if(updateAddressBar !== "no") {
|
||||
// Get the story and the history stack
|
||||
var storyList = $tw.wiki.getTiddlerList(DEFAULT_STORY_TITLE),
|
||||
historyList = $tw.wiki.getTiddlerData(DEFAULT_HISTORY_TITLE,[]);
|
||||
@ -110,12 +116,22 @@ function updateLocationHash() {
|
||||
targetTiddler = "";
|
||||
}
|
||||
// Assemble the location hash
|
||||
if(updateAddressBar === "permalink") {
|
||||
$tw.locationHash = "#" + encodeURIComponent(targetTiddler)
|
||||
} else {
|
||||
$tw.locationHash = "#" + encodeURIComponent(targetTiddler) + ":" + encodeURIComponent($tw.utils.stringifyList(storyList));
|
||||
}
|
||||
// Only change the location hash if we must, thus avoiding unnecessary onhashchange events
|
||||
if($tw.utils.getLocationHash() !== $tw.locationHash) {
|
||||
if($tw.wiki.getTiddlerText(CONFIG_UPDATE_HISTORY,"no").trim() === "yes") {
|
||||
// Assign the location hash so that history is updated
|
||||
window.location.hash = $tw.locationHash;
|
||||
} else {
|
||||
// We use replace so that browser history isn't affected
|
||||
window.location.replace(window.location.toString().split("#")[0] + $tw.locationHash);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
19
core/ui/ControlPanel/Advanced/Settings.tid
Normal file
19
core/ui/ControlPanel/Advanced/Settings.tid
Normal file
@ -0,0 +1,19 @@
|
||||
title: $:/core/ui/ControlPanel/Advanced/Settings
|
||||
tags: $:/tags/ControlPanel/Advanced
|
||||
caption: {{$:/language/ControlPanel/Advanced/Settings/Caption}}
|
||||
|
||||
\define lingo-base() $:/language/ControlPanel/Advanced/Settings/
|
||||
|
||||
<<lingo Hint>>
|
||||
|
||||
<$list filter="[all[shadows+tiddlers]tag[$:/tags/ControlPanel/Advanced/Settings]]">
|
||||
|
||||
<div style="border-top:1px solid #eee;">
|
||||
|
||||
!! <$link><$transclude field="caption"/></$link>
|
||||
|
||||
<$transclude/>
|
||||
|
||||
</div>
|
||||
|
||||
</$list>
|
@ -0,0 +1,34 @@
|
||||
title: $:/core/ui/ControlPanel/Advanced/Settings/NavigationAddressBar
|
||||
tags: $:/tags/ControlPanel/Advanced/Settings
|
||||
caption: {{$:/language/ControlPanel/Advanced/Settings/NavigationAddressBar/Caption}}
|
||||
|
||||
\define lingo-base() $:/language/ControlPanel/Advanced/Settings/NavigationAddressBar/
|
||||
<<lingo Hint>>
|
||||
<div style="position:relative;">
|
||||
<$button popup=<<qualify "$:/state/navaddressbarpopup">> class="btn-invisible btn-dropdown">
|
||||
<$view tiddler="$:/config/Navigation/UpdateAddressBar" field="text"/>:
|
||||
<$reveal state="$:/config/Navigation/UpdateAddressBar" type="match" text="no">
|
||||
''<<lingo No/Description>>''
|
||||
</$reveal>
|
||||
<$reveal state="$:/config/Navigation/UpdateAddressBar" type="match" text="permalink">
|
||||
''<<lingo Permalink/Description>>''
|
||||
</$reveal>
|
||||
<$reveal state="$:/config/Navigation/UpdateAddressBar" type="match" text="permaview">
|
||||
''<<lingo Permaview/Description>>''
|
||||
</$reveal>
|
||||
{{$:/core/images/down-arrow}}
|
||||
</$button>
|
||||
<div class="tw-block-dropdown-wrapper">
|
||||
<$reveal state=<<qualify "$:/state/navaddressbarpopup">> type="popup" position="below" animate="yes" default="">
|
||||
<$linkcatcher to="$:/config/Navigation/UpdateAddressBar">
|
||||
<div class="tw-block-dropdown tw-edit-type-dropdown">
|
||||
<$list filter="no permalink permaview">
|
||||
<$link to={{!!title}}>
|
||||
<$view field="title"/>
|
||||
</$link>
|
||||
</$list>
|
||||
</div>
|
||||
</$linkcatcher>
|
||||
</$reveal>
|
||||
</div>
|
||||
</div>
|
31
core/ui/ControlPanel/Advanced/Settings/NavigationHistory.tid
Normal file
31
core/ui/ControlPanel/Advanced/Settings/NavigationHistory.tid
Normal file
@ -0,0 +1,31 @@
|
||||
title: $:/core/ui/ControlPanel/Advanced/Settings/NavigationHistory
|
||||
tags: $:/tags/ControlPanel/Advanced/Settings
|
||||
caption: {{$:/language/ControlPanel/Advanced/Settings/NavigationHistory/Caption}}
|
||||
|
||||
\define lingo-base() $:/language/ControlPanel/Advanced/Settings/NavigationHistory/
|
||||
<<lingo Hint>>
|
||||
<div style="position:relative;">
|
||||
<$button popup=<<qualify "$:/state/navhistorypopup">> class="btn-invisible btn-dropdown">
|
||||
<$view tiddler="$:/config/Navigation/UpdateHistory" field="text"/>:
|
||||
<$reveal state="$:/config/Navigation/UpdateHistory" type="match" text="no">
|
||||
''<<lingo No/Description>>''
|
||||
</$reveal>
|
||||
<$reveal state="$:/config/Navigation/UpdateHistory" type="match" text="yes">
|
||||
''<<lingo Yes/Description>>''
|
||||
</$reveal>
|
||||
{{$:/core/images/down-arrow}}
|
||||
</$button>
|
||||
<div class="tw-block-dropdown-wrapper">
|
||||
<$reveal state=<<qualify "$:/state/navhistorypopup">> type="popup" position="below" animate="yes" default="">
|
||||
<$linkcatcher to="$:/config/Navigation/UpdateHistory">
|
||||
<div class="tw-block-dropdown tw-edit-type-dropdown">
|
||||
<$list filter="no yes">
|
||||
<$link to={{!!title}}>
|
||||
<$view field="title"/>
|
||||
</$link>
|
||||
</$list>
|
||||
</div>
|
||||
</$linkcatcher>
|
||||
</$reveal>
|
||||
</div>
|
||||
</div>
|
2
core/wiki/config/NavigationUpdateAddressBar.tid
Normal file
2
core/wiki/config/NavigationUpdateAddressBar.tid
Normal file
@ -0,0 +1,2 @@
|
||||
title: $:/config/Navigation/UpdateAddressBar
|
||||
text: permaview
|
2
core/wiki/config/NavigationUpdateHistory.tid
Normal file
2
core/wiki/config/NavigationUpdateHistory.tid
Normal file
@ -0,0 +1,2 @@
|
||||
title: $:/config/Navigation/UpdateHistory
|
||||
text: no
|
Loading…
Reference in New Issue
Block a user