From d991ccf134acbc2eec83b8409a5911744f1956eb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Jan 2011 17:15:38 -0400 Subject: [PATCH] use cgitemplate, remove misctemplate --- IkiWiki.pm | 33 ------------------- IkiWiki/Plugin/comments.pm | 4 +-- IkiWiki/Plugin/getsource.pm | 4 +-- IkiWiki/Plugin/goto.pm | 2 +- IkiWiki/Plugin/openid.pm | 2 +- IkiWiki/Plugin/search.pm | 11 ++++--- IkiWiki/Plugin/websetup.pm | 4 +-- debian/changelog | 11 ++++--- ...r_https_in_urls_to_allow_serving_both.mdwn | 4 ++- 9 files changed, 23 insertions(+), 52 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index 35e64d815..799236f35 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1916,39 +1916,6 @@ sub template ($;@) { 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 ($$) { my $template=shift; my $page=shift; diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 156d71daf..1287590a7 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -504,7 +504,7 @@ sub editcomment ($$) { IkiWiki::saveindex(); IkiWiki::printheader($session); - print IkiWiki::misctemplate(gettext(gettext("comment stored for moderation")), + print IkiWiki::cgitemplate($cgi, gettext(gettext("comment stored for moderation")), "

". gettext("Your comment will be posted after moderator review"). "

"); @@ -660,7 +660,7 @@ sub commentmoderation ($$) { IkiWiki::run_hooks(format => sub { $out = shift->(page => "", content => $out); }); - print IkiWiki::misctemplate(gettext("comment moderation"), $out); + print IkiWiki::cgitemplate($cgi, gettext("comment moderation"), $out); exit; } diff --git a/IkiWiki/Plugin/getsource.pm b/IkiWiki/Plugin/getsource.pm index b362de726..0a21413bd 100644 --- a/IkiWiki/Plugin/getsource.pm +++ b/IkiWiki/Plugin/getsource.pm @@ -61,7 +61,7 @@ sub cgi_getsource ($) { IkiWiki::cgi_custom_failure( $cgi, "404 Not Found", - IkiWiki::misctemplate(gettext("missing page"), + IkiWiki::cgitemplate($cgi, gettext("missing page"), "

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

". sprintf(gettext("%s is an attachment, not a page."), htmllink("", "", $page)). diff --git a/IkiWiki/Plugin/goto.pm b/IkiWiki/Plugin/goto.pm index 0eb83fc20..6b596ac8b 100644 --- a/IkiWiki/Plugin/goto.pm +++ b/IkiWiki/Plugin/goto.pm @@ -56,7 +56,7 @@ sub cgi_goto ($;$) { IkiWiki::cgi_custom_failure( $q, "404 Not Found", - IkiWiki::misctemplate(gettext("missing page"), + IkiWiki::cgitemplate($q, gettext("missing page"), "

". sprintf(gettext("The page %s does not exist."), htmllink("", "", $page)). diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm index ce0990e40..bd67384f2 100644 --- a/IkiWiki/Plugin/openid.pm +++ b/IkiWiki/Plugin/openid.pm @@ -84,7 +84,7 @@ sub openid_selector { ); IkiWiki::printheader($session); - print IkiWiki::misctemplate("signin", $template->output); + print IkiWiki::cgitemplate($q, "signin", $template->output); exit; } diff --git a/IkiWiki/Plugin/search.pm b/IkiWiki/Plugin/search.pm index 78eb750b5..3f0b7c9ad 100644 --- a/IkiWiki/Plugin/search.pm +++ b/IkiWiki/Plugin/search.pm @@ -227,20 +227,21 @@ sub setupfiles () { "database_dir .\n". "template_dir ./templates\n"); - # Avoid omega interpreting anything in the misctemplate + # Avoid omega interpreting anything in the cgitemplate # 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 ); eval q{use HTML::Entities}; error $@ if $@; - $misctemplate=encode_entities($misctemplate, '\$'); + $template=encode_entities($template, '\$'); my $querytemplate=readfile(IkiWiki::template_file("searchquery.tmpl")); - $misctemplate=~s/\0/$querytemplate/; + $template=~s/\0/$querytemplate/; writefile("query", $config{wikistatedir}."/xapian/templates", - $misctemplate); + $template); $setup=1; } } diff --git a/IkiWiki/Plugin/websetup.pm b/IkiWiki/Plugin/websetup.pm index 6a5190301..0a3d90aec 100644 --- a/IkiWiki/Plugin/websetup.pm +++ b/IkiWiki/Plugin/websetup.pm @@ -447,10 +447,10 @@ sub showform ($$) { IkiWiki::saveindex(); 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. my $divider="\0"; - my $html=IkiWiki::misctemplate("setup", $divider); + my $html=IkiWiki::cgitemplate($cgi, "setup", $divider); IkiWiki::printheader($session); my ($head, $tail)=split($divider, $html, 2); print $head."

\n";
diff --git a/debian/changelog b/debian/changelog
index 4ed9bb8b2..4cf0a2965 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,15 +3,16 @@ ikiwiki (3.20101232) UNRELEASED; urgency=low
   * tag: Do not include tagbase in rss/atom category tags. (Giuseppe Bilotta)
   * tag: Improve display of tags with a slash in their names.
     (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
     changes in last release.
-  * Temporarily revert one part of the multiple url support in the last
-    release. Non-edit pages are now back to having `` set to
-    the site's main url.
+  * Fix `` output by cgi to have a full url again, broken by last
+    release.
   * Fix permalinks to recentchanges items and comments, broken by last
     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   Tue, 04 Jan 2011 16:00:55 -0400
 
diff --git a/doc/todo/want_to_avoid_ikiwiki_using_http_or_https_in_urls_to_allow_serving_both.mdwn b/doc/todo/want_to_avoid_ikiwiki_using_http_or_https_in_urls_to_allow_serving_both.mdwn
index 143bf0edc..534a099b6 100644
--- a/doc/todo/want_to_avoid_ikiwiki_using_http_or_https_in_urls_to_allow_serving_both.mdwn
+++ b/doc/todo/want_to_avoid_ikiwiki_using_http_or_https_in_urls_to_allow_serving_both.mdwn
@@ -1,6 +1,6 @@
 ## current status
 
-99% of the way there, but:
+[[done]] again! :)
 
 * CGI pages, with the exception of edit pages, set `` to
   `$config{url}`
@@ -15,6 +15,8 @@
   generate a better baseurl. Not sure yet what to do; may have to thread
   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
   will redirect to the `$config{url}`-based url, since the
   permalinks are made to be absolute urls now.