use cgitemplate, remove misctemplate

master
Joey Hess 2011-01-05 17:15:38 -04:00
parent 4a6ac6b485
commit d991ccf134
9 changed files with 23 additions and 52 deletions

View File

@ -1916,39 +1916,6 @@ sub template ($;@) {
template_depends(shift, undef, @_); template_depends(shift, undef, @_);
} }
sub misctemplate ($$;@) {
my $title=shift;
my $content=shift;
my %params=@_;
my $template=template("page.tmpl");
my $page="";
if (exists $params{page}) {
$page=delete $params{page};
}
run_hooks(pagetemplate => sub {
shift->(
page => $page,
destpage => $page,
template => $template,
);
});
templateactions($template, "");
$template->param(
dynamic => 1,
title => $title,
wikiname => $config{wikiname},
content => $content,
baseurl => $config{url}.'/',
html5 => $config{html5},
%params,
);
return $template->output;
}
sub templateactions ($$) { sub templateactions ($$) {
my $template=shift; my $template=shift;
my $page=shift; my $page=shift;

View File

@ -504,7 +504,7 @@ sub editcomment ($$) {
IkiWiki::saveindex(); IkiWiki::saveindex();
IkiWiki::printheader($session); IkiWiki::printheader($session);
print IkiWiki::misctemplate(gettext(gettext("comment stored for moderation")), print IkiWiki::cgitemplate($cgi, gettext(gettext("comment stored for moderation")),
"<p>". "<p>".
gettext("Your comment will be posted after moderator review"). gettext("Your comment will be posted after moderator review").
"</p>"); "</p>");
@ -660,7 +660,7 @@ sub commentmoderation ($$) {
IkiWiki::run_hooks(format => sub { IkiWiki::run_hooks(format => sub {
$out = shift->(page => "", content => $out); $out = shift->(page => "", content => $out);
}); });
print IkiWiki::misctemplate(gettext("comment moderation"), $out); print IkiWiki::cgitemplate($cgi, gettext("comment moderation"), $out);
exit; exit;
} }

View File

@ -61,7 +61,7 @@ sub cgi_getsource ($) {
IkiWiki::cgi_custom_failure( IkiWiki::cgi_custom_failure(
$cgi, $cgi,
"404 Not Found", "404 Not Found",
IkiWiki::misctemplate(gettext("missing page"), IkiWiki::cgitemplate($cgi, gettext("missing page"),
"<p>". "<p>".
sprintf(gettext("The page %s does not exist."), sprintf(gettext("The page %s does not exist."),
htmllink("", "", $page)). htmllink("", "", $page)).
@ -72,7 +72,7 @@ sub cgi_getsource ($) {
if (! defined pagetype($pagesources{$page})) { if (! defined pagetype($pagesources{$page})) {
IkiWiki::cgi_custom_failure( IkiWiki::cgi_custom_failure(
$cgi->header(-status => "403 Forbidden"), $cgi->header(-status => "403 Forbidden"),
IkiWiki::misctemplate(gettext("not a page"), IkiWiki::cgitemplate($cgi, gettext("not a page"),
"<p>". "<p>".
sprintf(gettext("%s is an attachment, not a page."), sprintf(gettext("%s is an attachment, not a page."),
htmllink("", "", $page)). htmllink("", "", $page)).

View File

@ -56,7 +56,7 @@ sub cgi_goto ($;$) {
IkiWiki::cgi_custom_failure( IkiWiki::cgi_custom_failure(
$q, $q,
"404 Not Found", "404 Not Found",
IkiWiki::misctemplate(gettext("missing page"), IkiWiki::cgitemplate($q, gettext("missing page"),
"<p>". "<p>".
sprintf(gettext("The page %s does not exist."), sprintf(gettext("The page %s does not exist."),
htmllink("", "", $page)). htmllink("", "", $page)).

View File

@ -84,7 +84,7 @@ sub openid_selector {
); );
IkiWiki::printheader($session); IkiWiki::printheader($session);
print IkiWiki::misctemplate("signin", $template->output); print IkiWiki::cgitemplate($q, "signin", $template->output);
exit; exit;
} }

View File

@ -227,20 +227,21 @@ sub setupfiles () {
"database_dir .\n". "database_dir .\n".
"template_dir ./templates\n"); "template_dir ./templates\n");
# Avoid omega interpreting anything in the misctemplate # Avoid omega interpreting anything in the cgitemplate
# as an omegascript command. # as an omegascript command.
my $misctemplate=IkiWiki::misctemplate(gettext("search"), "\0", eval q{use IkiWiki::CGI};
my $template=IkiWiki::cgitemplate(undef, gettext("search"), "\0",
searchform => "", # avoid showing the small search form searchform => "", # avoid showing the small search form
); );
eval q{use HTML::Entities}; eval q{use HTML::Entities};
error $@ if $@; error $@ if $@;
$misctemplate=encode_entities($misctemplate, '\$'); $template=encode_entities($template, '\$');
my $querytemplate=readfile(IkiWiki::template_file("searchquery.tmpl")); my $querytemplate=readfile(IkiWiki::template_file("searchquery.tmpl"));
$misctemplate=~s/\0/$querytemplate/; $template=~s/\0/$querytemplate/;
writefile("query", $config{wikistatedir}."/xapian/templates", writefile("query", $config{wikistatedir}."/xapian/templates",
$misctemplate); $template);
$setup=1; $setup=1;
} }
} }

View File

@ -447,10 +447,10 @@ sub showform ($$) {
IkiWiki::saveindex(); IkiWiki::saveindex();
IkiWiki::unlockwiki(); IkiWiki::unlockwiki();
# Print the top part of a standard misctemplate, # Print the top part of a standard cgitemplate,
# then show the rebuild or refresh, live. # then show the rebuild or refresh, live.
my $divider="\0"; my $divider="\0";
my $html=IkiWiki::misctemplate("setup", $divider); my $html=IkiWiki::cgitemplate($cgi, "setup", $divider);
IkiWiki::printheader($session); IkiWiki::printheader($session);
my ($head, $tail)=split($divider, $html, 2); my ($head, $tail)=split($divider, $html, 2);
print $head."<pre>\n"; print $head."<pre>\n";

11
debian/changelog vendored
View File

@ -3,15 +3,16 @@ ikiwiki (3.20101232) UNRELEASED; urgency=low
* tag: Do not include tagbase in rss/atom category tags. (Giuseppe Bilotta) * tag: Do not include tagbase in rss/atom category tags. (Giuseppe Bilotta)
* tag: Improve display of tags with a slash in their names. * tag: Improve display of tags with a slash in their names.
(Giuseppe Bilotta) (Giuseppe Bilotta)
* Fix base url when previewing. Was broken by base changes in last release.
* Fix redirect to use a full url. Was broken (in theory) by baseurl * Fix redirect to use a full url. Was broken (in theory) by baseurl
changes in last release. changes in last release.
* Temporarily revert one part of the multiple url support in the last * Fix `<base>` output by cgi to have a full url again, broken by last
release. Non-edit pages are now back to having `<base>` set to release.
the site's main url.
* Fix permalinks to recentchanges items and comments, broken by last * Fix permalinks to recentchanges items and comments, broken by last
release. release.
* Export three cgi env vars needed for CGI->url to work. * Export three cgi env vars needed for CGI->url to work. Fixed
openid breakage from last release.
* Removed `IkiWiki::misctemplate()` function. Any plugins using
it should use `IkiWiki::cgitemplate()` instead.
-- Joey Hess <joeyh@debian.org> Tue, 04 Jan 2011 16:00:55 -0400 -- Joey Hess <joeyh@debian.org> Tue, 04 Jan 2011 16:00:55 -0400

View File

@ -1,6 +1,6 @@
## current status ## current status
99% of the way there, but: [[done]] again! :)
* CGI pages, with the exception of edit pages, set `<base>` to * CGI pages, with the exception of edit pages, set `<base>` to
`$config{url}` `$config{url}`
@ -15,6 +15,8 @@
generate a better baseurl. Not sure yet what to do; may have to thread generate a better baseurl. Not sure yet what to do; may have to thread
a cgi parameter through all the calls to misctemplate. --[[Joey]] a cgi parameter through all the calls to misctemplate. --[[Joey]]
> Fixed, cgitemplate is used now. --[[Joey]]
* Using `do=goto` to go to a comment or recentchanges item * Using `do=goto` to go to a comment or recentchanges item
will redirect to the `$config{url}`-based url, since the will redirect to the `$config{url}`-based url, since the
permalinks are made to be absolute urls now. permalinks are made to be absolute urls now.