Smart TOC and Outlining - Authoring with Tiddlywiki: One step forward

667 views
Skip to first unread message

Mohammad

unread,
Jan 25, 2020, 6:26:21 AM1/25/20
to tiddl...@googlegroups.com
Recently Eric Shulman shared a very impressive tool which can be used for authoring!
It can create an outliner, a feature (outlining) quite necessary in long writings like novels, theses, project reports,... 

It is a smart designed Table of Contents (TOC) generator.


It not only generates a flexible table of content, but also generates its TOC as an outliner.

With the outliner, you can see in a single glance the overall status of your contents (book, report, ...). See how contents (sections, chapters, ...) are organised. See which character appear in which scene. Quickly rearrange things. Write notes for each item as you keep the big picture in view [1]

It is possible to drag'n drop a tiddler title from the river into the TOC (outliner) [2]
It uses $:/HistoryList!!currenttiddler to highlight the most recently opened tiddler [3].
It can exclude items and multiple branches in the TOC [4]
It can switch between author mode and reader mode (in reader mode one cannot edit the TOC) [3].
It uses a local window on hover lets you create new item and new branch
and much more ...


I think this is an essential tool for authors and put Tiddlywiki in comparison with other wiki/web tool one step forward.

Best
Mohammad



Mohammad

unread,
Jan 25, 2020, 6:34:45 AM1/25/20
to TiddlyWiki
More info on outlining:

--Mohammad


On Saturday, January 25, 2020 at 2:56:21 PM UTC+3:30, Mohammad wrote:
Recently Eric Shulman shared a very impressive tool which can be used for authoring!
It can create an outliner, a feature (outlining) quite necessary in long writings like novels, theses, project reports,... 

It is a smart designed Table of Contents (TOC) generator.


It not only generates a flexible table of content, but also generate its TOC as an outliner.

Eric Shulman

unread,
Jan 25, 2020, 7:14:39 AM1/25/20
to TiddlyWiki
On Saturday, January 25, 2020 at 3:26:21 AM UTC-8, Mohammad wrote:
Recently Eric Shulman shared a very impressive tool which can be used for authoring!
It can create an outliner, a feature (outlining) quite necessary in long writings like novels, theses, project reports,... 
It is a smart designed Table of Contents (TOC) generator.
and much more ...


* <<toc-list>> (defined in TiddlyTools/TOC/Macros) is a VERY simple recursion, that returns the entire TOC contents as a simple list of tiddlers
\define toc-list(here,exclude)
<$list filter="""[title[$here$]tagging[]] $exclude$ -[[$here$]]""">
   
<$link/><br>
   
<$macrocall $name="toc-list" here=<<currentTiddler>> exclude="""$exclude$ -[[$here$]]"""/>
</$list>
\end

* TiddlyTools/NavBar/Bottom is a ViewTemplate addition that uses the <<toc-list>> output to present next/previous buttons to provide a "sequential reader" interface that lets you step through all the TOC items, one at a time.

enjoy,
-e






TiddlyTweeter

unread,
Jan 25, 2020, 9:50:16 AM1/25/20
to TiddlyWiki
Very interesting thread!

Something I find missing though is thought on limits.

As far as I grasp it David wrote TiddlyWiki Toolmap in Dynalist because it was easiest in it. 
At over 600 entries it is well worth noting his AUTHOR experience. 

Emulate that and you'd be on a winner :-).

But I don't see why TW should be perfect at everything.

To ME the issue here is not ONLY about emulating "authoring" in a favorite tool per se. 
Rather, it is about much more about  getting stuff INTO TW.

Who cares where or how stuff is authored? Surely it is the final product that matters?

What is the issue? ... David's ToolMap illustrates it well. It has a pretty simple OPML export format. 
Yet we don't do the obvious and just devise an importer!

My point? WRITE in what is easiest. PUBLISH through TW which is about the most flexible tool around for organisation and search. 

Good as it is, TiddlyToolmap would be a MUCH more useful resource in TW.

Just "left field" thoughts
TT

Mark S.

unread,
Jan 25, 2020, 10:29:43 AM1/25/20
to TiddlyWiki


On Saturday, January 25, 2020 at 6:50:16 AM UTC-8, TiddlyTweeter wrote:

My point? WRITE in what is easiest. PUBLISH through TW which is about the most flexible tool around for organisation and search. 

Good as it is, TiddlyToolmap would be a MUCH more useful resource in TW.



What would TW bring to the table, for this particular application? You can search it, view it, toggle sections, filter by tags, etc. (except there are none -- but there could be if desired).

That conversion step between writing and publishing would get tedious, whereas it's instantaneous in TiddlyToolmap.

Mohammad

unread,
Jan 25, 2020, 10:42:42 AM1/25/20
to TiddlyWiki
Eric,
 Thanks for this step through addition!
It seems it does not work with tiddler with space in the title!

--Mohammad

Mohammad

unread,
Jan 25, 2020, 2:08:30 PM1/25/20
to TiddlyWiki
Eric,
 I changed toc-list as below

\define toc-list(here,exclude)
<$list filter="""[title[$here$]tagging[]] $exclude$ -[[$here$]]""">

   
<$text text="[["/><<currentTiddler>><$text text="]]"/>

   <$macrocall $name="toc-list" here=<<currentTiddler>> exclude="""$exclude$ -[[$here$]]"""/>
</$list>
\end

It seems now it handles tiddlers with space in their title.

Please have a look and confirm if this is the right solution!

--Mohammad




On Saturday, January 25, 2020 at 3:44:39 PM UTC+3:30, Eric Shulman wrote:

Eric Shulman

unread,
Jan 25, 2020, 2:37:47 PM1/25/20
to TiddlyWiki
On Saturday, January 25, 2020 at 11:08:30 AM UTC-8, Mohammad wrote:
 I changed toc-list as below
\define toc-list(here,exclude)
<$list filter="""[title[$here$]tagging[]] $exclude$ -[[$here$]]""">
   
<$text text="[["/><<currentTiddler>><$text text="]]"/>
   <$macrocall $name="toc-list" here=<<currentTiddler>> exclude="""$exclude$ -[[$here$]]"""/>
</$list>
\end
It seems now it handles tiddlers with space in their title.
Please have a look and confirm if this is the right solution!

I was thinking of the exact same solution... you just beat me to it!  Again... Great work!!!


-e


Mohammad

unread,
Jan 25, 2020, 2:47:53 PM1/25/20
to TiddlyWiki
Thanks Eric,
:-)
 

Thank you!

One more question
By default  TiddlyBook uses "sequential reader" interface that lets one steps through all the TOC items or all tiddlers.
How one can have this interface on those tiddlers only existed in TOC not all tiddlers?

I thought to add a third tag like book, but I think a better solution can be suggested.


-e



-- Mohammad 

Eric Shulman

unread,
Jan 25, 2020, 3:59:14 PM1/25/20
to TiddlyWiki
On Saturday, January 25, 2020 at 11:47:53 AM UTC-8, Mohammad wrote:
By default  TiddlyBook uses "sequential reader" interface that lets one steps through all the TOC items or all tiddlers.
How one can have this interface on those tiddlers only existed in TOC not all tiddlers?

By default, if you are viewing a tiddler that is not in the <<toc-list>>, TiddlyBook/NavBar/Bottom shows links to the first <<toc-list>> item.  I find this convenient when working on TiddlyBook internals, as it gives me an easy way to get back to the CoverPage for quick testing of changes.  However, I can understand why it might also be desirable to suppress that default handling when TiddlyBook/NavBar/Bottom is used in other documents.

To enable suppression of the default handling, I've changed the code to use $list instead of $tiddler when showing the the link/button output:
<$list filter="[<currentTiddler>!tag[bookcover]!is[system]]">
   
<div class="hideForPrint">
      @@.floatleft  {{TiddlyBook/Popups/Chapters}}  @@
      @@.floatright {{TiddlyBook/Popups/Appendix}} @@
     
<div style="text-align:center;white-space:nowrap">
         <$wikify name="all" text="""<$macrocall $name="toc-list" here={{TiddlyBook/RootTag}} />""">
         <$vars first={{{ [enlist
<all>first[]] }}}>
         <$vars  prev={{{ [enlist
<all>before<currentTiddler>] ~[<first>] }}}>
         <$vars  next={{{ [enlist
<all>after<currentTiddler>]  ~[<first>] }}}>
         <$list filter=<
<prev>>>
           
<span class="tt-navbar-button">
               <$link tooltip=<
<toc-caption>>>{{$:/core/images/chevron-left}}</$link>
           
</span>
         </$list>
         <$list filter=<
<next>>>
           
<div style="display:inline-block;">
               @@.smaller ''//next topic://''
<br>@@
               @@.largest <$link>''<
<toc-caption>>''</$link>@@
           
</div>
           
<span class="tt-navbar-button">
               <$link tooltip=<
<toc-caption>>>{{$:/core/images/chevron-right}}</$link>
           
</span>
         </$list>
         </$vars>
         </$vars>
         </$vars>
         </$wikify>
     
</div>
      @@.clear @@
   
</div>
</$list>

This, in itself, does NOT change the default behavior... but, it does allow you quickly tweak ONE LINE in the code to achieve the result you want.  Simply change this:
<$vars first={{{ [enlist<all>first[]] }}}>
to this:
<$vars NO_first={{{ [enlist<all>first[]] }}}>
The effect is that there is no longer a fallback default when calculating the "prev" and "next" values... and, since the code now uses $list instead of $tiddler, no output is produced when the current tiddler is not in the <<toc-list>>

Q.E.D.


Give it a try and let me know how it goes.

-e

Mohammad

unread,
Jan 26, 2020, 2:02:00 AM1/26/20
to TiddlyWiki
Hi Eric,
 Thank you very much!
It works like a charm.

--Mohammad

TiddlyTweeter

unread,
Jan 26, 2020, 6:26:00 AM1/26/20
to TiddlyWiki
TiddlyTweeter wrote:
My point? WRITE in what is easiest. PUBLISH through TW which is about the most flexible tool around for organisation and search. 

Good as it is, TiddlyToolmap would be a MUCH more useful resource in TW.


Mark S. replied: 
What would TW bring to the table, for this particular application? You can search it, view it, toggle sections, filter by tags, etc. (except there are none -- but there could be if desired).

That conversion step between writing and publishing would get tedious, whereas it's instantaneous in TiddlyToolmap.

As usual with me my ability to make a solution is in the dark ages. 

You are right in that a TW published version of TiddlyWiki ToolMap might add nothing. 
I think it might. 
I did some attempts at a conversion but got stuck on my idiocy at coding. 

Best wishes
TT


Mohammad

unread,
Jan 26, 2020, 10:35:01 PM1/26/20
to TiddlyWiki
Hi Eric,
 Now the flexible TOC generator works fine and its outliner is really helpful.

My question is how to improve the performance?
  • I created 1000 tiddlers in 5 levels using Tiddler commander
    • Parent 10, Child 5, Grand Son 10, Grand Grand Son 2 = 10*5*10*2 = 1000 tiddlers
  • I created a toc-tree and put it on a sidebar tab
  • Using the zoomin story view I tried to step through tiddlers
  • It seems slow, when you click on an item it takes like 0.5 - 1 second to move to the new tiddler
  • closing and reopening the TOC tree on the sidebar takes like two three seconds.



--Mohammad

Mohammad

unread,
Jan 26, 2020, 10:36:59 PM1/26/20
to TiddlyWiki
Further note,
 With 1000 tiddlers, the core TOC is also slow but toc-tree is slower!
 I though to switch off scroll here and seems it has some effect.

--Mohammad

Eric Shulman

unread,
Jan 27, 2020, 4:51:53 AM1/27/20
to TiddlyWiki
On Sunday, January 26, 2020 at 7:35:01 PM UTC-8, Mohammad wrote:
Now the flexible TOC generator works fine and its outliner is really helpful.
My question is how to improve the performance?

I've made a small change to TiddlyTools/TOC/Macros that *might* result in better performance:

Instead of using
[title[$here$]tagging[]]
to drive the tree-walking recursion, I now use
[tag[$here$]]

While this is logically the same, the performance of [tag[...]] should be better since, as of 5.1.20, Jeremy added:
"pluggable index modules to accelerate the ... tag Operator (in tests on a wiki with 60K tiddlers, startup time is reduced by 25% with these optimisations, and refresh time is reduced by a factor of three.)"

Update your copy of TiddlyTools/TOC/Macros and re-run your 1000 tiddler test case and let me know if it shows any improvement.

-e



Mohammad

unread,
Jan 27, 2020, 5:19:28 AM1/27/20
to TiddlyWiki
Thanks Eric,

 I will and notify you!
By the way, We need to store the whole hierarchical list dynamically in a variable and then take care of what is in $:/HistoryList
and then highlight the entry in the TOC tree! I don't know any way to measure the impact of each step.

--Mohammad

P.S: As I noted already the core TOC is not very faster than toc-tree when it comes to 1000 tiddler!

Mat

unread,
Jan 27, 2020, 8:45:20 AM1/27/20
to TiddlyWiki
Am I doing something wrong? I still get double entries in the TOC and the arrow buttons don't show up: http://els-toc.tiddlyspot.com/
Thinking I might have some other custom stylesheets or similar that interfered, I also tried it on a completely new and empty TW, but same results.

Nobody else has this problem?

<:-)


Mohammad Rahmani

unread,
Jan 27, 2020, 9:17:38 AM1/27/20
to tiddl...@googlegroups.com
Hi Mat,
Overload toc-show-time with the below one!
You have not authortools and readertools!



\define toc-show-item()
<span class="authortools">
   <$droppable actions=<<toc-item-drop>>>
      <div class="tc-droppable-placeholder tt-toc-placeholder"></div> 
      <$draggable tiddler=<<item>> startactions=<<toc-item-dragstart>> endactions=<<toc-item-dragend>> dragimagetype="blank">
         <div title="drag to rearrange items">
            {{$(item)$||$(toc-template)$}}
         </div>
      </$draggable>
      <div class="tc-droppable-placeholder tt-toc-placeholder"><<toc-item-dragtip>></div> 
   </$droppable>
</span>
\end


Best wishes
Mohammad


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/91af8f40-822e-486e-8989-25686554b94a%40googlegroups.com.

Eric Shulman

unread,
Jan 27, 2020, 9:57:40 AM1/27/20
to TiddlyWiki
On Monday, January 27, 2020 at 5:45:20 AM UTC-8, Mat wrote:
Am I doing something wrong? I still get double entries in the TOC and the arrow buttons don't show up: http://els-toc.tiddlyspot.com/
Thinking I might have some other custom stylesheets or similar that interfered, I also tried it on a completely new and empty TW, but same results.

The double-entries are from <<toc-show-item>>, which produces output for both ".readertools" (read-only TOC) and ".authortools" (with drag-and-drop re-ordering)
If you don't have the stylesheet that defines these CSS classes, you get BOTH kinds of output.

Are you using <<toc-all>> rather than <<toc-tree>>?

<<toc-all>> doesn't allow expanding/collapsing individual branches of the tree, so there are no arrows.
<<toc-tree>> allows expanding/collapsing (initial default is all collapsed), so there are arrows.

-e

Eric Shulman

unread,
Jan 27, 2020, 10:03:11 AM1/27/20
to TiddlyWiki
On Monday, January 27, 2020 at 6:17:38 AM UTC-8, Mohammad wrote:
Hi Mat,
Overload toc-show-item with the below one!
You have not authortools and readertools!

I don't recommend doing it this way, as it will bypass any updates that I make to the code.
Instead, install  http://tiddlytools.com/InsideTW/#TiddlyTools%2FReadOnly%2FStylesheet, which defines the .readertools and .authortools CSS classes.
Note: the default is .authortools mode, which permits drag-and-drop, and also displays the "more" menu when you hover over a TOC item.

You can also install http://tiddlytools.com/InsideTW/#TiddlyTools%2FReadOnly, which provides a button to toggle between the two classes.

-e

Mohammad Rahmani

unread,
Jan 27, 2020, 10:34:03 AM1/27/20
to tiddl...@googlegroups.com
Hi Eric,
Thank you! The reason was to keep your code intact!

I used the new tiddlers you recommended. Just a question
What I am doing wrong, when I click the pad lock, still I see the arrows?


Best wishes
Mohammad


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.

Mohammad Rahmani

unread,
Jan 27, 2020, 10:39:22 AM1/27/20
to tiddl...@googlegroups.com
Eric, it works now!
I re-import into a new empty TW, and it works like a charm.



Best wishes
Mohammad

Mat

unread,
Jan 28, 2020, 2:45:27 PM1/28/20
to TiddlyWiki
Aha! I now see what has confused me:

tabort.png

The UI doesn't really show any link to the tiddler and the titles are not set to display as links so I assumed that the link I saw above the title was a link to it - it does read the same at a quick glance - so I've been pulling the wrong tiddler into my TW repeatedly. 

And, yeah, I was apparently also using toc-all instead of toc-tree.

Thank you Eric!

<:-)

Mohammad

unread,
Jan 29, 2020, 12:44:22 AM1/29/20
to TiddlyWiki
Eric,
 In any of toc macro is there any simple way to restric the number of levels?
I mean if
 L1
    L11
    L12
L2
  L21
  L22
      L221
      L222
            L2221
            L2222
      L223


I do not want to display the entries (leaves) at level 4 e.g. L2221 and L2222

--Mohammad

Mohammad

unread,
Jan 29, 2020, 12:46:08 AM1/29/20
to TiddlyWiki
It implies anything located at level 4 and above!
So, when level 4 is not displayed, level 5 and 6 if present, will not be displayed and so on.

--Mohammad

Mat

unread,
Jan 29, 2020, 1:55:53 AM1/29/20
to TiddlyWiki
Mohammad, 
I imagine one could make the recursion generate and apply a style class for each new item based on the level and then display:none for wherever you want.
For example, a style could be set in the beginning (class="mystyle") and for each recursion, an incrementing suffix is updated ("mystyle-1", "mystyle-2") or appended ("mystyle-1-2") or added as new class ("mystyle level1").

<:-)

Eric Shulman

unread,
Jan 29, 2020, 6:27:12 AM1/29/20
to tiddl...@googlegroups.com
On Tuesday, January 28, 2020 at 9:44:22 PM UTC-8, Mohammad wrote:
 In any of toc macro is there any simple way to restrict the number of levels?

I've added a new optional "max" parameter to <<toc-tree>>, <<toc-all>> and <<toc-list>>.  Thus:
   <<toc-all roottag 3>>
will show a maximum of 3 levels.  If you omit the "max" param, the full tree depth will be displayed as before.

Note that if you also want to use the "exclude" param without a "max" value, you will need to use either named parameters
   <<toc-all here:roottag exclude:"-[[ThisTag]] -[[ThatTag]]">>
or "" as a placeholder for the missing max param:
   <<toc-all roottag "" "-[[ThisTag]] -[[ThatTag]]">>
Alternatively, you can use the <$macrocall> widget syntax, which always uses named parameters:
   <$macrocall $name="toc-all" here="roottag" exclude="-[[ThisTag]] -[[ThatTag]]" />

One minor tweak still to be done for <<toc-tree>>:
when the 'max' level is reached, if more levels are present for that item it will still show an open/close arrow.
Even so, toggling this arrow will NOT show any more levels.

Give it a try and let me know how it goes...

-e

PMario

unread,
Jan 29, 2020, 6:52:29 AM1/29/20
to TiddlyWiki
Hi,
I'm following this thread with interest, but I was just skimming the individual posts.

On Wednesday, January 29, 2020 at 12:27:12 PM UTC+1, Eric Shulman wrote:
...
One minor tweak still to be done for <<toc-tree>>:
when the 'max' level is reached, if more levels are present for that item it will still show an open/close arrow.
Even so, toggling this arrow will NOT show any more levels.

I think "hiding" information, for performance reasons, without a clear and visible info isn't best practice. So as a user I would expect to get some info, that there are more levels, but I'm not able to see them. As a second step I would demand a possibility to see everything.

just my thoughts.
-mario

Eric Shulman

unread,
Jan 29, 2020, 7:30:30 AM1/29/20
to TiddlyWiki
On Wednesday, January 29, 2020 at 3:52:29 AM UTC-8, PMario wrote:
I think "hiding" information, for performance reasons, without a clear and visible info isn't best practice. So as a user I would expect to get some info, that there are more levels, but I'm not able to see them. As a second step I would demand a possibility to see everything.

I don't view the purpose of a "max" depth limit as a way to address some kind of "performance" issue.

Consider the following possible use-case:

Suppose I have a "primary" TOC tree that has 3 levels that might represent product categories/sub-categories, navigating down to individual products entries.  Then, clicking a product entry opens a separate tiddler that has it's own "secondary" TOC tree with product-specific levels such as "description", "specifications", "reviews", "images", etc.

I can also imagine having a input control to enter the "max" level to be shown in the "primary" tree so that you could easily change from "show the top 3 levels" to "show all levels", simply by clearing the input value.

-e

Mohammad

unread,
Jan 29, 2020, 8:03:41 AM1/29/20
to TiddlyWiki
Hi Eric,

 Works like a charm!
It is fantastic and beats the MS-Word outliner and TOC generator in many ways!
If Tiddlywiki sports printing CSS to create book like those publishers uses like Elsevier or Wiley,
then we could use TW for production!

The TOC tools from http://tiddlytools.com/InsideTW/ now more feature rich comparing to the current core toc macro!
I hope people support this to be included in the core!

--Mohammad
I confirm this, while it is not a big deal! But it would be nice to have this fixed! 

PMario

unread,
Jan 29, 2020, 8:44:43 AM1/29/20
to TiddlyWiki
On Wednesday, January 29, 2020 at 1:30:30 PM UTC+1, Eric Shulman wrote:
Consider the following possible use-case:

Suppose I have a "primary" TOC tree that has 3 levels that might represent product categories/sub-categories, navigating down to individual products entries.  Then, clicking a product entry opens a separate tiddler that has it's own "secondary" TOC tree with product-specific levels such as "description", "specifications", "reviews", "images", etc.

That's a good argument.
 
I can also imagine having a input control to enter the "max" level to be shown in the "primary" tree so that you could easily change from "show the top 3 levels" to "show all levels", simply by clearing the input value.

If a limit is preferred by the author, there should be an option as described, to give the user the control back. I would be perfectly happy with a solution like this one.

-mar

Mohammad

unread,
Jan 29, 2020, 8:59:30 AM1/29/20
to tiddl...@googlegroups.com
Deleted because these materials need permission.

Please see: https://groups.google.com/d/msg/tiddlywiki/_IojZZU4O0U/mal-gya8AgAJ

Mohammad Rahmani

unread,
Jan 29, 2020, 9:04:12 AM1/29/20
to tiddl...@googlegroups.com

Eric Shulman

unread,
Jan 29, 2020, 10:42:30 AM1/29/20
to TiddlyWiki
On Wednesday, January 29, 2020 at 5:59:30 AM UTC-8, Mohammad wrote:
I have prepared a summary on Eric TOC Tools with a simple installation.
This is for people like to give a try or use Eric flexible TOC and outliner in their real work.
I hope Eric confirm if the procedure given below is correct.
Regarding the license I assume it is open source, but Eric himself will explain.

Although I have posted InsideTW for *reading*, I have NOT yet "published" InsideTW or the TiddlyBook framework for general distribution.  Take note of the words on the CoverPage:


I'm OK with sharing the current TOC stuff for testing and debugging purposes only.  While it can be used in other documents, I have my own plans for providing a separate distribution for public consumption and I don't want people to grab all sort of bits and pieces of the TiddlyBook framework until I formally package and publish each bundle - which I have NOT done yet!

While I can appreciate your enthusiasm for my work, Please don't tell people to take ANY other parts of the TiddlyBook framework without asking me!
 

The Eric TOC tools is a set of macros, templates, and stylesheets to create flexible table of contents by Eric Shulman.


Everything that I share for general use will be formally distributed under my legal trademark of TiddlyTools, so "Eric TOC" is NOT an appropriate name.

When I do provide a distribution "bundle" for the TOC, it will be called "TiddlyTools/TOC".
 

It can create an outliner, a feature (outlining) quite necessary in long writings like novels, theses, project reports,...

It is a smart designed Table of Contents (TOC) generator.

It not only generates a flexible table of content, but also generates its TOC as an outliner.

With the outliner, you can see in a single glance the overall status of your contents (book, report, ...). See how contents (sections, chapters, ...) are organised. See which character appear in which scene. Quickly rearrange things. Write notes for each item as you keep the big picture in view.

  • It is possible to drag'n drop a tiddler title from the river into the TOC (outliner)
You can also drag-and-drop to re-order items within the TOC.  Drag a TOC item and drop it onto another TOC item.  The dropped item is placed *before* the item it is dropped onto.  Hold SHIFT while dropping to place the item to *after* the item it is dropped onto.  Hold CTRL while dropping to place the item as a "child" of the item it is dropped onto.
  • It uses $:/HistoryList!!currenttiddler to highlight the most recently opened tiddler
  • It can exclude items and multiple branches in the TOC
  • It can switch between author mode and reader mode (in reader mode one cannot edit the TOC)
  • It uses a local window on hover lets you create new item and new branch
  • It uses a local window on hover lets you create new item and new branch
Not sure what you mean by "local window".  When in "author" mode, hovering over a TOC item shows the TiddlyWiki standard "more" menu for that tiddler. 
  • It has toc-list macro, a simple recursion, that returns the entire TOC contents as a simple list of tiddlers
toc-all macro is also a simple recursion that shows the whole TOC with indented levels, but without support for open/close individual branches
toc-tree macro offers full tree with "arrows" to open/close individual branches.  It also features "auto-open" logic to open a branch when you view a tiddler contained in that branch (i.e., navigation to a tiddler via normal "in tiddler" links)
  • It has a ViewTemplate addition that uses the toc-list output to present next/previous buttons to provide a "sequential reader" interface that lets you step through all the TOC items, one at a time.
TiddlyTools/NavBar/Bottom is optional, and currently transcludes a few bits of TiddlyBook-specific content and includes a reference to {{TiddlyBook/RootTag}} to define the TOC starting tag (the "root" of the tree).  I will eventually be re-factoring this tiddler into two parts, one for TiddlyBook-specific use, and another as a generic TOC addon.

How to Install


The ONLY tiddlers that are REQUIRED for the TOC "bundle" are:
[prefix[TiddlyTools/TOC]] [[TiddlyTools/ReadOnly/Stylesheet]]
[[TiddlyTools/ReadOnly]] [[TiddlyTools/NavBar/Bottom]]
 The following are NOT part of the TOC bundle and should NOT be copied without separate permission
-e

Mohammad

unread,
Jan 29, 2020, 10:59:56 AM1/29/20
to TiddlyWiki
Hi Eric,
 Thanks for clarification!

I will delete my original post here and this one (your reply) will remain for readers!
So, people should consider this right protected and can be used with Permission.

--Mohammad

Eric Shulman

unread,
Jan 29, 2020, 1:31:20 PM1/29/20
to TiddlyWiki
On Wednesday, January 29, 2020 at 7:59:56 AM UTC-8, Mohammad wrote:
 Thanks for clarification!
I will delete my original post here and this one (your reply) will remain for readers!
So, people should consider this right protected and can be used with Permission.

Thanks.  Much appreciated.

Please note that to hopefully avoid any future issues, I have updated the "DraftNotice"
and added it to all pages (not just the CoverPage) so it is more prominently displayed.

I have also updated the Legal Statements (see http://tiddlytools.com/InsideTW/#Legal)
to more clearly reference applicable laws and statutes regarding Copyright, including
United States Code, Title 17 and the Berne Convention for the Protection of Literary and Artistic Works

-e

Mat

unread,
Jan 29, 2020, 3:22:43 PM1/29/20
to TiddlyWiki
@Eric, a feature request:

While InsideTW shows one tiddler at a time, I would be very neat if the TOC tool could open a full branch (i.e a tiddler and all its children, grandchildren) in the river with a single button click. I guess such a button could be positioned in the drop down menu that each title link has in your TOC. This would in effect overlap with a/the "story editor" as discussed in other threads (@pmario). This would add much value to your TOC as a tool for authoring longer texts.

I addition it would be nice if the TOC could indicate which tiddlers are open in the river, presumably with some styling.

<:-)

TonyM

unread,
Jan 29, 2020, 5:40:14 PM1/29/20
to TiddlyWiki
I love Eric's work here, though if you go back to my recent toc thread I specifically demonstrated calculating the level. In part so you can build your own toc. Eric's work is great but as features are added it gets harder for others to customise.

The feature rich solutions are valuable like Eric's but the do it yourself code patterns can reduce the need to maintain feature rich solutions.

How often do we need all the features?

just thoughts for consideration.

Tony

Eric Shulman

unread,
Jan 29, 2020, 8:53:37 PM1/29/20
to TiddlyWiki
One of Jeremy's basic guiding principles in creating TiddlyWiki is to make customization more accessible for the untrained "non-technical" user.

While "do-it-yourself code patterns" are very important for people who are somewhat coding-proficient, there are many people who are not programming-oriented and simply wish to have a "feature-rich solution" ready-made for them.  In addition, even for the coding-proficient user, there is the effect of "feature creep", where the initial custom implementation is straightforward, but rapidly increases in complexity as the desire for adding "just one more feature" starts to set in.

For example, as you and I have both shown, building a basic recursive TOC is relatively simple (once you grasp the initial concepts of recursion in TiddlyWiki), but adding such commonly-desired features as selective opening/closing of branches, drag-and-drop reordering, and currentTiddler highlighting are much harder to achieve for most casual TiddlyWiki users and even for some of the more advanced TiddlyWiki developers.

Of course, it is always satisfying when people can "follow my trail" to achieving their own complex solutions, but that is not something that should be required or even expected from most users.

Providing the appropriate balance between complexity and customization is often a subtle (and time-consuming) endeavor.  This is where the "art" of programming and the experience of many years of developing software meet, and fully tested, plug-and-play solutions such as my TOC code come into the picture.  I don't expect (nor do I encourage) people to customize the internals of my TOC code.  Even so, in anticipation of differing use-cases, I have factored some of my code to isolate certain key parts so that they can be more readily customized; e.g., TiddlyTools/TOC/Template, which controls the rendering of content for each individual TOC entry.

-e

Mohammad

unread,
Jan 30, 2020, 12:12:47 AM1/30/20
to TiddlyWiki
Mat,
 I think this is not difficult!
Assume you have open all button, you can use the same mechanism to walk through the branch starting from the node (root of that branch not root of tree)
Then one can have two options: close current story river and open new with these tiddlers, or keep story river and open this one by one!

I have used this strategy in two plugins, Tiddlyshow and Slider.

Just some thought!
--Mohammad

TonyM

unread,
Jan 30, 2020, 3:03:45 AM1/30/20
to TiddlyWiki
Eric,

Very nicely put. Totally agree too.

Love you work
Tony

Mohammad

unread,
Feb 24, 2020, 10:18:29 AM2/24/20
to tiddl...@googlegroups.com
Hi Eric,
 The drag and drop feature seems does not work with tiddlers in their title have spaces like [[copyright 1]]

To reproduce the issue
  1. goto http://tiddlytools.com/InsideTW/
  2. activate author tools by clicking on the lock pad on the top right
  3. open Copyrights tiddler
  4. clone it and change its caption to like Copyrights 1 with title Legal/Copyrights 1
  5. save
  6. now in the table of contents try to relocate this new tiddler using drag and drop
  7. only drop as a child works
  8. it seems the error comes from here
      <$action-listops $tiddler=<<newtag>>  $field="list" $subfilter="[enlist<order>] -[<actionTiddler>] +[append<actionTiddler>putbefore<item>]" />


the enlist should be the source of issue.

--Mohammad



On Saturday, January 25, 2020 at 3:44:39 PM UTC+3:30, Eric Shulman wrote:
On Saturday, January 25, 2020 at 3:26:21 AM UTC-8, Mohammad wrote:
Recently Eric Shulman shared a very impressive tool which can be used for authoring!
It can create an outliner, a feature (outlining) quite necessary in long writings like novels, theses, project reports,... 
It is a smart designed Table of Contents (TOC) generator.
and much more ...


* <<toc-list>> (defined in TiddlyTools/TOC/Macros) is a VERY simple recursion, that returns the entire TOC contents as a simple list of tiddlers
\define toc-list(here,exclude)
<$list filter="""[title[$here$]tagging[]] $exclude$ -[[$here$]]""">
   
<$link/><br>
   
<$macrocall $name="toc-list" here=<<currentTiddler>> exclude="""$exclude$ -[[$here$]]"""/>
</$list>
\end

* TiddlyTools/NavBar/Bottom is a ViewTemplate addition that uses the <<toc-list>> output to present next/previous buttons to provide a "sequential reader" interface that lets you step through all the TOC items, one at a time.

enjoy,
-e






Mohammad

unread,
Feb 24, 2020, 2:04:02 PM2/24/20
to TiddlyWiki
Further input:  It seems append does not work with tiddler have space in their name and it needs to get the input using double brackets when there is a space in title.

--Mohammad

Eric Shulman

unread,
Feb 25, 2020, 4:42:26 PM2/25/20
to TiddlyWiki
On Monday, February 24, 2020 at 11:04:02 AM UTC-8, Mohammad wrote:
Further input:  It seems append does not work with tiddler have space in their name and it needs to get the input using double brackets when there is a space in title.

Instead of using: 
      <$action-listops $tiddler=<<newtag>>  $field="list" $subfilter="[enlist<order>] -[<actionTiddler>] +[append<actionTiddler>putbefore<item>]" />
TiddlyTools/TOC now uses:
      <$action-listops $tiddler=<<newtag>>  $field="list" $subfilter="[enlist<order>] -[<actionTiddler>] [<actionTiddler>] +[putbefore<item>]" />
This avoids the use of the "append" filter (which expects a space separated list) and instead, just explicitly appends the actionTiddler at the end, then moves it into position

Similarly, when using "shift drop" (drop after), it now does:
      <$action-listops $tiddler=<<newtag>>  $field="list" $subfilter="[enlist<order>] -[<actionTiddler>] [<actionTiddler>] +[putafter<item>]" />

Also, I added handling to "ctrl drop" (drop into) so it works like the other handlers and builds the full "order" while removing any "list-before" or "list-after" fields on the individual entries:
      <$set name="order" filter="[<item>tagging[]]">
      <$list filter=<
<order>>> <$action-deletefield $field="list-before"/> <$action-deletefield $field="list-after"/> </$list>
      <$action-listops $tiddler=<
<actionTiddler>> $field="tags" $subfilter="-[<oldtag>] [<item>]" />
      <$action-listops $tiddler=<
<oldtag>>        $field="list" $subfilter="-[<actionTiddler>]" />
      <$action-listops $tiddler=<
<item>>          $field="list" $subfilter="[enlist<order>] -[<actionTiddler>] [<actionTiddler>]" />
      </$set>

With these code tweaks, TiddlyTools/TOC now handles drag-and-drop of tiddlers with spaces in their titles.

Thank for all your help testing the various edge cases for TiddlyTools/TOC.

enjoy,
-e

Mohammad

unread,
Feb 25, 2020, 4:58:24 PM2/25/20
to tiddl...@googlegroups.com
Hi Eric,
 many thanks for this update! Yes it works great!
 I also try use 

<$action-listops $tiddler=<<newtag>>        $field="list" $subfilter="[enlist<order>] -[<actionTiddler>] +[insertbefore:item<actionTiddler>]" />

and it works! but I see your solution is more consistent as it uses the same mechanism for putting before and after item!


On Wednesday, February 26, 2020 at 1:12:26 AM UTC+3:30, Eric Shulman wrote:
On Monday, February 24, 2020 at 11:04:02 AM UTC-8, Mohammad wrote:
Further input:  It seems append does not work with tiddler have space in their name and it needs to get the input using double brackets when there is a space in title.

Instead of using: 
      <$action-listops $tiddler=<<newtag>>  $field="list" $subfilter="[enlist<order>] -[<actionTiddler>] +[append<actionTiddler>putbefore<item>]" />
TiddlyTools/TOC now uses:
      <$action-listops $tiddler=<<newtag>>  $field="list" $subfilter="[enlist<order>] -[<actionTiddler>] [<actionTiddler>] +[putbefore<item>]" />
This avoids the use of the "append" filter (which expects a space separated list) and instead, just explicitly appends the actionTiddler at the end, then moves it into position

Similarly, when using "shift drop" (drop after), it now does:
      <$action-listops $tiddler=<<newtag>>  $field="list" $subfilter="[enlist<order>] -[<actionTiddler>] [<actionTiddler>] +[putafter<item>]" />

Also, I added handling to "ctrl drop" (drop into) so it works like the other handlers and builds the full "order" while removing any "list-before" or "list-after" fields on the individual entries:
      <$set name="order" filter="[<item>tagging[]]">
      <$list filter=<
<order>>> <$action-deletefield $field="list-before"/> <$action-deletefield $field="list-after"/> </$list>
      <$action-listops $tiddler=<
<actionTiddler>> $field="tags" $subfilter="-[<oldtag>] [<item>]" />
      <$action-listops $tiddler=<
<oldtag>>        $field="list" $subfilter="-[<actionTiddler>]" />
      <$action-listops $tiddler=<
<item>>          $field="list" $subfilter="[enlist<order>] -[<actionTiddler>] [<actionTiddler>]" />
      </$set>


I do not understand this, as DROP AS CHILD  means the target tiddler is a branch but it is closed, so one drops an actionTiddler on it!
If the branch is open, I expect the drop before OR drop after mechanism work as expected!
 
With these code tweaks, TiddlyTools/TOC now handles drag-and-drop of tiddlers with spaces in their titles.

Thank for all your help testing the various edge cases for TiddlyTools/TOC.


I really learn from it! and every aspects of it is a lesson in Tiddlywiki scripting! I like the toggle mechanism and the way it processes branches.
 
enjoy,
-e


One more question:

I confused with drag and drop when there are more than a tag! (I mean an entry in the TOC tree has more than one tags)

Example:

* root
**  child1
***    gchild1
***    gchild2
**  child2
**  child3


they have a hierarchy and create a tree.
Now assume gchild2 not only tagged with child1 but also tagged with foo and bar!
Then I tried to drag and drop gchild2 over child3 (no modifier) I see gchild2 remains under child1 branch and also appears before child3 (gets the root tag as expected)

Is there any limitation here, or I made a mistake?

--Mohammad



 

Mohammad

unread,
Feb 25, 2020, 6:34:37 PM2/25/20
to TiddlyWiki
Further input to handle multiple tags I did some elaboration and see


\define toc-item-dragdata()      $:/temp/TOC/dragdata
\define toc-item-dragdata-path() $:/temp/TOC/dragdata/path
\define toc-item-dragstart()   
<$action-setfield  $tiddler=<<toc-item-dragdata>> text=<<actionTiddler>> />
<$action-setfield  $tiddler=<<toc-item-dragdata-path>> text=<<path>> />
\end


\define toc-item-drop()
<$reveal default=<<actionTiddler>> type="nomatch" text=<<item>>> <!-- DON'T DROP ON SELF -->
   <!-- get OLDTAG and NEWTAG, exclude special TiddlyBook tags -->
   <$vars sourcetags={{{ [<actionTiddler>get[tags]] }}}
  sourcepath={{{ [<toc-item-dragdata-path>get[text]] }}}
          targettags={{{ [<item>get[tags]] }}}>
   <$vars  oldtag={{{ [<sourcepath>split[/]]-[<actionTiddler>]+[last[]]  }}}
           newtag={{{ [enlist<targettags>!enlist<toc-ignore-tags>] }}}>
   ......
 .....

It seems it work! I actually use the path to see what is the immediate parent! Then I just removed it and the code add the new tag correctly!
Of course this may be used when the target has also several tags!

What do you think?

--Mohammad

Mohammad

unread,
Feb 25, 2020, 6:43:36 PM2/25/20
to TiddlyWiki
One more question:

I confused with drag and drop when there are more than a tag! (I mean an entry in the TOC tree has more than one tags)

Example:

* root
**  child1
***    gchild1
***    gchild2
**  child2
**  child3


they have a hierarchy and create a tree.
Now assume gchild2 not only tagged with child1 but also tagged with foo and bar!
Then I tried to drag and drop gchild2 over child3 (no modifier) I see gchild2 remains under child1 branch and also appears before child3 (gets the root tag as expected)

Is there any limitation here, or I made a mistake?

--Mohammad


I think the below may acts as an alternative when both source tiddler and target tiddler have multiple tags and one reorder tiddlers by drag and drop

\define toc-item-dragdata()      $:/temp/TOC/dragdata
\define toc-item-dragdata-path() $:/temp/TOC/dragdata/path

\define toc-item-dragstart()  
<$action-setfield  $tiddler=<<toc-item-dragdata>> text=<<actionTiddler>> />
<$action-setfield  $tiddler=<<toc-item-dragdata-path>> text=<<path>> /
>
\end

\define toc-item-dragend()  
<$action-deletetiddler $tiddler=<<toc-item-dragdata>> />
<$action-deletetiddler $tiddler=<<toc-item-dragdata-path>> /
>
\end

\define toc-item-drop()
<$reveal default=<<actionTiddler>> type="nomatch" text=<<item>>> <!-- DON'T DROP ON SELF -->
   
<!-- get OLDTAG and NEWTAG, exclude special TiddlyBook tags -->

   
<$vars sourcepath={{{ [<toc-item-dragdata-path>get[text]] }}}
          targetpath=
<<path>> >
   
<$vars oldtag= {{{ [<sourcepath>split[/]]-[<actionTiddler>]+[last[]]  }}}
           newtag={{{ [
<targetpath>split[/]]-[<item>]+[last[]]  }}}>
   
<$reveal default=<<modifier>> type="match" text="normal"> <!-- DROP BEFORE SIBLING -->
     
<$set name="order" filter="[<newtag>tagging[]]">

     
<$list filter=<<order>>> <$action-deletefield $field="list-before"/> <$action-deletefield $field="list-after"/> </$list>

     
<$action-listops $tiddler=<<actionTiddler>> $field="tags" $subfilter="-[<oldtag>] [<newtag>]" />
     
<$action-listops $tiddler=<<oldtag>>        $field="list" $subfilter="-[<actionTiddler>]" />
     
<$action-listops $tiddler=<<newtag>>        $field="list" $subfilter="[enlist<order>] -[<actionTiddler>] [<actionTiddler>] +[putbefore<item>]" />
     
</$set>
   
</$reveal>
   
<$reveal default=<<modifier>> type="match" text="shift"> <!-- DROP AFTER SIBLING -->
     
<$set name="order" filter="[<newtag>tagging[]]">

     
<$list filter=<<order>>> <$action-deletefield $field="list-before"/> <$action-deletefield $field="list-after"/> </$list>

     
<$action-listops $tiddler=<<actionTiddler>> $field="tags" $subfilter="-[<oldtag>] [<newtag>]" />
     
<$action-listops $tiddler=<<oldtag>>        $field="list" $subfilter="-[<actionTiddler>]" />
     
<$action-listops $tiddler=<<newtag>>        $field="list" $subfilter="[enlist<order>] -[<actionTiddler>] [<actionTiddler>] +[putafter<item>]" />
     
</$set>
   
</$reveal>
   
<$reveal default=<<modifier>> type="match" text="ctrl"> <!-- DROP AS CHILD -->

     
<$set name="order" filter="[<item>tagging[]]">
     
<$list filter=<<order>>> <$action-deletefield $field="list-before"/> <$action-deletefield $field="list-after"/> </$list>
     
<$action-listops $tiddler=<<actionTiddler>> $field="tags" $subfilter="-[<oldtag>] [<item>]" />
     
<$action-listops $tiddler=<<oldtag>>        $field="list" $subfilter="-[<actionTiddler>]" />
     
<$action-listops $tiddler=<<item>>          $field="list" $subfilter="[enlist<order>] -[<actionTiddler>] [<actionTiddler>]" />
     
</$set>

   
</$reveal>
   
</$vars>
   
</$vars>
</$reveal>
\end

Please have a look and let me know your opinion on this?

--Mohammad



 


 
Reply all
Reply to author
Forward
0 new messages