]> sipb.mit.edu Git - ikiwiki.git/commitdiff
Add parameter to displaytime to specify that it is a pubdate, and in html5 mode,...
authorJoey Hess <joey@kitenet.net>
Sun, 2 May 2010 17:44:13 +0000 (13:44 -0400)
committerJoey Hess <joey@kitenet.net>
Sun, 2 May 2010 17:44:13 +0000 (13:44 -0400)
IkiWiki.pm
IkiWiki/Plugin/comments.pm
IkiWiki/Plugin/inline.pm
IkiWiki/Plugin/relativedate.pm
IkiWiki/Render.pm
debian/changelog
doc/bugs/html5_support.mdwn
doc/plugins/write.mdwn

index ed57710bbbca104294679df383b920f6d5deb6d4..c428de77f7e055390e66fcdf53301f61ac2d9382 100644 (file)
@@ -998,10 +998,18 @@ sub abs2rel ($$) {
        return $ret;
 }
 
        return $ret;
 }
 
-sub displaytime ($;$) {
+sub displaytime ($;$$) {
        # Plugins can override this function to mark up the time to
        # display.
        # Plugins can override this function to mark up the time to
        # display.
-       return '<span class="date">'.formattime(@_).'</span>';
+       my $time=formattime($_[0], $_[1]);
+       if ($config{html5}) {
+               return '<time datetime="'.date_3339($_[0]).'"'.
+                       ($_[2] ? ' pubdate' : '').
+                       '>'.$time.'</time>';
+       }
+       else {
+               return '<span class="date">'.$time.'</span>';
+       }
 }
 
 sub formattime ($;$) {
 }
 
 sub formattime ($;$) {
@@ -1017,6 +1025,16 @@ sub formattime ($;$) {
        return decode_utf8(POSIX::strftime($format, localtime($time)));
 }
 
        return decode_utf8(POSIX::strftime($format, localtime($time)));
 }
 
+sub date_3339 ($) {
+       my $time=shift;
+
+       my $lc_time=POSIX::setlocale(&POSIX::LC_TIME);
+       POSIX::setlocale(&POSIX::LC_TIME, "C");
+       my $ret=POSIX::strftime("%Y-%m-%dT%H:%M:%SZ", gmtime($time));
+       POSIX::setlocale(&POSIX::LC_TIME, $lc_time);
+       return $ret;
+}
+
 sub beautify_urlpath ($) {
        my $url=shift;
 
 sub beautify_urlpath ($) {
        my $url=shift;
 
index f7dc99dcacd32decee2dd5845d139868758603bc..02f1d93011f0f3afda8ede7b4c67ddd047b5f438 100644 (file)
@@ -672,7 +672,7 @@ sub previewcomment ($$$) {
 
        my $template = template("comment.tmpl");
        $template->param(content => $preview);
 
        my $template = template("comment.tmpl");
        $template->param(content => $preview);
-       $template->param(ctime => displaytime($time));
+       $template->param(ctime => displaytime($time, undef, 1));
 
        IkiWiki::run_hooks(pagetemplate => sub {
                shift->(page => $location,
 
        IkiWiki::run_hooks(pagetemplate => sub {
                shift->(page => $location,
index 95fe9031256f3050c0902932b91e7b1e0e9570a5..2df59f414b026eab4ea4fdcf508b6dd3f58a6ae0 100644 (file)
@@ -358,7 +358,7 @@ sub preprocess_inline (@) {
                                $template->param(pageurl => urlto($page, $params{destpage}));
                                $template->param(inlinepage => $page);
                                $template->param(title => pagetitle(basename($page)));
                                $template->param(pageurl => urlto($page, $params{destpage}));
                                $template->param(inlinepage => $page);
                                $template->param(title => pagetitle(basename($page)));
-                               $template->param(ctime => displaytime($pagectime{$page}, $params{timeformat}));
+                               $template->param(ctime => displaytime($pagectime{$page}, $params{timeformat}, 1));
                                $template->param(mtime => displaytime($pagemtime{$page}, $params{timeformat}));
                                $template->param(first => 1) if $page eq $list[0];
                                $template->param(last => 1) if $page eq $list[$#list];
                                $template->param(mtime => displaytime($pagemtime{$page}, $params{timeformat}));
                                $template->param(first => 1) if $page eq $list[0];
                                $template->param(last => 1) if $page eq $list[$#list];
@@ -500,16 +500,6 @@ sub date_822 ($) {
        return $ret;
 }
 
        return $ret;
 }
 
-sub date_3339 ($) {
-       my $time=shift;
-
-       my $lc_time=POSIX::setlocale(&POSIX::LC_TIME);
-       POSIX::setlocale(&POSIX::LC_TIME, "C");
-       my $ret=POSIX::strftime("%Y-%m-%dT%H:%M:%SZ", gmtime($time));
-       POSIX::setlocale(&POSIX::LC_TIME, $lc_time);
-       return $ret;
-}
-
 sub absolute_urls ($$) {
        # sucky sub because rss sucks
        my $content=shift;
 sub absolute_urls ($$) {
        # sucky sub because rss sucks
        my $content=shift;
index 7e615f7f1685c32a2586cb3a49abfc67acea6828..fe8ef09013e0d888fcf7ff879715dfe8020e1842 100644 (file)
@@ -43,9 +43,10 @@ sub include_javascript ($;$) {
                '" type="text/javascript" charset="utf-8"></script>';
 }
 
                '" type="text/javascript" charset="utf-8"></script>';
 }
 
-sub mydisplaytime ($;$) {
+sub mydisplaytime ($;$$) {
        my $time=shift;
        my $format=shift;
        my $time=shift;
        my $format=shift;
+       my $pubdate=shift;
 
        # This needs to be in a form that can be parsed by javascript.
        # Being fairly human readable is also nice, as it will be exposed
 
        # This needs to be in a form that can be parsed by javascript.
        # Being fairly human readable is also nice, as it will be exposed
@@ -53,8 +54,16 @@ sub mydisplaytime ($;$) {
        my $gmtime=decode_utf8(POSIX::strftime("%a, %d %b %Y %H:%M:%S %z",
                        localtime($time)));
 
        my $gmtime=decode_utf8(POSIX::strftime("%a, %d %b %Y %H:%M:%S %z",
                        localtime($time)));
 
-       return '<span class="relativedate" title="'.$gmtime.'">'.
-               IkiWiki::formattime($time, $format).'</span>';
+       my $mid=' class="relativedate" title="'.$gmtime.'">'.
+               IkiWiki::formattime($time, $format);
+
+       if ($config{html5}) {
+               return '<time datetime="'.IkiWiki::date_3339($time).'"'.
+                       ($pubdate ? ' pubdate' : '').$mid.'</time>';
+       }
+       else {
+               return '<span'.$mid.'</span>';
+       }
 }
 
 1
 }
 
 1
index 5923f5e74459e53933cc6ee2112592449e2f299a..cf6943e7d705c8d4fb3b9fd40f74af5d909c6897 100644 (file)
@@ -136,7 +136,7 @@ sub genpage ($$) {
                backlinks => $backlinks,
                more_backlinks => $more_backlinks,
                mtime => displaytime($pagemtime{$page}),
                backlinks => $backlinks,
                more_backlinks => $more_backlinks,
                mtime => displaytime($pagemtime{$page}),
-               ctime => displaytime($pagectime{$page}),
+               ctime => displaytime($pagectime{$page}, undef, 1),
                baseurl => baseurl($page),
                html5 => $config{html5},
        );
                baseurl => baseurl($page),
                html5 => $config{html5},
        );
index 6962e517118303e10179fec318aca54ecd9e5eb3..8158429a0411e43c40625c4da22a815d64d6cc47 100644 (file)
@@ -1,3 +1,10 @@
+ikiwiki (3.20100502) UNRELEASED; urgency=low
+
+  * Add parameter to displaytime to specify that it is a pubdate,
+    and in html5 mode, use time tag.
+
+ -- Joey Hess <joeyh@debian.org>  Sun, 02 May 2010 13:22:50 -0400
+
 ikiwiki (3.20100501) unstable; urgency=low
 
   * TMPL_INCLUDE re-enabled for templates read from the templatedir.
 ikiwiki (3.20100501) unstable; urgency=low
 
   * TMPL_INCLUDE re-enabled for templates read from the templatedir.
index dca60d57e5162ad674b62b28fc4025c96b361748..386a3094aa1a299ae15b1f3b34491cd06c9c51dc 100644 (file)
@@ -133,6 +133,9 @@ As a workaround:
 > Also, the [[plugins/relativedate]] plugin needs to be updated to 
 > support relatatizing the contents of time elements. --[[Joey]] 
 
 > Also, the [[plugins/relativedate]] plugin needs to be updated to 
 > support relatatizing the contents of time elements. --[[Joey]] 
 
+> Done and done; in html5 mode it uses the time tag, and even 
+> adds pubdate when displaying ctimes. --[[Joey]]
+
 ## tidy plugin
 
 Will reformat html5 to html4.
 ## tidy plugin
 
 Will reformat html5 to html4.
index a9ea7db73c2864f406aafbc07aa4f665a9a2f44f..5e7042c3b5d22c9a90a0c63a02a7d8b1615f81d2 100644 (file)
@@ -938,13 +938,16 @@ search for files.
 If the directory name is not absolute, ikiwiki will assume it is in
 the parent directory of the configured underlaydir.
 
 If the directory name is not absolute, ikiwiki will assume it is in
 the parent directory of the configured underlaydir.
 
-### `displaytime($;$)`
+### `displaytime($;$$)`
 
 Given a time, formats it for display.
 
 The optional second parameter is a strftime format to use to format the
 time.
 
 
 Given a time, formats it for display.
 
 The optional second parameter is a strftime format to use to format the
 time.
 
+If the third parameter is true, this is the publication time of a page.
+(Ie, set the html5 pubdate attribute.)
+
 ### `gettext`
 
 This is the standard gettext function, although slightly optimised.
 ### `gettext`
 
 This is the standard gettext function, although slightly optimised.