* Patch from James Westby to add a template for the search form.
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Sat, 26 Aug 2006 21:57:59 +0000 (21:57 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Sat, 26 Aug 2006 21:57:59 +0000 (21:57 +0000)
* Cache search form for speedup.

IkiWiki/Plugin/search.pm
debian/changelog
doc/patchqueue/make-searchform-template.mdwn [deleted file]
doc/templates.mdwn
templates/searchform.tmpl [new file with mode: 0644]

index 751c75ab566e7849721ba987e2347d9bc62bb05d..c8e0dd580224a7dc810208c1ac3f294633b1f5ab 100644 (file)
@@ -27,6 +27,7 @@ sub checkconfig () { #{{{
        }
 } #}}}
 
+my $form;
 sub pagetemplate (@) { #{{{
        my %params=@_;
        my $page=$params{page};
@@ -34,15 +35,13 @@ sub pagetemplate (@) { #{{{
 
        # Add search box to page header.
        if ($template->query(name => "searchform")) {
-               $template->param(searchform => qq{
-<form method="get" action="$IkiWiki::config{cgiurl}" id="searchform">
-<div>
-<input type="text" name="phrase" value="" size="16" />
-<input type="hidden" name="enc" value="UTF-8" />
-<input type="hidden" name="do" value="hyperestraier" />
-</div>
-</form>
-});
+               if (! defined $form) {
+                       my $searchform = IkiWiki::template("searchform.tmpl", blind_cache => 1);
+                       $searchform->param(searchaction => $IkiWiki::config{cgiurl});
+                       $form=$searchform->output;
+               }
+
+               $template->param(searchform => $form);
        }
 } #}}}
 
index e36ad1c8b73dd11fb4b95029bc033bed18cc065e..a2320c1e0c1d12a39d4467041c0e2bfbac1cc9a9 100644 (file)
@@ -32,8 +32,10 @@ ikiwiki (1.22) UNRELEASED; urgency=low
     from a different directory.
   * Generalised preprocesser loop protection code.
   * Patch from James Westby to allow a description to be set for rss feeds.
+  * Patch from James Westby to add a template for the search form.
+  * Cache search form for speedup.
 
- -- Joey Hess <joeyh@debian.org>  Sat, 26 Aug 2006 13:26:22 -0400
+ -- Joey Hess <joeyh@debian.org>  Sat, 26 Aug 2006 17:51:16 -0400
 
 ikiwiki (1.21) unstable; urgency=low
 
diff --git a/doc/patchqueue/make-searchform-template.mdwn b/doc/patchqueue/make-searchform-template.mdwn
deleted file mode 100644 (file)
index 97a8b7e..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-Here is a small patch that adds a new template for the search form. 
-
-http://jameswestby.net/scratch/search_template.diff
-
-I wanted this so I could add a label to it easily.
-
-I don't really think there's a problem with doing it except that it makes it
-more easy to break the search box.
-
-       Thanks for the patch. The only problem I see is that the template
-       is identical but gets rebuilt per-page. Would probably be better to
-       build it only the first time, then reuse the rendered text for all
-       further pages, to avoid slowing ikiwiki down any. --[[Joey]]
index 55e6ec6c817b9e97962ff67509d1e9f14d24e5a7..53b14f9bda5692f1b57043a1d2580318cb3a4abd 100644 (file)
@@ -29,6 +29,8 @@ It ships with some basic templates which can be customised:
 * `rsslink.tmpl` - Used to add a rss link if blogpost.tmpl is not used.
 * `aggregatepost.tmpl` - Used by the [[plugins/aggregate]] plugin to create
   a page for a post.
+* `searchform.tmpl` - Used by the [[plugins/search]] plugin to add a search
+  form to wiki pages.
 
 If you like, you can add these to further customise it:
 
@@ -44,3 +46,6 @@ CGI::FormBuilder, which interfaces to HTML::Template, so not all of it can
 be customised with templates, although most of it can, by creating these
 templates. Without the templates, CGI::FormBuilder creates the page bodies
 by itself.
+
+The [[plugin/template]] plugin also uses templates, though those templates
+are stored in the wiki.
diff --git a/templates/searchform.tmpl b/templates/searchform.tmpl
new file mode 100644 (file)
index 0000000..7c4fdb0
--- /dev/null
@@ -0,0 +1,7 @@
+<form method="get" action="<TMPL_VAR SEARCHACTION>" id="searchform">
+<div>
+<input type="text" name="phrase" value="" size="16" />
+<input type="hidden" name="enc" value="UTF-8" />
+<input type="hidden" name="do" value="hyperestraier" />
+</div>
+</form>