From 7390a7a0721d9985c88efec1fd0e3a19d0368c82 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 17 Oct 2008 20:47:32 -0400 Subject: relativedate: New javascript-alicious plugin that makes all dates display relative, in a very nice way, if I say so myself. --- IkiWiki/Plugin/relativedate.pm | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 IkiWiki/Plugin/relativedate.pm (limited to 'IkiWiki/Plugin/relativedate.pm') diff --git a/IkiWiki/Plugin/relativedate.pm b/IkiWiki/Plugin/relativedate.pm new file mode 100644 index 000000000..99265676b --- /dev/null +++ b/IkiWiki/Plugin/relativedate.pm @@ -0,0 +1,41 @@ +#!/usr/bin/perl +package IkiWiki::Plugin::relativedate; + +use warnings; +use strict; +use IkiWiki 2.00; + +sub import { #{{{ + add_underlay("javascript"); + hook(type => "format", id => "relativedate", call => \&format); +} # }}} + +sub getsetup () { #{{{ + return + plugin => { + safe => 1, + rebuild => 1, + }, +} #}}} + +sub format (@) { #{{{ + my %params=@_; + + if (! ($params{content}=~s!^()!$1.include_javascript($params{page})!em)) { + # no tag, probably in preview mode + $params{content}=include_javascript($params{page}, 1).$params{content}; + } + return $params{content}; +} # }}} + +sub include_javascript ($;$) { #{{{ + my $page=shift; + my $absolute=shift; + + return ''."\n". + ''; +} #}}} + +1 -- cgit v1.2.3