aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2010-05-02 13:44:13 -0400
committerJoey Hess <joey@kitenet.net>2010-05-02 13:44:13 -0400
commit970373548fda77223ebbeb6aadbdbe4884b67cef (patch)
tree96bff9d98712ea9a0171ebe6620edea46b7f0e7d /IkiWiki/Plugin
parentf9e41d19b77f677a58bb22e1db47627cf9faa57f (diff)
downloadikiwiki-970373548fda77223ebbeb6aadbdbe4884b67cef.tar
ikiwiki-970373548fda77223ebbeb6aadbdbe4884b67cef.tar.gz
Add parameter to displaytime to specify that it is a pubdate, and in html5 mode, use time tag.
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/comments.pm2
-rw-r--r--IkiWiki/Plugin/inline.pm12
-rw-r--r--IkiWiki/Plugin/relativedate.pm15
3 files changed, 14 insertions, 15 deletions
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index f7dc99dca..02f1d9301 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -672,7 +672,7 @@ sub previewcomment ($$$) {
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,
diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm
index 95fe90312..2df59f414 100644
--- a/IkiWiki/Plugin/inline.pm
+++ b/IkiWiki/Plugin/inline.pm
@@ -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(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];
@@ -500,16 +500,6 @@ sub date_822 ($) {
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;
diff --git a/IkiWiki/Plugin/relativedate.pm b/IkiWiki/Plugin/relativedate.pm
index 7e615f7f1..fe8ef0901 100644
--- a/IkiWiki/Plugin/relativedate.pm
+++ b/IkiWiki/Plugin/relativedate.pm
@@ -43,9 +43,10 @@ sub include_javascript ($;$) {
'" type="text/javascript" charset="utf-8"></script>';
}
-sub mydisplaytime ($;$) {
+sub mydisplaytime ($;$$) {
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
@@ -53,8 +54,16 @@ sub mydisplaytime ($;$) {
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