how to make a link list finding all tiddlers with a certain field and sorting them by that field content

356 views
Skip to first unread message

Sapphireslinger

unread,
Aug 27, 2020, 5:48:05 AM8/27/20
to TiddlyWiki
When I finish reading a book, what is the most elegant way to mark it as read?

For each book I have a book tiddler titled "Book - (author) - (book title)" in which I keep transcluded quote tiddlers, a link list of all the author's other books, tags like (x)-star if finished reading, or tagged read now / read next / read later if not read yet.

To mark the book as read I tried creating a new field called "finished-reading-date" and put the date/time I finished the book in that field.

Then I created a tiddler titled "Reading History" in which to keep a list of books read. But I don't know the link list expression to call all tiddlers possessing the field "finished-reading-date" into a list and sort them by that field's variable, the date/time.

 Also, is there anything I can add to the expression to have the tiddlers sort themselves under year headings, not to mention month headings? They are already tagged with the year I finished reading them (i.e 2020) and the month (i.e August).

And even if I find out how to do the above, are there more elegant ways of keeping track of one's reading history? What do other people do? (Maybe I should ask this as a separate post.)

Eric Shulman

unread,
Aug 27, 2020, 7:05:28 AM8/27/20
to tiddl...@googlegroups.com
On Thursday, August 27, 2020 at 2:48:05 AM UTC-7, Sapphireslinger wrote:
When I finish reading a book, what is the most elegant way to mark it as read?

There are LOTS of ways to do this.  For this reply, let's just use the method you described...
 
list ... all tiddlers possessing the field "finished-reading-date" ... and sort them by that field ... sort under year headings (and) month headings?
They are already tagged with the year I finished reading them (i.e 2020) and the month (i.e August).

Here's a set of nested <$list> widgets to show the "Reading History":
<$list filter="[range[2018,2021]]" variable="year">
   <$list filter="[tag
<year>limit[1]]">
      <
<year>><br>
      <$list filter="[range[1,12]addprefix[$:/language/Date/Long/Month/]get[text]]" variable="month">
         <$list filter="[tag
<year>tag<month>limit[1]]">
            &emsp;<
<month>><br>
            <$list filter="[tag
<year>tag<month>has[finished-reading-date]sort[finished-reading-date]]">
               &emsp;&emsp;<$link /> (<$view field="finished-reading-date"/>)
<br>
            </$list>
         </$list>
      </$list>
   </$list>
</$list>

Notes:
* Line 1: $list iterates over a set of years using range[start,end] (adjust start and end values to fit your data)
* Line 2: $list checks to see if at least 1 tiddler is tagged with that year
* Line 3: displays the year
* Line 4: $list iterates over a set of month names using range[1,12], getting the month names from the TWCore shadows
* Line 5: $list checks to see if at least 1 tiddler is tagged with that year and month
* Line 6: displays the month, indented by &emsp; (an "em" space character)
* Line 7: $list finds all tiddlers with the year and month tags that also have a "finished-reading-date" field, and sorts by that field
* Line 8: displays a link to the matching tiddler and the value of the "finished-reading-date" field, indented by two $emsp;
* Lines 9-13: close the $list widgets

enjoy,
-e

Sapphireslinger

unread,
Aug 27, 2020, 7:56:11 AM8/27/20
to TiddlyWiki
Eureka! It works! Thank you!!

I will try to learn how to use those nested widgets for other purposes as well, not just Reading History. 

Sapphireslinger

unread,
Sep 18, 2020, 9:39:50 AM9/18/20
to TiddlyWiki
How do I tweak this for journal entries? My journal entries are also tagged with year and month and "Journal", so I tried to turn this into a table of contents for my journal entries like so:

<$list filter="[range[2000,2021]]" variable="year">
   <$list filter="[tag
<year>limit[1]]">
      <
<year>><br>

      <$list filter="[range[1,12]addprefix[$:/language/Date/Long/Month/]get[text]]" variable="month">
         <$list filter="[tag
<year>tag<month>limit[1]]">
            &emsp;<
<month>><br>

            <$list filter="[tag
<year>tag<month>has[tag="Journal"]sort[title]]">
               &emsp;&emsp;<$link />
<br>

            </$list>
         </$list>
      </$list>
   </$list>
</$list>

But the results were clearly broken.

Eric Shulman

unread,
Sep 18, 2020, 10:37:21 AM9/18/20
to TiddlyWiki
On Friday, September 18, 2020 at 6:39:50 AM UTC-7, Sapphireslinger wrote:
How do I tweak this for journal entries? My journal entries are also tagged with year and month and "Journal", so I tried to turn this into a table of contents for my journal entries like so:

This filter is wrong... 
            <$list filter="[tag<year>tag<month>has[tag="Journal"]sort[title]]">

The has[...] operator just checks to see if a specified field name exists in the tiddler.  You can't use it to check the value of that field.

To check to see if a tiddler has a particular tag, use the tag[...] filter, just as you have for the <year> and <month>.  Thus:
<$list filter="[tag<year>tag<month>tag[Journal]sort[title]]">
Note the use of [...] to enclose a literal value "Journal", rather than the <...> syntax which is for reference to the value of a variable.

enjoy,
-e

TW Tones

unread,
Sep 18, 2020, 8:09:42 PM9/18/20
to TiddlyWiki
Sapphireslinger

I see you have being on a journey to get here. I for one am trying to persuade the modification of the Journal buttons to those attached, try them and delete them if you don't like them.

The New Journal and New Journal Here are altered to also set a journal-date field with the tiddlywiki date stamp. Ten you can rely on this regardless of the title name, last modified, even if the created date was manipulated to provide a full data and time, from which it is easy to extract any value as needed.

Sorting is then done on the Journal-date field. even with just sort[] or !sort[]

So no need to "My journal entries are also tagged with year and month"

Just saying
Tones
-NewJournal2020release.json

Sapphireslinger

unread,
Sep 19, 2020, 3:45:59 AM9/19/20
to TiddlyWiki
Eric Shulman

Thank you! It worked!

I had tried "...tag<year>tag<month>tag<Journal>..." but didn't know about the [...] versus <...> syntax.

Is there any way to make lines 3 and 5 (the year headings and month headings) collapsible/expandable? (Click on the year and every thing under it appears, click again and it disappears.)

Sapphireslinger

unread,
Sep 19, 2020, 5:00:11 AM9/19/20
to TiddlyWiki
Tones

How do I use your attachment? I tried copying the contents into a tiddler and made it a json tiddler. I also tried drag and dropping your attachment into my wiki. But neither attempt made anything different appear in my wiki.

I do already have a New Journal button which timestamps the title and automatically populates it with the tags "Journal", "(year)", "(month)", "202009 September"(for instance).

I am deleting all my other apps one by one (Evernote, Google Keep, etc.) as I retrieve my old journal entries from them and bring them over into Tiddlywiki, so I can not rely on the creation date of the journal tiddlers. I suppose I could manually change the creation date to match the date of the journal entry, but I would have a ton of tiddlers to process all over again one by one. In transferring my journal entries I just had every journal tiddler title follow this pattern ...

"2020.09.19 Sat 0600 - (some phrase to jog my memory about the journal entry)"

... and didn't worry about the creation date.

Ultimately I had a Journal TOC that was terribly clunky, manual and redundant. At the top was the "Journal" tiddler with the TOC code. Then an empty tiddler for every year ("Journal 2020", etc) tagged with "Journal". Then a tiddler for EVERY month of EVERY year ("202009 September", etc) tagged with "Journal 2020"(etc) and inside each of those tiddlers code to transclude all the journal entries for that month (a list filter calling for title and text of all entries tagged with "Journal" "2020" and "September" for instance). The individual journal entries were also tagged with "202009 September" etc and would show up under it (for instance "202009 September") in the TOC.

But I had to remember to do up a new month tiddler every month, which I never do, so my TOC has fallen sadly behind. Which is why I was delighted to find out how to repurpose Eric Schulman's code for my Reading History which accomplishes almost all of this automatically and far more elegantly.

Looking forward to experimenting with your New Journal button as soon as I figure out how to get it into my wiki.

Birthe C

unread,
Sep 19, 2020, 6:17:48 AM9/19/20
to TiddlyWiki
Sapphireslinger,

You should be able to drag and drop import the json from Tones. I did that and got two overwritten core tiddlers - empty but with nice tags.

@TW Tones,
Something is missing, would you please reupload the attachment?


Birthe

TW Tones

unread,
Sep 19, 2020, 8:35:10 PM9/19/20
to TiddlyWiki
I have attached it again;

However if you already have a custom journal tiddler add this in the <$action-sendmessage $message="tm-new-tiddler" (there is more than one)
  journal-date=<<now "YYYY0MM0DD0hh0mm0ss0XXX">>
The package adds it to;
The only but important thing it does is store a full Tiddlywiki serial number date in the field journal-date for the Journal tiddlers both, new an new here journals.

As a result without interrogating the title you can do any date manipulation like use days[] operator, and a lot more, including edit you title, post it on a date different to when entered 
  • ie not relying on the created date, or modified date which should do as advertised and not compromised.
Regards
Tony

journal-date.json

Birthe C

unread,
Sep 20, 2020, 12:47:34 AM9/20/20
to TiddlyWiki
Thank you TW Tones,

Works for me now.

Birthe
Message has been deleted

Sapphireslinger

unread,
Sep 22, 2020, 3:36:34 AM9/22/20
to TiddlyWiki
TW Tones,

I'm using Quinoid on my smartphone, but to install things on my tiddlywiki, I copy the tiddlywiki file to my microSD, which I take out of my phone and plug in to the desktop computer. I open the file with firefox/timini.

FIRST ATTEMPT

I dragged the your journal-date.json into my tiddlywiki. After hitting "import", all I got was a tiddler named Untitled and all it contained was the link: https://docs.google.com/viewer?a=v&pid=forums&srcid=MTEyNjM4NzE3NzI3NzEyNTIyMDMBMDIwMDA4NzE2NDA4NTU3MzE3NDkBYW9HVUd2dTJCUUFKATAuMQEBdjI

So I went to the link, copied the contents, pasted them into a new tiddler, titled it "TW tones - new journal button", no tags, and saved it as a json tiddler. Saved my tiddlywiki, closed and reopened it just to make sure.

Nothing new happened when I clicked on any journal buttons :(

SECOND ATTEMPT

Then I tried pasting the contents of the link directly into the two files you mentioned, in the empty space at the bottom of the code they contained.
So (1) $:/core/ui/Actions/new-journal looked like this:

<$vars journalTitleTemplate={{$:/config/NewJournal/Title}} journalTags={{$:/config/NewJournal/Tags!!tags}} journalText={{$:/config/NewJournal/Text}}>
<$wikify name="journalTitle" text="""<$macrocall $name="now" format=<<journalTitleTemplate>>/>""">
<$reveal type="nomatch" state=<<journalTitle>> text="">
<$action-sendmessage $message="tm-new-tiddler" title=<<journalTitle>> tags=<<journalTags>> text={{{ [<journalTitle>get[]] }}}/>
</$reveal>
<$reveal type="match" state=<<journalTitle>> text="">
<$action-sendmessage $message="tm-new-tiddler" title=<<journalTitle>> tags=<<journalTags>> text=<<journalText>>/>
</$reveal>
</$wikify>
</$vars>
[{"created":"20200609104906227","text":"Adds the journal-date field to new journals be they new here or from the Page Controls\n\n","title":"$:/PSaT/with-Journal-Date","tags":"","modified":"20200610031648548","description":"Modify core behaviour to New Journals With Journal-Date field","rating":"5","package-filter":"[all[]prefix[$:/PSaT/with-Journal-Date]] [[$:/core/ui/Actions/new-journal]] [[$:/core/ui/Buttons/new-journal-here]]","icon":"$:/core/images/new-journal-button"},{"created":"20200508083445369","text":"<$vars journalTitleTemplate={{$:/config/NewJournal/Title}} journalTags={{$:/config/NewJournal/Tags!!tags}} journalText={{$:/config/NewJournal/Text}}>\n<$wikify name=\"journalTitle\" text=\"\"\"<$macrocall $name=\"now\" format=<<journalTitleTemplate>>/>\"\"\">\n<$reveal type=\"nomatch\" state=<<journalTitle>> text=\"\">\n<$action-sendmessage $message=\"tm-new-tiddler\" title=<<journalTitle>> tags=<<journalTags>> text={{{ [<journalTitle>get[]] }}}  journal-date=<<now \"YYYY0MM0DD0hh0mm0ss000\">>/>\n</$reveal>\n<$reveal type=\"match\" state=<<journalTitle>> text=\"\">\n<$action-sendmessage $message=\"tm-new-tiddler\" title=<<journalTitle>> tags=<<journalTags>> text=<<journalText>>  journal-date=<<now \"YYYY0MM0DD0hh0mm0ss000\">>/>\n</$reveal>\n</$wikify>\n</$vars>\n","title":"$:/core/ui/Actions/new-journal","tags":"$:/tags/Actions","modifier":"Quick Config","modified":"20200626001201202","description":"create a new journal tiddler","creator":"Quick Config"},{"text":"\\whitespace trim\n\\define journalButtonTags()\n[[$(currentTiddlerTag)$]] $(journalTags)$\n\\end\n\\define journalButton()\n<$button tooltip={{$:/language/Buttons/NewJournalHere/Hint}} aria-label={{$:/language/Buttons/NewJournalHere/Caption}} class=<<tv-config-toolbar-class>>>\n<$wikify name=\"journalTitle\" text=\"\"\"<$macrocall $name=\"now\" format=<<journalTitleTemplate>>/>\"\"\">\n<$action-sendmessage $message=\"tm-new-tiddler\" title=<<journalTitle>> tags=<<journalButtonTags>>  journal-date=<<now \"YYYY0MM0DD0hh0mm0ss000\">>/>\n<$list filter=\"[<tv-config-toolbar-icons>match[yes]]\">\n{{$:/core/images/new-journal-button}}\n</$list>\n<$list filter=\"[<tv-config-toolbar-text>match[yes]]\">\n<span class=\"tc-btn-text\">\n<$text text={{$:/language/Buttons/NewJournalHere/Caption}}/>\n</span>\n</$list>\n</$wikify>\n</$button>\n\\end\n<$set name=\"journalTitleTemplate\" value={{$:/config/NewJournal/Title}}>\n<$set name=\"journalTags\" value={{$:/config/NewJournal/Tags!!tags}}>\n<$set name=\"currentTiddlerTag\" value=<<currentTiddler>>>\n<<journalButton>>\n</$set>\n</$set>\n</$set>\n","title":"$:/core/ui/Buttons/new-journal-here","tags":"$:/tags/ViewToolbar","modifier":"Quick Config","modified":"20200508083846432","description":"{{$:/language/Buttons/NewJournalHere/Hint}}","creator":"Quick Config","created":"20200508083825834","caption":"{{$:/core/images/new-journal-button}} {{$:/language/Buttons/NewJournalHere/Caption}}"}]

And (2) $:/core/ui/Buttons/new-journal-here looked like this:

\whitespace trim
\define journalButtonTags()
[[$(currentTiddlerTag)$]] $(journalTags)$
\end
\define journalButton()
<$button tooltip={{$:/language/Buttons/NewJournalHere/Hint}} aria-label={{$:/language/Buttons/NewJournalHere/Caption}} class=<<tv-config-toolbar-class>>>
<$wikify name="journalTitle" text="""<$macrocall $name="now" format=<<journalTitleTemplate>>/>""">
<$action-sendmessage $message="tm-new-tiddler" title=<<journalTitle>> tags=<<journalButtonTags>>/>
<$list filter="[<tv-config-toolbar-icons>match[yes]]">
{{$:/core/images/new-journal-button}}
</$list>
<$list filter="[<tv-config-toolbar-text>match[yes]]">
<span class="tc-btn-text">
<$text text={{$:/language/Buttons/NewJournalHere/Caption}}/>
</span>
</$list>
</$wikify>
</$button>
\end
<$set name="journalTitleTemplate" value={{$:/config/NewJournal/Title}}>
<$set name="journalTags" value={{$:/config/NewJournal/Tags!!tags}}>
<$set name="currentTiddlerTag" value=<<currentTiddler>>>
<<journalButton>>
</$set>
</$set>
</$set>
[{"created":"20200609104906227","text":"Adds the journal-date field to new journals be they new here or from the Page Controls\n\n","title":"$:/PSaT/with-Journal-Date","tags":"","modified":"20200610031648548","description":"Modify core behaviour to New Journals With Journal-Date field","rating":"5","package-filter":"[all[]prefix[$:/PSaT/with-Journal-Date]] [[$:/core/ui/Actions/new-journal]] [[$:/core/ui/Buttons/new-journal-here]]","icon":"$:/core/images/new-journal-button"},{"created":"20200508083445369","text":"<$vars journalTitleTemplate={{$:/config/NewJournal/Title}} journalTags={{$:/config/NewJournal/Tags!!tags}} journalText={{$:/config/NewJournal/Text}}>\n<$wikify name=\"journalTitle\" text=\"\"\"<$macrocall $name=\"now\" format=<<journalTitleTemplate>>/>\"\"\">\n<$reveal type=\"nomatch\" state=<<journalTitle>> text=\"\">\n<$action-sendmessage $message=\"tm-new-tiddler\" title=<<journalTitle>> tags=<<journalTags>> text={{{ [<journalTitle>get[]] }}}  journal-date=<<now \"YYYY0MM0DD0hh0mm0ss000\">>/>\n</$reveal>\n<$reveal type=\"match\" state=<<journalTitle>> text=\"\">\n<$action-sendmessage $message=\"tm-new-tiddler\" title=<<journalTitle>> tags=<<journalTags>> text=<<journalText>>  journal-date=<<now \"YYYY0MM0DD0hh0mm0ss000\">>/>\n</$reveal>\n</$wikify>\n</$vars>\n","title":"$:/core/ui/Actions/new-journal","tags":"$:/tags/Actions","modifier":"Quick Config","modified":"20200626001201202","description":"create a new journal tiddler","creator":"Quick Config"},{"text":"\\whitespace trim\n\\define journalButtonTags()\n[[$(currentTiddlerTag)$]] $(journalTags)$\n\\end\n\\define journalButton()\n<$button tooltip={{$:/language/Buttons/NewJournalHere/Hint}} aria-label={{$:/language/Buttons/NewJournalHere/Caption}} class=<<tv-config-toolbar-class>>>\n<$wikify name=\"journalTitle\" text=\"\"\"<$macrocall $name=\"now\" format=<<journalTitleTemplate>>/>\"\"\">\n<$action-sendmessage $message=\"tm-new-tiddler\" title=<<journalTitle>> tags=<<journalButtonTags>>  journal-date=<<now \"YYYY0MM0DD0hh0mm0ss000\">>/>\n<$list filter=\"[<tv-config-toolbar-icons>match[yes]]\">\n{{$:/core/images/new-journal-button}}\n</$list>\n<$list filter=\"[<tv-config-toolbar-text>match[yes]]\">\n<span class=\"tc-btn-text\">\n<$text text={{$:/language/Buttons/NewJournalHere/Caption}}/>\n</span>\n</$list>\n</$wikify>\n</$button>\n\\end\n<$set name=\"journalTitleTemplate\" value={{$:/config/NewJournal/Title}}>\n<$set name=\"journalTags\" value={{$:/config/NewJournal/Tags!!tags}}>\n<$set name=\"currentTiddlerTag\" value=<<currentTiddler>>>\n<<journalButton>>\n</$set>\n</$set>\n</$set>\n","title":"$:/core/ui/Buttons/new-journal-here","tags":"$:/tags/ViewToolbar","modifier":"Quick Config","modified":"20200508083846432","description":"{{$:/language/Buttons/NewJournalHere/Hint}}","creator":"Quick Config","created":"20200508083825834","caption":"{{$:/core/images/new-journal-button}} {{$:/language/Buttons/NewJournalHere/Caption}}"}]

And now one of my "new journal buttons" does not appear to work at all. (So sorry, can not remember where and when I got that particular new journal button. But it's not the one that automatically tags my new journal tiddlers with month and year etc that I've been using for awhile.)

Not sure what to try next.

Sapphireslinger

unread,
Sep 22, 2020, 4:03:23 AM9/22/20
to TiddlyWiki
TW-Tones,

I made a third attempt and IT WORKED! Thank you, thank you so much!

Now my files look like this:


<$vars journalTitleTemplate={{$:/config/NewJournal/Title}} journalTags={{$:/config/NewJournal/Tags!!tags}} journalText={{$:/config/NewJournal/Text}}>
<$wikify name="journalTitle" text="""<$macrocall $name="now" format=<<journalTitleTemplate>>/>""">
<$reveal type="nomatch" state=<<journalTitle>> text="">
<$action-sendmessage $message="tm-new-tiddler" title=<<journalTitle>> tags=<<journalTags>> journal-date=<<now "YYYY0MM0DD0hh0mm0ss0XXX">> text={{{ [<journalTitle>get[]] }}}/>

</$reveal>
<$reveal type="match" state=<<journalTitle>> text="">
<$action-sendmessage $message="tm-new-tiddler" title=<<journalTitle>> tags=<<journalTags>> journal-date=<<now "YYYY0MM0DD0hh0mm0ss0XXX">> text=<<journalText>>/>
</$reveal>
</$wikify>
</$vars>


\whitespace trim
\define journalButtonTags()
[[$(currentTiddlerTag)$]] $(journalTags)$
\end
\define journalButton()
<$button tooltip={{$:/language/Buttons/NewJournalHere/Hint}} aria-label={{$:/language/Buttons/NewJournalHere/Caption}} class=<<tv-config-toolbar-class>>>
<$wikify name="journalTitle" text="""<$macrocall $name="now" format=<<journalTitleTemplate>>/>""">
<$action-sendmessage $message="tm-new-tiddler" title=<<journalTitle>> tags=<<journalButtonTags>> journal-date=<<now "YYYY0MM0DD0hh0mm0ss0XXX">>/>

<$list filter="[<tv-config-toolbar-icons>match[yes]]">
{{$:/core/images/new-journal-button}}
</$list>
<$list filter="[<tv-config-toolbar-text>match[yes]]">
<span class="tc-btn-text">
<$text text={{$:/language/Buttons/NewJournalHere/Caption}}/>
</span>
</$list>
</$wikify>
</$button>
\end
<$set name="journalTitleTemplate" value={{$:/config/NewJournal/Title}}>
<$set name="journalTags" value={{$:/config/NewJournal/Tags!!tags}}>
<$set name="currentTiddlerTag" value=<<currentTiddler>>>
<<journalButton>>
</$set>
</$set>
</$set>

Sapphireslinger

unread,
Sep 22, 2020, 4:10:29 AM9/22/20
to TiddlyWiki
TW Tones,

So I just change the journal-date to the date the described events were happening. For instance: I find an old journal entry from 2007, I enter the 2007 date, not today's date, is that correct?

Sapphireslinger

unread,
Sep 22, 2020, 5:11:16 AM9/22/20
to TiddlyWiki
TW Tones

You say I now do not need year and month tag on my journal tiddlers.

But if I get rid of the year and month tags, I assume this code will no longer work?

<$list filter="[range[2000,2021]]" variable="year">
   <$list filter="[tag<year>limit[1]]">
      <<year>><br>
      <$list filter="[range[1,12]addprefix[$:/language/Date/Long/Month/]get[text]]" variable="month">
         <$list filter="[tag<year>tag<month>limit[1]]">
            &emsp;<<month>><br>
            <$list filter="[tag<year>tag<month>tag[Journal]sort[title]]">

               &emsp;&emsp;<$link /><br>
            </$list>
         </$list>
      </$list>
   </$list>
</$list>

It needs to be modified in some way to take advantage of the journal-date field?

Sapphireslinger

unread,
Dec 7, 2020, 5:55:25 AM12/7/20
to TiddlyWiki
In my reading history log (thank you so much) how do I have a count of entries for the month show up beside the month?

For instance, if I read 10 books in September, how do I get it to show: September (10)

Ditto for year total of entries: 2020 (x)

I'm pretty sure this was the wrong way to do it:

<$list filter="[range[2018,2021]]" variable="year">
   <$list filter="[tag
<year>limit[1]]">
      <
<year>><<count>><br>

      <$list filter="[range[1,12]addprefix[$:/language/Date/Long/Month/]get[text]]" variable="month">
         <$list filter="[tag
<year>tag<month>
limit[1]]">
            &emsp;<
<month>><<count>><br>

            <$list filter="[tag
<year>tag<month>
has[finished-reading-date]sort[finished-reading-date]]">
               &emsp;&emsp;<$link /> (<$view field="finished-reading-date"/>)
<br>

            </$list>
         </$list>
      </$list>
   </$list>
</$list>
Reply all
Reply to author
Forward
0 new messages