aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki.pm22
-rw-r--r--IkiWiki/Plugin/comments.pm2
-rw-r--r--IkiWiki/Plugin/inline.pm12
-rw-r--r--IkiWiki/Plugin/relativedate.pm15
-rw-r--r--IkiWiki/Render.pm2
-rw-r--r--debian/changelog7
-rw-r--r--doc/bugs/html5_support.mdwn3
-rw-r--r--doc/plugins/write.mdwn5
8 files changed, 49 insertions, 19 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index ed57710bb..c428de77f 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -998,10 +998,18 @@ sub abs2rel ($$) {
return $ret;
}
-sub displaytime ($;$) {
+sub displaytime ($;$$) {
# 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 ($;$) {
@@ -1017,6 +1025,16 @@ sub formattime ($;$) {
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;
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
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index 5923f5e74..cf6943e7d 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -136,7 +136,7 @@ sub genpage ($$) {
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},
);
diff --git a/debian/changelog b/debian/changelog
index 6962e5171..8158429a0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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.
diff --git a/doc/bugs/html5_support.mdwn b/doc/bugs/html5_support.mdwn
index dca60d57e..386a3094a 100644
--- a/doc/bugs/html5_support.mdwn
+++ b/doc/bugs/html5_support.mdwn
@@ -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]]
+> 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.
diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn
index a9ea7db73..5e7042c3b 100644
--- a/doc/plugins/write.mdwn
+++ b/doc/plugins/write.mdwn
@@ -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.
-### `displaytime($;$)`
+### `displaytime($;$$)`
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.