13th-July-2018: RSSforStaticTiddlyWiki

Need to use the template tiddler $:/core/templates/static.template.html as a basis for creating a multi-tiddler output, but that tiddler seems to use templating in a way that I'm unfamiliar with. In particular, it pulls in stuff via:


Oh! I thought that the first part read as PostTemplate, which I further mistook for $:/core/ui/ViewTemplate. I suspect that I know what's afoot here, now; let's dive in!

The file looks OK (maybe deceptively simple), but the lack of indentation among blocks prevents us from really keeping track of what's working and associated with what, so let's add some indentation:

\define containerClasses()
tc-page-container tc-page-view-$(themeTitle)$ tc-language-$(languageTitle)$

<$importvariables filter="[[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]">

    <$set name="tv-config-toolbar-icons" value={{$:/config/Toolbar/Icons}}>

        <$set name="tv-config-toolbar-text" value={{$:/config/Toolbar/Text}}>

            <$set name="tv-config-toolbar-class" value={{$:/config/Toolbar/ButtonClass}}>

                <$set name="themeTitle" value={{$:/view}}>

                    <$set name="currentTiddler" value={{$:/language}}>

                        <$set name="languageTitle" value={{!!name}}>

                            <$set name="currentTiddler" value="">

                                <div class=<<containerClasses>>>

                                    <$navigator story="$:/StoryList" history="$:/HistoryList" openLinkFromInsideRiver={{$:/config/Navigation/openLinkFromInsideRiver}} openLinkFromOutsideRiver={{$:/config/Navigation/openLinkFromOutsideRiver}} relinkOnRename={{$:/config/RelinkOnRename}}>


                                            <$list filter="[all[shadows+tiddlers]tag[$:/tags/PageTemplate]!has[draft.of]]" variable="listItem">

                                                <$transclude tiddler=<<listItem>>/>













Side note: I currently forget why, but as I learned previously when mucking around with TW, the second half of the code we first saw, {{$:/core/ui/PageTemplate||$:/core/templates/html-tiddler}}, is important, because without it, the content of $:/core/ui/PageTemplate (shown above) would be spit out to wherever it's transcluded, but without any HTML tags. This is not intuitive.

I'm now cheating to understand what's afoot: I've looked up what the <$set> blocks are/do, via the TW website, and they're called "set widgets". They don't help me, I think; they just assign values to a given variable.

It's looking like the <$list ... widget is what I need to look into. The fact that it ends with variable="listItem" and that listItem also appears in the below/contained transclude widget, and appears to function as the name of the tiddler being transcluded with the transclude widget, suggests that looking into the variable, uh, parameter(??? or is it an "argument"? or is a parameter the thing to which a thing, an argument (arg) is posed?) should shed light on what's going on.

HAH! After looking into the list widget, I see that I was sorta way off in terms of guessing as to what's going on. variable is literally allowing you to ONLY assign a name of your choosing to something that exists regardless of whether you call upon it explicitly or not: a variable that contains a list's currently-considered list item.

So why might this be assigning a name to it, unnecessarily? I don't know. In the docs it suggests that the name given to this variable is, by default, currentTiddler, which you'll notice in the code for PageTemplate appears a number of times. Further, the fact that <$set name="currentTiddler" value=""> comes up before the list widget leads me to wonder why it is that someone needed to bother with assigning an empty value to currentTiddler prior to this list. Is it simply because it was set earlier, by <$set name="currentTiddler" value={{$:/language}}>?

I'll play a fool and not only not do anything of this sort but instead proceed with the following, notably ripping out the variable="listItem" stuff and replacing listItem with the default name of currentTiddler.

<$list filter="[all[shadows+tiddlers]tag[$:/tags/PageTemplate]!has[draft.of]]">

    <$transclude tiddler=<<currentTiddler>>/>


OK. After some 30 minutes of struggling, I seemed to have figured out an issue I had when going down this route.

When I run the block of code above in a new tiddler, the tiddler has a BUNCH of formatted and stylized posts (as though the View Template were being used upon each list item), etc. I did not expect this to be the case.

Next, I tried changing <<currentTiddler>> to my stupid tiddler, named Hi. Suddenly, there's the tiddler, but without the View Template formatting. Plain as day. WAT.

Come to find out, if we run the above code block but delete the part of the list widget's filter that reads tag[$:/tags/PageTemplate], leaving behind only [all[shadows+tiddlers]!has[draft.of]], it works as expected: all posts, outputted without the View Template formatting. This is quite strange behavior, and I look forward to exploring Filters more to understand why this is happening. But for now, we can proceed with the simple list and transclude widgets!

Jul 14th

Investigating into the various tiddler templates:

  • static (View Template)
  • raw-static (View Template, as html)
  • plain-text-tiddler (Pre-Wikified text of tiddler, as plain text)

Wait I think I'm using this wrong. I think that the tiddler journals-feed need only be used as a template for plain text file output, at this point.

After testing, I see that I'm correct. Using the command line command, I was able to generated a plain text file containing a list of all Journal posts, given the journal tag filter ([tag[Journal]]):

tiddlywiki publicwiki --render "journals-feed" journals-feed.txt text/plain "" exportFilter "[tag[Journal]]"

This is pretty much a straight copy of the command given in the render command's documentation.

If you do not specify the double quotes ("") before exportFilter, no static file is produced. I'm not sure why.

To go beyond plain text formatting, we need to add in HTML or XML blocks. To do this, we need to put tick marks around the code blocks so that they are preserved while the content outside of the tick marks is generated via TiddlyWiki's WikiText stuff.

Before we go further, let's clone the journals-feed tiddler and name the new tiddler "journals-feed-atom", as I hope to make a general atom feed for journals/etc.

I've now modified the new tiddler in accordance with this article regarding making atom feeds. Generating the atom XML file works, as expected, with the following command:

tiddlywiki publicwiki --render "journals-feed-atom" journals-feed-atom.xml text/plain "" exportFilter "[tag[Journal]]"

Whoops! I need to add a way of sorting this so that the newest entries are listed first! I'll add this to both templates. The docs for Filter Operators will be invaluable to me, here.

Or not. I couldn't figure out which thing fit what I needed, so I jumped over to Tobias Beer's TiddlyWiki Filter Examples page and all-but immediately found what I needed: to add !sort[modified] to the templates' list filters.

I'll work in the tiddler 14th-July-2018: RSSforStaticTiddlyWiki, Atom feed dev on finishing up the atom feed itself, as that'll be a big discussion.

Let's get the raw form:




Figure out how to:

Use filter to get only 1 post that matches filter, to set the Modified/Updated date of the feed to the date of the modification of the most recent post listed in the feed, as opposed to the date of modification of the tiddler for which the feed is being made for/from (assuming that I wish to offer feeds based upon some one particular Tiddler [tag]; could expand in the future to include multiple tags).

Figure out how to combine text output with WikiText stuff, like widgets

I was unintentionally wise in choosing "the template tiddler $:/core/templates/static.template.html as a basis for creating a multi-tiddler output", as I meant to use alltiddlers instead, which is a supreme deadend and not even really what we need.