Building this Website (5. tiddlers' date)

Saturday, May 2, 2015

This is a series of posts which technically describes how Not Even Odd is built. It is primarily meant as a guide for static website creation using TiddlyWiki.

This article is based on this post from Jim Lehmer in the TiddlyWiki community forum.

In TiddlyWiki, when you create a new tiddler and save it, the subtitle will read something like "1 second ago", that is, the last modified time is displayed as a "relative date." It then ages over a period of minutes, hours, days, weeks and so on. The problem with that behavior on a static site is that the date gets "frozen in time" when you generate a static site.

One way to correct this is to override the shadow tiddler $:/core/ui/ViewTemplate/subtitle (local) (v5.1.8) (current TW), which looks like this out of the box:

<div class="tc-subtitle">
<$link to={{!!modifier}}>
<$view field="modifier"/>
</$link> <$view field="modified" format="relativedate"/>

and replace it something like this to always show a date similar to "Monday, April 27, 2015":

<div class="tc-subtitle">
<$link to={{!!modifier}}>
<$view field="modifier"/>
</$link> <$view field="modified" format="date" template="DDD, MMM DD, YYYY"/></div>

alternatively, you might want to use created instead of modified

Modifying this shadow tiddler will affect tiddlers date display in the TiddlyWiki used for editing the site, which is probably undesirable, so I again override the shadow tiddler from within the static generation script:

cp -i static_date tiddlers/\$__core_ui_ViewTemplate_subtitle.tid

tiddliwiki --rendertiddlers ...   # static generation

rm -f tiddlers/\$__core_ui_ViewTemplate_subtitle.tid


Note: Jeremy Ruston, the creator of TiddlyWiki, mentionned that he'd like to replace the current relative date with a relativedate widget that would then automatically update (and renders statically as a normal, absolute date). He created this ticket. If/when this ticket gets implemented this probably would make a tiddler's date correction unecessary.

previous: tags
next: external files

Not Even Odd

Musings and mumblings of a random nerd

Last 10 Posts:

Free Software
Building this Website (7. plugins)
Building this Website (6. external files)
Building this Website (5. tiddlers' date)
Building this Website (4. tags)
Building this Website (3. navigation)
Building this Website (2. template)
Building this Website (1. content selection)


see all tags
    All Posts
    (alphabetically | chronologically)

Follow:          ...

Site Policy