enable action bar on misctemplates
So RecentChanges shows on the action bar there, convert recentchanges to use new pageactions hook, with compatability code to avoid breaking old templates.master
parent
8ff761afa2
commit
5a4c95cc35
11
IkiWiki.pm
11
IkiWiki.pm
|
@ -1748,7 +1748,6 @@ sub misctemplate ($$;@) {
|
||||||
|
|
||||||
$template->param(
|
$template->param(
|
||||||
dynamic => 1,
|
dynamic => 1,
|
||||||
have_actions => 0, # force off
|
|
||||||
title => $title,
|
title => $title,
|
||||||
wikiname => $config{wikiname},
|
wikiname => $config{wikiname},
|
||||||
content => $content,
|
content => $content,
|
||||||
|
@ -1756,6 +1755,16 @@ sub misctemplate ($$;@) {
|
||||||
html5 => $config{html5},
|
html5 => $config{html5},
|
||||||
@_,
|
@_,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
my @actions;
|
||||||
|
run_hooks(pageactions => sub {
|
||||||
|
push @actions, map { { action => $_ } }
|
||||||
|
grep { defined } shift->(page => "");
|
||||||
|
});
|
||||||
|
$template->param(actions => \@actions);
|
||||||
|
if (@actions) {
|
||||||
|
$template->param(have_actions => 1);
|
||||||
|
}
|
||||||
|
|
||||||
return $template->output;
|
return $template->output;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ sub import {
|
||||||
hook(type => "getsetup", id => "recentchanges", call => \&getsetup);
|
hook(type => "getsetup", id => "recentchanges", call => \&getsetup);
|
||||||
hook(type => "checkconfig", id => "recentchanges", call => \&checkconfig);
|
hook(type => "checkconfig", id => "recentchanges", call => \&checkconfig);
|
||||||
hook(type => "refresh", id => "recentchanges", call => \&refresh);
|
hook(type => "refresh", id => "recentchanges", call => \&refresh);
|
||||||
|
hook(type => "pageactions", id => "recentchanges", call => \&pageactions);
|
||||||
hook(type => "pagetemplate", id => "recentchanges", call => \&pagetemplate);
|
hook(type => "pagetemplate", id => "recentchanges", call => \&pagetemplate);
|
||||||
hook(type => "htmlize", id => "_change", call => \&htmlize);
|
hook(type => "htmlize", id => "_change", call => \&htmlize);
|
||||||
# Load goto to fix up links from recentchanges
|
# Load goto to fix up links from recentchanges
|
||||||
|
@ -61,14 +62,27 @@ sub refresh ($) {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Enable the recentchanges link on wiki pages.
|
# Enable the recentchanges link on wiki pages.
|
||||||
|
sub pageactions (@) {
|
||||||
|
my %params=@_;
|
||||||
|
my $page=$params{page};
|
||||||
|
|
||||||
|
if (defined $config{recentchangespage} && $config{rcs} &&
|
||||||
|
$page ne $config{recentchangespage}) {
|
||||||
|
return htmllink($page, $page, $config{recentchangespage},
|
||||||
|
gettext("RecentChanges"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Backwards compatability for templates still using
|
||||||
|
# RECENTCHANGESURL.
|
||||||
sub pagetemplate (@) {
|
sub pagetemplate (@) {
|
||||||
my %params=@_;
|
my %params=@_;
|
||||||
my $template=$params{template};
|
my $template=$params{template};
|
||||||
my $page=$params{page};
|
my $page=$params{page};
|
||||||
|
|
||||||
if (defined $config{recentchangespage} && $config{rcs} &&
|
if (defined $config{recentchangespage} && $config{rcs} &&
|
||||||
$page ne $config{recentchangespage} &&
|
$template->query(name => "recentchangesurl") &&
|
||||||
$template->query(name => "recentchangesurl")) {
|
$page ne $config{recentchangespage}) {
|
||||||
$template->param(recentchangesurl => urlto($config{recentchangespage}, $page));
|
$template->param(recentchangesurl => urlto($config{recentchangespage}, $page));
|
||||||
$template->param(have_actions => 1);
|
$template->param(have_actions => 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,9 +61,6 @@
|
||||||
<TMPL_IF EDITURL>
|
<TMPL_IF EDITURL>
|
||||||
<li><a href="<TMPL_VAR EDITURL>" rel="nofollow">Edit</a></li>
|
<li><a href="<TMPL_VAR EDITURL>" rel="nofollow">Edit</a></li>
|
||||||
</TMPL_IF>
|
</TMPL_IF>
|
||||||
<TMPL_IF RECENTCHANGESURL>
|
|
||||||
<li><a href="<TMPL_VAR RECENTCHANGESURL>">RecentChanges</a></li>
|
|
||||||
</TMPL_IF>
|
|
||||||
<TMPL_IF HISTORYURL>
|
<TMPL_IF HISTORYURL>
|
||||||
<li><a href="<TMPL_VAR HISTORYURL>">History</a></li>
|
<li><a href="<TMPL_VAR HISTORYURL>">History</a></li>
|
||||||
</TMPL_IF>
|
</TMPL_IF>
|
||||||
|
|
Loading…
Reference in New Issue