added --hyperestraier switch, which turns on search support
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Wed, 29 Mar 2006 22:21:23 +0000 (22:21 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Wed, 29 Mar 2006 22:21:23 +0000 (22:21 +0000)
(ok, the way I run estseek.cgi is admittedly pretty nasty, but it works..)

12 files changed:
IkiWiki/CGI.pm
IkiWiki/Render.pm
basewiki/style.css
debian/control
doc/features.mdwn
doc/ikiwiki.setup
doc/todo/done/search.mdwn [moved from doc/todo/search.mdwn with 100% similarity]
doc/usage.mdwn
ikiwiki
templates/estseek.conf [new file with mode: 0644]
templates/misc.tmpl
templates/page.tmpl

index f360b6778d9c78c1a227d755aa6b4f03e0d76018..08d79614217e0855a35fb99565c7adc5d5e0ea60 100644 (file)
@@ -475,12 +475,22 @@ sub cgi_editpage ($$) { #{{{
        }
 } #}}}
 
+sub cgi_hyperestraier () { #{{{
+       # only works for GET requests
+       chdir("$config{wikistatedir}/hyperestraier") || error("chdir: $!");
+       exec("./".basename($config{cgiurl})) || error("estseek.cgi failed");
+} #}}}
+
 sub cgi () { #{{{
        eval q{use CGI};
        eval q{use CGI::Session};
        
        my $q=CGI->new;
        
+       if (defined $q->param('phrase')) {
+               cgi_hyperestraier();
+       }
+       
        my $do=$q->param('do');
        if (! defined $do || ! length $do) {
                error("\"do\" parameter missing");
@@ -491,6 +501,9 @@ sub cgi () { #{{{
                cgi_recentchanges($q);
                return;
        }
+       elsif ($do eq 'hyperestraier') {
+               cgi_hyperestraier();
+       }
        
        CGI::Session->name("ikiwiki_session_$config{wikiname}");
        
index 9e340c26e162abe5623524d4b4ced32942e6c834..8375cfe7a9d3e984253f417415e12a8927baa51f 100644 (file)
@@ -214,6 +214,9 @@ sub genpage ($$$) { #{{{
                $u=~s/\[\[file\]\]/$pagesources{$page}/g;
                $template->param(historyurl => $u);
        }
+       if ($config{hyperestraier}) {
+               $template->param(hyperestraierurl => cgiurl());
+       }
 
        if ($config{rss} && $inlinepages{$page}) {
                $template->param(rssurl => rsspage(basename($page)));
@@ -381,6 +384,56 @@ sub prune ($) { #{{{
        }
 } #}}}
 
+sub estcfg () { #{{{
+       my $estdir="$config{wikistatedir}/hyperestraier";
+       my $cgi=basename($config{cgiurl});
+       $cgi=~s/\..*$//;
+       open(TEMPLATE, ">$estdir/$cgi.tmpl") ||
+               error("write $estdir/$cgi.tmpl: $!");
+       print TEMPLATE misctemplate("search", 
+               "<!--ESTFORM-->\n\n<!--ESTRESULT-->\n\n<!--ESTINFO-->\n\n");
+       close TEMPLATE;
+       open(TEMPLATE, ">$estdir/$cgi.conf") ||
+               error("write $estdir/$cgi.conf: $!");
+       my $template=HTML::Template->new(
+               filename => "$config{templatedir}/estseek.conf"
+       );
+       eval q{use Cwd 'abs_path'};
+       $template->param(
+               index => $estdir,
+               tmplfile => "$estdir/$cgi.tmpl",
+               destdir => abs_path($config{destdir}),
+               url => $config{url},
+       );
+       print TEMPLATE $template->output;
+       close TEMPLATE;
+       symlink("/usr/lib/estraier/estseek.cgi",
+               "$estdir/".basename($config{cgiurl})) ||
+                       error("symlink: $!");
+} # }}}
+
+sub estcmd ($;@) { #{{{
+       my @params=split(' ', shift);
+       push @params, "-cl", "$config{wikistatedir}/hyperestraier";
+       if (@_) {
+               push @params, "-";
+       }
+       
+       my $pid=open(CHILD, "|-");
+       if ($pid) {
+               # parent
+               foreach (@_) {
+                       print CHILD "$_\n";
+               }
+               close(CHILD) || error("estcmd @params exited nonzero: $?");
+       }
+       else {
+               # child
+               open(STDOUT, "/dev/null"); # shut it up (closing won't work)
+               exec("estcmd", @params) || error("can't run estcmd");
+       }
+} #}}}
+
 sub refresh () { #{{{
        # find existing pages
        my %exists;
@@ -505,6 +558,7 @@ FILE:               foreach my $file (@files) {
                                        if (globlist_match($page, $inlinepages{$p})) {
                                                debug("rendering $f, which inlines $page");
                                                render($f);
+                                               $rendered{$f}=1;
                                                last;
                                        }
                                }
@@ -539,9 +593,25 @@ FILE:              foreach my $file (@files) {
                        if (defined $linkfile) {
                                debug("rendering $linkfile, to update its backlinks");
                                render($linkfile);
+                               $rendered{$linkfile}=1;
                        }
                }
        }
+
+       if ($config{hyperestraier} && (%rendered || @del)) {
+               debug("updating hyperestraier search index");
+               if (%rendered) {
+                       estcmd("gather -cm -bc -cl -sd", 
+                               map { $config{destdir}."/".$renderedfiles{pagename($_)} }
+                               keys %rendered);
+               }
+               if (@del) {
+                       estcmd("purge -cl");
+               }
+               
+               debug("generating hyperestraier cgi config");
+               estcfg();
+       }
 } #}}}
 
 1
index 97b30fbf86b62854d17606665af931cae0df6788..6da3e62536e26812508d7fc1da966cb9ff79bd24 100644 (file)
@@ -1,11 +1,11 @@
 #header h1 {
        margin: 0;
-       padding: 2px 0;
+       padding: 0 0;
 }
 
 #actions ul {
        margin: 0;
-       padding: 2px;
+       padding: 6px;
        list-style-type: none;
        border-bottom: 1px solid #000;
 }
        padding: .2em .4em;
 }
 
+#searchform {
+       display: inline;
+       float: right;
+}
+
 #content {
        border-bottom: 1px solid #000;
 }
@@ -23,8 +28,8 @@
 #blogform {
        padding: 10px 10px;
        border: 1px solid #aaa;
-       color: black !important;;
        background: #eee;
+       color: black !important;
 }
 
 #backlinks {
index 1d69e55a54e8d02448d1e998dcf6f5be7b96cd32..8eaffedb6f51722ec85ea5602b7d0b2973a63fba 100644 (file)
@@ -8,7 +8,7 @@ Standards-Version: 3.6.2
 Package: ikiwiki
 Architecture: all
 Depends: ${perl:Depends}, markdown, libhtml-template-perl, libcgi-formbuilder-perl, libtime-duration-perl, libcgi-session-perl, libmail-sendmail-perl, gcc | c-compiler
-Recommends: subversion
+Recommends: subversion, hyperestraier
 Suggests: viewcvs
 Description: a wiki compiler
  ikiwiki converts a directory full of wiki pages into html pages suitable
index eaf0d539fb5588189975bb93dcc5d074ba625511..3b3b8ff9b902d77a54ee892c5d6e9a2a47f82d82 100644 (file)
@@ -102,6 +102,11 @@ Currently implemented:
 
   Wiki admins can lock pages so that only other admins can edit them.
 
+* Full text search
+
+  ikiwiki can use the [[HyperEstraier]] search engine to add powerful
+  full text search capabilities to your wiki.
+
 ----
 
 It also has some [[TODO]] items and [[Bugs]].
index bd82f3d102079303c397546f5b641eb1b1ffaa48..17b647e7561a41281211c3bd9480550e5f26ebc1 100644 (file)
@@ -46,4 +46,6 @@ use IkiWiki::Setup::Standard {
        #anonok => 1,
        # Generate rss feeds for pages?
        rss => 1,
+       # Use the Hyper Estraier search engine?
+       #hyperestraier => 1,
 }
index 9a8b97ceb15fcc2ead6e190e499f5e0cea006cde..228d4e5951b630a9eacd07f43512aed9fe527b8b 100644 (file)
@@ -143,6 +143,11 @@ These options configure the wiki.
   Currently allows locking of any page, other powers may be added later.
   May be specified multiple times for multiple admins.
 
+* --hyperestraier
+
+  Enables use of the [[HyperEstraier]] search engine for full test page
+  searches.
+
 * --verbose
 
   Be vebose about what it's doing.
diff --git a/ikiwiki b/ikiwiki
index b1bc9984f2bd9475787808d65f886424c250e7cc..8eebcdf77e90f48a3c6c74087408e3d836c81369 100755 (executable)
--- a/ikiwiki
+++ b/ikiwiki
@@ -36,6 +36,7 @@ sub getconfig () { #{{{
                        rebuild => 0,
                        refresh => 0,
                        getctime => 0,
+                       hyperestraier => 0,
                        wrapper => undef,
                        wrappermode => undef,
                        srcdir => undef,
@@ -57,6 +58,7 @@ sub getconfig () { #{{{
                        "wrappermode=i" => \$config{wrappermode},
                        "svn!" => \$config{svn},
                        "anonok!" => \$config{anonok},
+                       "hyperestraier" => \$config{hyperestraier},
                        "rss!" => \$config{rss},
                        "cgi!" => \$config{cgi},
                        "url=s" => \$config{url},
@@ -102,6 +104,9 @@ sub checkconfig () { #{{{
        if ($config{rss} && ! length $config{url}) {
                error("Must specify url to wiki with --url when using --rss\n");
        }
+       if ($config{hyperestraier} && ! length $config{url}) {
+               error("Must specify --url when using --hyperestraier\n");
+       }
        
        $config{wikistatedir}="$config{srcdir}/.ikiwiki"
                unless exists $config{wikistatedir};
diff --git a/templates/estseek.conf b/templates/estseek.conf
new file mode 100644 (file)
index 0000000..91e144d
--- /dev/null
@@ -0,0 +1,21 @@
+indexname: <TMPL_VAR INDEX>
+tmplfile: <TMPL_VAR TMPLFILE>
+topfile: /dev/null
+logfile:
+replace: ^file://<TMPL_VAR DESTDIR>{{!}}<TMPL_VAR URL>
+showreal: false
+perpage: 10,20,30,40,50,100
+attrselect: false
+showscore: false
+extattr: date|Date
+snipwwidth: 480
+sniphwidth: 96
+snipawidth: 96
+condgstep: 2
+dotfidf: true
+scancheck: false
+smplphrase: true
+candetail: true
+smlrvnum: 0
+clipview: 2
+spcache:
index 98d60d7032c98df09e6907345737caad1d2003aa..442db8c21cafb4589680978500b23ccad83f0018 100644 (file)
@@ -8,13 +8,19 @@
 </head>
 <body>
 
+<div id="header">
 <h1>
 <TMPL_VAR INDEXLINK>/ <TMPL_VAR TITLE>
 </h1>
+</div>
 
+<div id="content">
 <TMPL_VAR PAGEBODY>
+</div>
 
+<div id="footer">
 <!-- from <TMPL_VAR NAME=WIKINAME> -->
+</div>
 
 </body>
 </html>
index 8b018ddfb0d6d33b1ad526b09ebab0ecf64c2079..fb7383acb2f6060e80e1fab8ed35ece5a65306c1 100644 (file)
 </TMPL_LOOP>
 <TMPL_VAR TITLE>
 </h1>
+<TMPL_IF NAME="HYPERESTRAIERURL">
+<form method="get" action="<TMPL_VAR HYPERESTRAIERURL>" id="searchform">
+<input type="text" name="phrase" value="" size="32" />
+<input type="submit" value="Search" />
+<input type="hidden" name="enc" value="UTF-8" />
+<input type="hidden" name="do" value="hyperestraier" />
+</TMPL_IF>
 </div>
 
 <div id="actions">
@@ -36,6 +43,7 @@
 </TMPL_IF>
 
 <li><TMPL_VAR DISCUSSIONLINK><br /></li>
+
 </ul>
 </div>