]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
Add meta field "updated", which can alter the <updated> Atom element
authorSimon McVittie <smcv@ http://smcv.pseudorandom.co.uk/>
Sun, 18 Jan 2009 16:27:43 +0000 (16:27 +0000)
committerSimon McVittie <smcv@ http://smcv.pseudorandom.co.uk/>
Sun, 18 Jan 2009 21:58:24 +0000 (21:58 +0000)
Some aggregators, like Planet, sort by mtime rather than ctime. This
means that posts with modified content come to the top (which seems odd
to me, but is presumably what the aggregator's author or operator
wants), but it also means that posts with insignificant edits (like
adding tags) come to the top too. Atom defines <updated> to be the date
of the last *significant* change, so it's fine that ikiwiki defaults to
using the mtime, but it would be good to have a way for the author to
say "that edit was insignificant, don't use that mtime".

IkiWiki/Plugin/inline.pm
IkiWiki/Plugin/meta.pm
doc/ikiwiki/directive/meta.mdwn

index d8b5f8548251f4d04332fb0f7d9e0bbd555993af..2205ebffc48cda2f9ccd6fab71dec170765fa880 100644 (file)
@@ -519,9 +519,15 @@ sub genfeed ($$$$$@) {
                        mdate_3339 => date_3339($pagemtime{$p}),
                );
 
-               if (exists $pagestate{$p} &&
-                   exists $pagestate{$p}{meta}{guid}) {
-                       $itemtemplate->param(guid => $pagestate{$p}{meta}{guid});
+               if (exists $pagestate{$p}) {
+                       if (exists $pagestate{$p}{meta}{guid}) {
+                               $itemtemplate->param(guid => $pagestate{$p}{meta}{guid});
+                       }
+
+                       if (exists $pagestate{$p}{meta}{updated}) {
+                               $itemtemplate->param(mdate_822 => date_822($pagestate{$p}{meta}{updated}));
+                               $itemtemplate->param(mdate_3339 => date_3339($pagestate{$p}{meta}{updated}));
+                       }
                }
 
                if ($itemtemplate->query(name => "enclosure")) {
index 15bb29b3fc8450e693fe4a3005f2f3925ab0f00b..4a22fed3057015156c27d9f8159e9f4b47e3a633 100644 (file)
@@ -128,6 +128,13 @@ sub preprocess (@) {
                        $IkiWiki::pagectime{$page}=$time if defined $time;
                }
        }
+       elsif ($key eq 'updated') {
+               eval q{use Date::Parse};
+               if (! $@) {
+                       my $time = str2time($value);
+                       $pagestate{$page}{meta}{updated}=$time if defined $time;
+               }
+       }
 
        if (! defined wantarray) {
                # avoid collecting duplicate data during scan pass
index 74db319435b346ce8aee6854717947c72c4d389e..f29a118bfea91d9957c30022312e558bc3b8b980 100644 (file)
@@ -139,6 +139,15 @@ Supported fields:
   pages unchanged and avoid_flooding_aggregators
   (see [[!iki tips/howto_avoid_flooding_aggregators]]).
 
+* updated
+
+  Specifies a fake modification time for a page, to be output into RSS and
+  Atom feeds. This is useful to avoid flooding aggregators that sort by
+  modification time, like Planet: for instance, when editing an old blog post
+  to add tags, you could set `updated` to be one second later than the original
+  value. The date/time can be given in any format that
+  [[!cpan TimeDate]] can understand, just like the `date` field.
+
 If the field is not one of the above predefined fields, the metadata will be
 written to the generated html page as a &lt;meta&gt; header. However, this
 won't be allowed if the [[!iki plugins/htmlscrubber desc=htmlscrubber]] plugin is enabled,