* 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.
master
joey 2006-05-29 05:09:43 +00:00
parent 890257521e
commit 7a1e12675e
8 changed files with 31 additions and 2 deletions

View File

@ -42,6 +42,7 @@ sub defaultconfig () { #{{{
adminuser => undef, adminuser => undef,
adminemail => undef, adminemail => undef,
plugin => [qw{inline htmlscrubber}], plugin => [qw{inline htmlscrubber}],
timeformat => '%c',
} #}}} } #}}}
sub checkconfig () { #{{{ sub checkconfig () { #{{{

View File

@ -62,7 +62,7 @@ sub preprocess_inline (@) { #{{{
$template->param(pagelink => htmllink($params{page}, $params{page}, $page)); $template->param(pagelink => htmllink($params{page}, $params{page}, $page));
$template->param(content => get_inline_content($params{page}, $page)) $template->param(content => get_inline_content($params{page}, $page))
if $params{archive} eq "no"; if $params{archive} eq "no";
$template->param(ctime => scalar(gmtime($pagectime{$page}))); $template->param(ctime => displaytime($pagectime{$page}));
$ret.=$template->output; $ret.=$template->output;
} }

View File

@ -202,7 +202,7 @@ sub genpage ($$$) { #{{{
parentlinks => [parentlinks($page)], parentlinks => [parentlinks($page)],
content => $content, content => $content,
backlinks => [backlinks($page)], backlinks => [backlinks($page)],
mtime => scalar(gmtime($mtime)), mtime => displaytime($mtime),
styleurl => styleurl($page), 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 ($) { #{{{ sub mtime ($) { #{{{
my $file=shift; my $file=shift;

8
debian/changelog vendored
View File

@ -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 ikiwiki (1.4) unstable; urgency=low
* Tell HTML::Scrubber to treat "/" as a valid attribute which is its * Tell HTML::Scrubber to treat "/" as a valid attribute which is its

View File

@ -50,6 +50,8 @@ use IkiWiki::Setup::Standard {
rss => 1, rss => 1,
# Include discussion links on all pages? # Include discussion links on all pages?
discussion => 1, discussion => 1,
# Time format (for strftime)
#timeformat => '%c',
# To change the enabled plugins, edit this list # To change the enabled plugins, edit this list
#plugin => [qw{pagecount inline brokenlinks search smiley #plugin => [qw{pagecount inline brokenlinks search smiley
# htmlscrubber}], # htmlscrubber}],

View File

@ -177,6 +177,11 @@ These options configure the wiki.
Enables or disables "Discussion" links from being added to the header of Enables or disables "Discussion" links from being added to the header of
every page. The links are enabled by default. 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 * --verbose
Be vebose about what is being done. Be vebose about what is being done.

View File

@ -37,6 +37,7 @@ sub getconfig () { #{{{
"svnrepo" => \$config{svnrepo}, "svnrepo" => \$config{svnrepo},
"svnpath" => \$config{svnpath}, "svnpath" => \$config{svnpath},
"adminemail=s" => \$config{adminemail}, "adminemail=s" => \$config{adminemail},
"timeformat=s" => \$config{timeformat},
"exclude=s@" => sub { "exclude=s@" => sub {
$config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/; $config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/;
}, },