From a3a50dbf6d96e7441e5e8ec183e40134bc4eb618 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Mon, 3 Nov 2014 17:26:51 +0000 Subject: [PATCH] Extend timeline macro to be able to use different date fields --- core/wiki/macros/timeline.tid | 8 ++--- .../prerelease/tiddlers/TimelineMacro.tid | 34 +++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 editions/prerelease/tiddlers/TimelineMacro.tid diff --git a/core/wiki/macros/timeline.tid b/core/wiki/macros/timeline.tid index c385c9500..2a6fdb07f 100644 --- a/core/wiki/macros/timeline.tid +++ b/core/wiki/macros/timeline.tid @@ -1,12 +1,12 @@ title: $:/core/macros/timeline tags: $:/tags/Macro -\define timeline(limit:"100",format:"DDth MMM YYYY",subfilter:"") +\define timeline(limit:"100",format:"DDth MMM YYYY",subfilter:"",dateField:"modified")
-<$list filter="[!is[system]$subfilter$has[modified]!sort[modified]limit[$limit$]eachday[modified]]"> +<$list filter="[!is[system]$subfilter$has[dateField]!sort[dateField]limit[$limit$]eachday[dateField]]">
-<$view field="modified" format="date" template="$format$"/> -<$list filter="[sameday{!!modified}!is[system]$subfilter$!sort[modified]]"> +<$view field="dateField" format="date" template="$format$"/> +<$list filter="[sameday{!!dateField}!is[system]$subfilter$!sort[dateField]]">
<$link to={{!!title}}> <$view field="title"/> diff --git a/editions/prerelease/tiddlers/TimelineMacro.tid b/editions/prerelease/tiddlers/TimelineMacro.tid new file mode 100644 index 000000000..2c7be7ea9 --- /dev/null +++ b/editions/prerelease/tiddlers/TimelineMacro.tid @@ -0,0 +1,34 @@ +title: TimelineMacro +tags: Macros +modified: 20141103172520228 +caption: timeline + +The timeline macro produces a list of tiddlers in reverse chronological order of modification date that is grouped by the date of the day of modification. + +! Parameters + +|!Position |!Name |!Description |!Default | +|1st |limit |The maximum number of tiddlers to list (see below) |100 | +|2nd |format |A DateFormat string for formatting the date |DDth MMM YYYY | +|3rd |subfilter |A subfilter to include in the timeline filter (see below) | | +|4th |dateField |Optional name of date field to use |modified | + +The subfilter and limit parameters are spliced into the filter string like this: + +``` +[!is[system]$subfilter$has[modified]!sort[modified]limit[$limit$]eachday[modified]] +``` + +To restrict the timeline to a particular tag, the subfilter can be set to something like `tag[mytag]`: + +``` +<> +``` + +Note that the timeline macro does not truncate the entries for a particular day, instead always displaying all the tiddlers under each displayed day heading. This means that the limit parameter works in an unexpected way because it is possible for more than the specified number of tiddlers to be displayed. + +! Examples + +<$macrocall $name="wikitext-example-without-html" +src="<> +"/>