diff options
author | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-05-29 05:09:43 +0000 |
---|---|---|
committer | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-05-29 05:09:43 +0000 |
commit | 7a1e12675ec5f1ea605d4de06a0b82079073fb20 (patch) | |
tree | e7389f14c03af4a0b4e70cda4b84cc6216144393 | |
parent | 890257521ebb39dea0630143e60594d577128f1c (diff) |
* Add --timeformat config option to allow changing how dates are displayed.
Note that as a side effect, dates will now be displayed using the local
timezone, not as GMT.
-rw-r--r-- | IkiWiki.pm | 1 | ||||
-rw-r--r-- | IkiWiki/Plugin/inline.pm | 2 | ||||
-rw-r--r-- | IkiWiki/Render.pm | 14 | ||||
-rw-r--r-- | debian/changelog | 8 | ||||
-rw-r--r-- | doc/ikiwiki.setup | 2 | ||||
-rw-r--r-- | doc/todo/done/strftime.mdwn (renamed from doc/todo/strftime.mdwn) | 0 | ||||
-rw-r--r-- | doc/usage.mdwn | 5 | ||||
-rwxr-xr-x | ikiwiki | 1 |
8 files changed, 31 insertions, 2 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm index 5424d435c..ce9542f62 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -42,6 +42,7 @@ sub defaultconfig () { #{{{ adminuser => undef, adminemail => undef, plugin => [qw{inline htmlscrubber}], + timeformat => '%c', } #}}} sub checkconfig () { #{{{ diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 8b67bfa61..6ecdf0d38 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -62,7 +62,7 @@ sub preprocess_inline (@) { #{{{ $template->param(pagelink => htmllink($params{page}, $params{page}, $page)); $template->param(content => get_inline_content($params{page}, $page)) if $params{archive} eq "no"; - $template->param(ctime => scalar(gmtime($pagectime{$page}))); + $template->param(ctime => displaytime($pagectime{$page})); $ret.=$template->output; } diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index df08eb49c..c5922c933 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -202,7 +202,7 @@ sub genpage ($$$) { #{{{ parentlinks => [parentlinks($page)], content => $content, backlinks => [backlinks($page)], - mtime => scalar(gmtime($mtime)), + mtime => displaytime($mtime), styleurl => styleurl($page), ); @@ -223,6 +223,18 @@ sub check_overwrite ($$) { #{{{ } } #}}} +sub displaytime ($) { #{{{ + my $time=shift; + + if ($config{timeformat} eq '%c') { + return scalar(localtime($time)); # optimisation + } + else { + eval q{use POSIX}; + return POSIX::strftime($config{timeformat}, localtime($time)); + } +} #}}} + sub mtime ($) { #{{{ my $file=shift; diff --git a/debian/changelog b/debian/changelog index 10796a63a..f7a381e41 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +ikiwiki (1.5) UNRELEASED; urgency=low + + * Add --timeformat config option to allow changing how dates are displayed. + Note that as a side effect, dates will now be displayed using the local + timezone, not as GMT. + + -- Joey Hess <joeyh@debian.org> Mon, 29 May 2006 00:50:34 -0400 + ikiwiki (1.4) unstable; urgency=low * Tell HTML::Scrubber to treat "/" as a valid attribute which is its diff --git a/doc/ikiwiki.setup b/doc/ikiwiki.setup index dee4ca1d5..cda524ae1 100644 --- a/doc/ikiwiki.setup +++ b/doc/ikiwiki.setup @@ -50,6 +50,8 @@ use IkiWiki::Setup::Standard { rss => 1, # Include discussion links on all pages? discussion => 1, + # Time format (for strftime) + #timeformat => '%c', # To change the enabled plugins, edit this list #plugin => [qw{pagecount inline brokenlinks search smiley # htmlscrubber}], diff --git a/doc/todo/strftime.mdwn b/doc/todo/done/strftime.mdwn index 305f833be..305f833be 100644 --- a/doc/todo/strftime.mdwn +++ b/doc/todo/done/strftime.mdwn diff --git a/doc/usage.mdwn b/doc/usage.mdwn index c0fab5232..011cf53a2 100644 --- a/doc/usage.mdwn +++ b/doc/usage.mdwn @@ -177,6 +177,11 @@ These options configure the wiki. Enables or disables "Discussion" links from being added to the header of every page. The links are enabled by default. +* --timeformat format + + Specify how to display the time or date. The format string is passed to the + strftime(3) function. + * --verbose Be vebose about what is being done. @@ -37,6 +37,7 @@ sub getconfig () { #{{{ "svnrepo" => \$config{svnrepo}, "svnpath" => \$config{svnpath}, "adminemail=s" => \$config{adminemail}, + "timeformat=s" => \$config{timeformat}, "exclude=s@" => sub { $config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/; }, |