1 How about a direct link from the page header to the source of the latest version, to avoid the need to either use edit or navigate to the current version via the history link?
3 I'd like this too (and might try to implement it). -- [[jondowland]]
5 I just implemented this. There is one [[patch]] to the default page template, and a new plugin. -- [[Will]]
9 diff --git a/templates/page.tmpl b/templates/page.tmpl
10 index f2f9c34..3176bed 100644
11 --- a/templates/page.tmpl
12 +++ b/templates/page.tmpl
14 <TMPL_IF NAME="HISTORYURL">
15 <li><a href="<TMPL_VAR HISTORYURL>">History</a></li>
17 +<TMPL_IF NAME="GETSOURCEURL">
18 +<li><a href="<TMPL_VAR GETSOURCEURL>">Get Source</a></li>
20 <TMPL_IF NAME="PREFSURL">
21 <li><a href="<TMPL_VAR PREFSURL>">Preferences</a></li>
27 package IkiWiki::Plugin::getsource;
32 use open qw{:utf8 :std};
35 hook(type => "getsetup", id => "getsource", call => \&getsetup);
36 hook(type => "pagetemplate", id => "getsource", call => \&pagetemplate);
37 hook(type => "sessioncgi", id => "getsource", call => \&cgi_getsource);
40 sub getsetup () { #{{{
46 getsource_mimetype => {
48 example => "application/octet-stream",
49 description => "Mime type for returned source.",
55 sub pagetemplate (@) { #{{{
58 my $page=$params{page};
59 my $template=$params{template};
61 if (length $config{cgiurl}) {
62 $template->param(getsourceurl => IkiWiki::cgiurl(do => "getsource", page => $page));
63 $template->param(have_actions => 1);
67 sub cgi_getsource ($$) { #{{{
71 # Note: we use sessioncgi rather than just cgi
72 # because we need $IkiWiki::pagesources{} to be
75 return unless (defined $cgi->param('do') &&
76 $cgi->param("do") eq "getsource");
78 IkiWiki::decode_cgi_utf8($cgi);
80 my $page=$cgi->param('page');
82 if ($IkiWiki::pagesources{$page}) {
84 my $data = IkiWiki::readfile(IkiWiki::srcfile($IkiWiki::pagesources{$page}));
86 if (! $config{getsource_mimetype}) {
87 $config{getsource_mimetype} = "text/plain";
90 print "Content-Type: $config{getsource_mimetype}\r\n";
99 error("Unable to find page source for page: $page");