1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-01-22 10:54:46 +00:00

Compare commits

...

33 Commits

Author SHA1 Message Date
Jeremy Ruston
9d9b00bdb5 Merge branch 'master' into single-tiddler-mode 2020-04-02 11:45:01 +01:00
Jeremy Ruston
b88bfda0b4 Merge branch 'master' into single-tiddler-mode 2020-01-20 13:15:39 +00:00
Jeremy Ruston
834610cdb9 Restore single tiddler mode handling for zoomin
Thus avoiding the problem that performance slows after browsing many tiddlers in zoomin mode.
2020-01-20 08:34:18 +00:00
Jeremy Ruston
5272b13af1 Revert zoomin to old behaviour
Otherwise we break the animations
2020-01-18 10:36:33 +00:00
Jeremy Ruston
5f25b21c0d Introduce new "solo" storyview
It's a single tiddler view with no animation, hopefully more suitable for things like @kookma's presentation plugin.
2020-01-18 10:36:10 +00:00
Jeremy Ruston
f256b7791d Merge branch 'master' into single-tiddler-mode 2020-01-17 13:06:07 +00:00
Jeremy Ruston
66fc63ed7f Revert "Merge branch 'master' into single-tiddler-mode"
This reverts commit f703330962.
2020-01-17 13:01:39 +00:00
Jeremy Ruston
f703330962 Merge branch 'master' into single-tiddler-mode 2020-01-17 12:54:51 +00:00
Jermolene
0ea4bfe99f Merge branch 'master' into single-tiddler-mode 2018-10-04 20:40:42 +01:00
Jermolene
7f99b8c32e Merge branch 'master' into single-tiddler-mode 2018-10-02 14:19:22 +01:00
Jermolene
95111db7ee Merge branch 'master' into single-tiddler-mode 2018-09-28 18:32:07 +01:00
Jermolene
5e148c1d26 Merge branch 'master' into single-tiddler-mode 2018-09-27 11:51:56 +01:00
Jermolene
1ff40c6b22 Merge branch 'master' into single-tiddler-mode 2018-09-27 10:12:09 +01:00
Jermolene
a0084eee9a Merge branch 'master' into single-tiddler-mode 2018-09-27 09:48:12 +01:00
Jermolene
55740fbfaf Merge branch 'master' into single-tiddler-mode 2018-09-21 10:56:43 +01:00
Jermolene
226a635c5c Merge branch 'master' into single-tiddler-mode 2018-09-13 20:42:52 +01:00
Jermolene
a5dca25078 Merge branch 'master' into single-tiddler-mode 2018-09-05 09:27:52 +01:00
Jermolene
a15a711d4a Merge branch 'master' into single-tiddler-mode 2018-09-01 13:19:40 +01:00
Jermolene
9bc8cbfe98 Refactor getstoryviewsingletiddlermode operator into getstoryviewmode
Thanks @pmario
2018-08-31 13:00:30 +01:00
Jermolene
f8b81616fb Merge branch 'master' into single-tiddler-mode 2018-08-31 09:59:46 +01:00
Jermolene
b7611e23b4 Improve prerelease notes 2018-08-30 14:06:31 +01:00
Jermolene
eacbb928e9 Merge branch 'master' into single-tiddler-mode 2018-08-30 14:00:59 +01:00
Jermolene
04d6677949 Temporarily default to Zoomin view, and make the switcher more accessible 2018-08-30 12:39:36 +01:00
Jermolene
ee25af758e Make "Open" tab mutate into "History" tab when in STM
Instead of introducing a new "History" tab to the sidebar we make the existing "Open" tab mutate into a "History" tab when in Single Tiddler Mode.
2018-08-30 12:38:13 +01:00
Jermolene
33aa37f7dc Merge branch 'master' into single-tiddler-mode 2018-08-29 19:03:50 +01:00
Jermolene
0d40b691e7 Make "close tiddler" button in STM go back to the previous tiddler in the history stack 2018-08-27 18:12:54 +01:00
Jermolene
81fda40486 Make single tiddler mode status available in tv-storyview-single-tiddler-mode 2018-08-27 12:19:28 +01:00
Jermolene
7a50edb56d Refactor navigator attribute handling
And fix a bug whereby we weren't refreshing when some attributes changed
2018-08-26 23:57:17 +01:00
Jermolene
f76e3f5d41 Update release note 2018-08-26 17:04:42 +01:00
Jermolene
9f2ce65a71 Merge branch 'master' into single-tiddler-mode 2018-08-26 16:49:17 +01:00
Jermolene
9a77ec4591 Docs update 2018-08-26 15:43:40 +01:00
Jermolene
8625d6cd01 Add "History" sidebar tab
Much more useful than the "open" tab when in single tiddler mode
2018-08-26 15:43:32 +01:00
Jermolene
aba835fb74 Basics of single tiddler mode
* Storyviews expose a static "singleTiddlerMode" property to determine if they require single tiddler mode
* Navigator widget adds a "singleTiddlerMode" attribute; when set to "yes", the story list is entirely replaced during navigation
* Navigator widget now updates "list" field of $:/HistoryList with a more accessible version of the history list
* Add a getstoryviewsingletiddlermode[] operator so that we can obtain the story view STM status for passing to the navigator widget
2018-08-26 15:43:06 +01:00
13 changed files with 196 additions and 58 deletions

View File

@@ -0,0 +1,4 @@
title: $:/core/images/storyview-solo
tags: $:/tags/Image
<svg width="22pt" height="22pt" class="tc-image-storyview-single tc-image-button" viewBox="0 0 128 128"><path fill-rule="evenodd" d="M8.007 0A8.01 8.01 0 000 8.007v111.986A8.01 8.01 0 008.007 128h111.986a8.01 8.01 0 008.007-8.007V8.007A8.01 8.01 0 00119.993 0H8.007zm15.992 16A8 8 0 0016 24.009V71.99C16 76.414 19.588 80 24 80h80a8 8 0 008-8.009V24.01c0-4.423-3.588-8.009-8-8.009H24z"/></svg>

View File

@@ -4,6 +4,7 @@ All/Caption: All
Contents/Caption: Contents
Drafts/Caption: Drafts
Explorer/Caption: Explorer
History/Caption: History
Missing/Caption: Missing
More/Caption: More
Open/Caption: Open

View File

@@ -0,0 +1,38 @@
/*\
title: $:/core/modules/filters/getstoryviewmode.js
type: application/javascript
module-type: filteroperator
Filter operator for retrieving modes from a storyview. Only "singletiddlermode" is implemented at present
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter functions
*/
exports.getstoryviewmode = function(source,operator,options) {
// Initialise the storyviews if they've not been done already
var storyviews = {};
$tw.modules.applyMethods("storyview",storyviews);
if(operator.operand !== "singletiddlermode") {
return [];
}
var results = [];
source(function(tiddler,title) {
var storyview = storyviews[title];
if(storyview && storyview.singleTiddlerMode) {
results.push("yes");
} else {
results.push("no");
}
});
return results;
};
})();

View File

@@ -37,44 +37,48 @@ Story.prototype.getStoryList = function() {
Story.prototype.addToStory = function(navigateTo,navigateFromTitle,options) {
options = options || {};
var storyList = this.getStoryList();
// See if the tiddler is already there
var slot = storyList.indexOf(navigateTo);
// Quit if it already exists in the story river
if(slot >= 0) {
return;
}
// First we try to find the position of the story element we navigated from
var fromIndex = storyList.indexOf(navigateFromTitle);
if(fromIndex >= 0) {
// The tiddler is added from inside the river
// Determine where to insert the tiddler; Fallback is "below"
switch(options.openLinkFromInsideRiver) {
case "top":
slot = 0;
break;
case "bottom":
slot = storyList.length;
break;
case "above":
slot = fromIndex;
break;
case "below": // Intentional fall-through
default:
slot = fromIndex + 1;
break;
}
if(options.singleTiddlerMode) {
storyList = [navigateTo];
} else {
// The tiddler is opened from outside the river. Determine where to insert the tiddler; default is "top"
if(options.openLinkFromOutsideRiver === "bottom") {
// Insert at bottom
slot = storyList.length;
} else {
// Insert at top
slot = 0;
// See if the tiddler is already there
var slot = storyList.indexOf(navigateTo);
// Quit if it already exists in the story river
if(slot >= 0) {
return;
}
// First we try to find the position of the story element we navigated from
var fromIndex = storyList.indexOf(navigateFromTitle);
if(fromIndex >= 0) {
// The tiddler is added from inside the river
// Determine where to insert the tiddler; Fallback is "below"
switch(options.openLinkFromInsideRiver) {
case "top":
slot = 0;
break;
case "bottom":
slot = storyList.length;
break;
case "above":
slot = fromIndex;
break;
case "below": // Intentional fall-through
default:
slot = fromIndex + 1;
break;
}
} else {
// The tiddler is opened from outside the river. Determine where to insert the tiddler; default is "top"
if(options.openLinkFromOutsideRiver === "bottom") {
// Insert at bottom
slot = storyList.length;
} else {
// Insert at top
slot = 0;
}
}
// Add the tiddler
storyList.splice(slot,0,navigateTo);
}
// Add the tiddler
storyList.splice(slot,0,navigateTo);
// Save the story
this.saveStoryList(storyList);
};
@@ -93,11 +97,20 @@ Story.prototype.saveStoryList = function(storyList) {
Story.prototype.addToHistory = function(navigateTo,navigateFromClientRect) {
var titles = $tw.utils.isArray(navigateTo) ? navigateTo : [navigateTo];
// Add a new record to the top of the history stack
var historyList = this.wiki.getTiddlerData(this.historyTitle,[]);
var historyList = this.wiki.getTiddlerData(this.historyTitle,[]),
historyTitles = this.wiki.getTiddlerList(this.historyTitle);
$tw.utils.each(titles,function(title) {
historyList.push({title: title, fromPageRect: navigateFromClientRect});
var p;
do {
p = historyTitles.indexOf(title);
if(p !== -1) {
historyTitles.splice(p,1);
}
} while(p !== -1);
historyTitles.unshift(title);
});
this.wiki.setTiddlerData(this.historyTitle,historyList,{"current-tiddler": titles[titles.length-1]});
this.wiki.setTiddlerData(this.historyTitle,historyList,{"current-tiddler": titles[titles.length-1], list: historyTitles});
};
Story.prototype.storyCloseTiddler = function(targetTitle) {

View File

@@ -0,0 +1,23 @@
/*\
title: $:/core/modules/storyviews/solo.js
type: application/javascript
module-type: storyview
Flip between individual tiddlers
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var SoloListView = function(listWidget) {
};
// Engage single tiddler mode
SoloListView.singleTiddlerMode = true;
exports.solo = SoloListView;
})();

View File

@@ -39,6 +39,9 @@ var ZoominListView = function(listWidget) {
});
};
// Engage single tiddler mode
ZoominListView.singleTiddlerMode = true;
ZoominListView.prototype.navigateTo = function(historyInfo) {
var duration = $tw.utils.getAnimationDuration(),
listElementIndex = this.listWidget.findListItem(0,historyInfo.title);

View File

@@ -60,6 +60,10 @@ NavigatorWidget.prototype.execute = function() {
// Get our parameters
this.storyTitle = this.getAttribute("story");
this.historyTitle = this.getAttribute("history");
this.openLinkFromInsideRiver = this.getAttribute("openLinkFromInsideRiver","top");
this.openLinkFromOutsideRiver = this.getAttribute("openLinkFromOutsideRiver","top");
this.singleTiddlerMode = this.getAttribute("singleTiddlerMode","no") === "yes";
this.relinkOnRename = this.getAttribute("relinkOnRename","no").toLowerCase().trim() === "yes";
this.setVariable("tv-story-list",this.storyTitle);
this.setVariable("tv-history-list",this.historyTitle);
// Construct the child widgets
@@ -71,7 +75,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
*/
NavigatorWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes.story || changedAttributes.history) {
if(changedAttributes.story || changedAttributes.history || changedAttributes.openLinkFromInsideRiver || changedAttributes.openLinkFromOutsideRiver || changedAttributes.singleTiddlerMode || changedAttributes.relinkOnRename) {
this.refreshSelf();
return true;
} else {
@@ -122,12 +126,17 @@ NavigatorWidget.prototype.replaceFirstTitleInStory = function(storyList,oldTitle
};
NavigatorWidget.prototype.addToStory = function(title,fromTitle) {
if(this.storyTitle) {
this.wiki.addToStory(title,fromTitle,this.storyTitle,{
openLinkFromInsideRiver: this.getAttribute("openLinkFromInsideRiver","top"),
openLinkFromOutsideRiver: this.getAttribute("openLinkFromOutsideRiver","top")
});
}
this.wiki.addToStory(title,fromTitle,this.storyTitle,{
openLinkFromInsideRiver: this.openLinkFromInsideRiver,
openLinkFromOutsideRiver: this.openLinkFromOutsideRiver,
singleTiddlerMode: this.singleTiddlerMode
});
};
NavigatorWidget.prototype.removeFromStory = function(title) {
var storyList = this.getStoryList();
this.removeTitleFromStory(storyList,title);
this.saveStoryList(storyList);
};
/*
@@ -155,11 +164,34 @@ NavigatorWidget.prototype.handleNavigateEvent = function(event) {
// Close a specified tiddler
NavigatorWidget.prototype.handleCloseTiddlerEvent = function(event) {
var title = event.param || event.tiddlerTitle,
storyList = this.getStoryList();
// Look for tiddlers with this title to close
this.removeTitleFromStory(storyList,title);
this.saveStoryList(storyList);
var title = event.param || event.tiddlerTitle;
if(this.singleTiddlerMode) {
// Get the history stack and find the topmost occurance of the current tiddler
var history = this.wiki.getTiddlerDataCached(this.historyTitle,[]),
currPos = history.findIndex(function(historyRecord) {
return historyRecord.title === title;
}),
newTitle;
// Skip over any duplicates
while(currPos > 0 && history[currPos - 1].title === title) {
currPos--;
}
// Get the new title
if(currPos > 0) {
newTitle = history[currPos - 1].title;
}
// Navigate to the new title if we've got one
if(newTitle) {
this.addToStory(newTitle);
this.addToHistory(newTitle);
} else {
// If there's nothing to navigate back to then we really do close the last tiddler
this.removeFromStory(title);
}
} else {
// Look for tiddlers with this title to close
this.removeFromStory(title);
}
return false;
};
@@ -323,8 +355,7 @@ NavigatorWidget.prototype.handleSaveTiddlerEvent = function(event) {
newTiddler = $tw.hooks.invokeHook("th-saving-tiddler",newTiddler);
this.wiki.addTiddler(newTiddler);
// If enabled, relink references to renamed tiddler
var shouldRelink = this.getAttribute("relinkOnRename","no").toLowerCase().trim() === "yes";
if(isRename && shouldRelink && this.wiki.tiddlerExists(draftOf)) {
if(isRename && this.relinkOnRename && this.wiki.tiddlerExists(draftOf)) {
console.log("Relinking '" + draftOf + "' to '" + draftTitle + "'");
this.wiki.relinkTiddler(draftOf,draftTitle);
}

View File

@@ -20,7 +20,7 @@ tc-page-container tc-page-view-$(storyviewTitle)$ tc-language-$(languageTitle)$
<div class=<<containerClasses>>>
<$navigator story="$:/StoryList" history="$:/HistoryList">
<$navigator story="$:/StoryList" history="$:/HistoryList" singleTiddlerMode={{{ [<storyviewTitle>getstoryviewmode[singletiddlermode]] }}}>
<$transclude mode="block"/>

View File

@@ -18,11 +18,13 @@ tc-page-container tc-page-view-$(storyviewTitle)$ tc-language-$(languageTitle)$
<$set name="storyviewTitle" value={{$:/view}}>
<$set name="tv-storyview-single-tiddler-mode" value={{{ [<storyviewTitle>getstoryviewmode[singletiddlermode]] }}}>
<$set name="languageTitle" value={{{ [{$:/language}get[name]] }}}>
<div class=<<containerClasses>>>
<$navigator story="$:/StoryList" history="$:/HistoryList" openLinkFromInsideRiver={{$:/config/Navigation/openLinkFromInsideRiver}} openLinkFromOutsideRiver={{$:/config/Navigation/openLinkFromOutsideRiver}} relinkOnRename={{$:/config/RelinkOnRename}}>
<$navigator story="$:/StoryList" history="$:/HistoryList" singleTiddlerMode=<<tv-storyview-single-tiddler-mode>> openLinkFromInsideRiver={{$:/config/Navigation/openLinkFromInsideRiver}} openLinkFromOutsideRiver={{$:/config/Navigation/openLinkFromOutsideRiver}} relinkOnRename={{$:/config/RelinkOnRename}}>
<$dropzone enable=<<tv-enable-drag-and-drop>>>

View File

@@ -1,6 +1,6 @@
title: $:/core/ui/SideBar/Open
tags: $:/tags/SideBar
caption: {{$:/language/SideBar/Open/Caption}}
caption: <$list filter="[<tv-storyview-single-tiddler-mode>prefix[yes]]" emptyMessage="{{$:/language/SideBar/Open/Caption}}">{{$:/language/SideBar/History/Caption}}</$list>
\whitespace trim
\define lingo-base() $:/language/CloseAll/
@@ -23,6 +23,7 @@ $button$
</$droppable>
\end
\define open()
<div class="tc-sidebar-tab-open">
<$list filter="[list<tv-story-list>]" history=<<tv-history-list>> storyview="pop">
<div class="tc-sidebar-tab-open-item">
@@ -34,4 +35,8 @@ $button$
<$macrocall $name="droppable-item" button="""<$button message="tm-close-all-tiddlers" class="tc-btn-invisible tc-btn-mini"><<lingo Button>></$button>"""/>
</div>
</$tiddler>
</div>
\end
<$list filter="[<tv-storyview-single-tiddler-mode>prefix[yes]]" emptyMessage=<<open>>>
<$list filter="[list[$:/HistoryList]limit[100]]" template="$:/core/ui/ListItemTemplate"/>
</$list>

View File

@@ -1,6 +1,25 @@
title: TiddlyWiki Pre-release
modified: 20150428204930183
!! Experimental Single Tiddler Mode
This build of the TiddlyWiki Pre-release is built from the "single-tiddler-mode" branch, and incorporates the work in progress from this pull request:
https://github.com/Jermolene/TiddlyWiki5/pull/3412
Essentially, "Single Tiddler Mode" means that the ''zoomin'' storyview no longer keeps previously navigated tiddlers hidden but open. Instead, there is only ever one tiddler open in the story river.
This has some implications for familiar TiddlyWiki features:
* The "close" button now navigates to the previous tiddler in the history stack
* The "open" tab in the sidebar mutates into a more useful new "history" tab when "single tiddler mode" is engaged
You can switch storyviews here to experiment with the effect:
{{$:/snippets/viewswitcher}}
---
This is a pre-release build of TiddlyWiki, [[also available in empty form|https://tiddlywiki.com/prerelease/empty.html]]. It is provided for testing purposes. ''Please don't try to use it for anything important'' -- you should use the latest official release from https://tiddlywiki.com.
<$list filter="[tag[ReleaseNotes]!has[released]!sort[created]]">

View File

@@ -1,3 +1,3 @@
title: $:/view
classic
solo

View File

@@ -11,7 +11,7 @@ TiddlyWiki ships with defaults that are designed to get the best out of modern d
* ''Avoid the "Recent" tab''. It is computationally slow to generate and update in response to tiddler changes.
* ''Use the "Vanilla" theme''. The default "Snow White" theme includes visual effects like shadows, transparency and blurring that can be slow to render on older devices
* ''Avoid large tiddlers''. Large bitmaps can significantly slow TiddlyWiki's performance. For example, an image taken with a modern smartphone will often be 5MB or more. Use ExternalImages whenever possible
* ''Don't have too many tiddlers open at once''. Every tiddler you have open will require processing to keep it up to date as the store changes (for example, while you type into a draft tiddler). It is particularly easy when using zoomin story view to end up with dozens of tiddlers listed in the ''Open'' tab in the sidebar. Get into the habit of periodically closing all open tiddlers with the <<.icon $:/core/images/close-all-button>> ''close all'' button
* ''Don't have too many tiddlers open at once''. Every tiddler you have open will require processing to keep it up to date as the store changes (for example, while you type into a draft tiddler). It is easy to end up with dozens of tiddlers listed in the ''Open'' tab in the sidebar. Get into the habit of periodically closing all open tiddlers with the {{$:/core/images/close-all-button}} ''close all'' button, or use zoomin story view which only keeps one tiddler open at a time.
!! WikiText
@@ -28,4 +28,3 @@ TiddlyWiki ships with defaults that are designed to get the best out of modern d
** Note that the field indexer currently defaults to indexing field values of less than 128 characters; longer values can still be searched for, but no index will be constructed
** Also note that the “field” operator is also used when the operator name is a fieldname, so, for example, `[all[shadows+tiddlers]caption[x]...` is optimised.
* Use the [[throttling|RefreshThrottling]] feature of the RefreshMechanism judiciously