Package: ikiwiki
Version: 2.9
Severity: wishlist
Tags: patch
http://cairographics.org is currently using a slightly patched version
of ikiwiki. This means that Carl has to re-apply his patches when an
ikiwiki update is installed on fd.org. I would like to submit the
changes that might be suitable for upstream.
Subject: [PATCH] Allow DATE as a template parameter (with format controlled by
dateformat setting)
---
IkiWiki.pm | 12 +++++++++++-
Plugin/inline.pm | 1 +
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 953ad5a..71f502f 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -16,7 +16,7 @@ use vars qw{%config %links %oldlinks %pagemtime %pagectime
%pagecase
use Exporter q{import};
our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match
bestlink htmllink readfile writefile pagetype srcfile pagename
- displaytime will_render gettext urlto targetpage
+ displaytime displaydate will_render gettext urlto targetpage
%config %links %renderedfiles %pagesources %destsources);
our $VERSION = 2.00; # plugin interface version, next is ikiwiki version
our $version="2.00";my $installdir="/usr";
@@ -70,6 +70,7 @@ sub defaultconfig () { #{{{
plugin => [qw{mdwn inline htmlscrubber passwordauth openid signinedit
lockedit conditional}],
timeformat => '%c',
+ dateformat => '%x',
locale => undef,
sslcookie => 0,
httpauth => 0,
@@ -446,6 +447,15 @@ sub displaytime ($) { #{{{
$config{timeformat}, localtime($time)));
} #}}}
+sub displaydate ($) { #{{{
+ my $time=shift;
+
+ # strftime doesn't know about encodings, so make sure
+ # its output is properly treated as utf8
+ return decode_utf8(POSIX::strftime(
+ $config{dateformat}, localtime($time)));
+} #}}}
+
sub beautify_url ($) { #{{{
my $url=shift;
diff --git a/Plugin/inline.pm b/Plugin/inline.pm
index cdecf51..2389dc6 100644
--- a/Plugin/inline.pm
+++ b/Plugin/inline.pm
@@ -148,6 +148,7 @@ sub preprocess_inline (@) { #{{{
$template->param(pageurl =>
urlto(bestlink($params{page}, $page), $params{destpage}));
$template->param(title => pagetitle(basename($page)));
$template->param(ctime =>
displaytime($pagectime{$page}));
+ $template->param(date =>
displaydate($pagectime{$page}));
if ($actions) {
my $file = $pagesources{$page};
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]