Ajout : recherches cloisonnées.
authorJulien Moutinho <julm@cyclocoop.org>
Sun, 30 Mar 2014 21:07:36 +0000 (23:07 +0200)
committerJulien Moutinho <julm@cyclocoop.org>
Sun, 30 Mar 2014 21:09:41 +0000 (23:09 +0200)
.gitmodules
.ikiwiki/lib/IkiWiki/Plugin/search [new submodule]
.ikiwiki/lib/IkiWiki/Plugin/search.pm [new symlink]
ikiwiki.setup
templates/searchform.tmpl [new file with mode: 0644]
templates/searchquery.tmpl [new file with mode: 0644]

index a394e02..465f170 100644 (file)
@@ -16,3 +16,6 @@
 [submodule ".ikiwiki/lib/IkiWiki/Plugin/action"]
        path = .ikiwiki/lib/IkiWiki/Plugin/action
        url = ../ikiwiki/action
+[submodule ".ikiwiki/lib/IkiWiki/Plugin/search"]
+       path = .ikiwiki/lib/IkiWiki/Plugin/search
+       url = ../ikiwiki/search
diff --git a/.ikiwiki/lib/IkiWiki/Plugin/search b/.ikiwiki/lib/IkiWiki/Plugin/search
new file mode 160000 (submodule)
index 0000000..b3db03d
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit b3db03dabf3cb6351e211fe745dc39339ec61ace
diff --git a/.ikiwiki/lib/IkiWiki/Plugin/search.pm b/.ikiwiki/lib/IkiWiki/Plugin/search.pm
new file mode 120000 (symlink)
index 0000000..b3ea553
--- /dev/null
@@ -0,0 +1 @@
+search/search.pm
\ No newline at end of file
index e4e07a8..809464a 100644 (file)
@@ -221,7 +221,24 @@ BEGIN {
                 , "git\@git.cyclocoop.org:cyclowiki" ]
         , rss => 0
         #, rsync_command => 'rsync -qa --delete . user@host:/path/to/docroot/'
-        , search_pagespec => '* and !recentchanges/* and !templates/* and !templates'
+        , search_db => # db, auth required, page having the search, pages indexed
+               [ '3615', 1
+                , '3615 or 3615/*'
+                , '(3615 or 3615/*)
+                   and !3615/recentchanges/*
+                   and !3615/templates/*
+                   and !3615/templates'
+               , 'CycloWiki', 0
+                , '*
+                   and !3615
+                   and !3615/*'
+                , '*
+                   and !recentchanges/*
+                   and !templates
+                   and !templates/*
+                   and !3615
+                   and !3615/*'
+               ]
         , srcdir => $srcdir
         , sslcookie => $sslcookie
         #, syslog => 1
diff --git a/templates/searchform.tmpl b/templates/searchform.tmpl
new file mode 100644 (file)
index 0000000..c1c386d
--- /dev/null
@@ -0,0 +1,12 @@
+<form method="get" action="<TMPL_VAR SEARCHACTION>" id="searchform">
+<div>
+<input type="hidden" id="searchdo" name="do" value="search" />
+<TMPL_LOOP NAME="SEARCHDB">
+<input type="hidden" id="searchdb" name="DB" value="<TMPL_VAR DB>" />
+</TMPL_LOOP>
+<input type="text" id="searchbox" name="P" value="" size="16"
+<TMPL_IF HTML5>placeholder="Recherche <TMPL_LOOP NAME="SEARCHDB"
+><TMPL_UNLESS NAME="__first__">, </TMPL_UNLESS
+><TMPL_VAR DB></TMPL_LOOP>"</TMPL_IF> />
+</div>
+</form>
diff --git a/templates/searchquery.tmpl b/templates/searchquery.tmpl
new file mode 100644 (file)
index 0000000..d4c9fee
--- /dev/null
@@ -0,0 +1,114 @@
+$setmap{prefix,title,S}
+$setmap{prefix,link,XLINK}
+$set{thousand,$.}$set{decimal,.}$setmap{BN,,Any Country,uk,England,fr,France}
+${
+$def{PREV,
+$if{$ne{$topdoc,0},<INPUT TYPE=image NAME="&lt;" ALT="&lt;"
+SRC="/images/xapian-omega/prev.png" BORDER=0 HEIGHT=30 WIDTH=30>,
+<IMG ALT="" SRC="/images/xapian-omega/prevoff.png" HEIGHT=30 WIDTH=30>}
+}
+
+$def{NEXT,
+$if{$ne{$last,$msize},<INPUT TYPE=image NAME="&gt;" ALT="&gt;"
+SRC="/images/xapian-omega/next.png" BORDER=0 HEIGHT=30 WIDTH=30>,
+<IMG ALT="" SRC="/images/xapian-omega/nextoff.png" HEIGHT=30 WIDTH=30>}
+}
+
+$def{P,<INPUT TYPE=image NAME="$1" VALUE="$1" SRC="/images/xapian-omega/page-$2.png" BORDER=0$opt{a} ALT="$1">}
+$def{PAGE,$if{$gt{$1,9},$if{$gt{$1,99},$P{$1,$div{$1,100}}}$P{$1,$mod{$div{$1,10},10}}}$P{$1,$mod{$1,10}}}
+
+$def{S,<IMG SRC="/images/xapian-omega/page-$2s.png"$opt{a} ALT=$1>}
+$def{SPAGE,$if{$gt{$1,9},$if{$gt{$1,99},$S{$1,$div{$1,100}}}$S{$1,$mod{$div{$1,10},10}}}$S{$1,$mod{$1,10}}}
+}
+
+$def{PREV,$if{$ne{$topdoc,0},<INPUT TYPE=submit NAME="&lt;" VALUE="Previous">}}
+
+$def{PAGE,<INPUT TYPE=submit NAME="[" VALUE="$1">}
+
+$def{SPAGE,<INPUT TYPE=submit NAME="[" VALUE="$1" DISABLED=disabled>}
+
+$def{NEXT,$if{$ne{$last,$msize},<INPUT TYPE=submit NAME="&gt;" VALUE="Next">}}
+
+<p>
+
+<FORM NAME=P METHOD=GET 
+ACTION="$html{$env{CGIURL}}" TARGET="_top">
+<div style="text-align:center">
+<INPUT type="hidden" id="searchdo" name="do" value="search" />
+<INPUT NAME=P VALUE="$html{$query}" SIZE=65>
+<INPUT TYPE=SUBMIT VALUE="Rechercher">
+$env{HELPLINK}
+<hr>
+<SELECT NAME=DEFAULTOP>
+<OPTION VALUE=or $if{$eq{$defaultop,or},SELECTED}>Au moins un des mots
+<OPTION VALUE=and $if{$eq{$defaultop,and},SELECTED}>Tous les mots
+</SELECT>
+$or{$html{$error},
+$if{$eq{$msize,0},
+$if{$query,Aucun document trouvé,
+<hr>Recherche dans $nice{$dbsize} documents
+},
+$if{$not{$msizeexact},
+ $nice{$add{$topdoc,1}}-$nice{$last} of about $nice{$msize} matches,
+ $if{$and{$eq{$last,$msize},$eq{$topdoc,0}},
+  $nice{$msize} documents trouvés,
+  $nice{$add{$topdoc,1}}$if{$ne{$add{$topdoc,1},$last},-$nice{$last}} of exactly $nice{$msize} matches}
+}
+<hr>
+</div>
+$list{$map{$queryterms,$list{$html{$uniq{$unstem{$_}}},<b>,</b>/<b>,</b>}:&nbsp;$nice{$freq{$_}}},Term frequencies: ,$. ,}
+<br><small>La recherche a pris $time secondes</small>
+<table>
+$hitlist{<tr><td valign=top>
+${<IMG SRC="/images/xapian-omega/score-$div{$percentage,10}.png" ALT="$percentage%" HEIGHT=16 WIDTH=32>}
+<div title="$percentage%" style='float:left;width:60px;height:10px;border:1px solid black;margin-top:4px;'>
+<div style='width:$div{$mul{$percentage,6},10}px; height:10px; background-color: red;'>
+</div></div>
+<div style='float:left;margin-top:2px;font-size:x-small;'>
+<span title="$html{$date{$field{modtime},%Y-%m-%d %H:%M:%S}}">
+Modified:<br><b>$html{$date{$field{modtime},%Y-%m-%d}}</b></span><br>
+$if{$field{language},Language: <b>$html{$field{language}}</b><br>}
+$if{$field{size},<span title="$html{$field{size}} bytes">Size: <b>$html{$filesize{$field{size}}}</b></span><br>}
+</div>
+</td>
+<td><B><A HREF="$html{$field{url}}">$html{$or{$field{caption},$field{title},$field{url},Untitled}}</A></B><BR>
+<small>$highlight{$field{sample},$terms}$if{$field{sample},...}</small><br>
+<small>
+$percentage% pertinent$. contenant :
+<i>$list{$map{$terms,$html{$prettyterm{$_}}},$. ,</i> et <i>}</i></small>${for lynx:}<p></td></tr>}
+</table>
+
+<br />
+
+<div style="text-align:center">
+${suppress next, prev, and page links if there's only one page}
+$if{$ne{$lastpage,1},
+$set{a,$if{$opt{pagelink_height}, HEIGHT=$opt{pagelink_height}}$if{$opt{pagelink_width}, WIDTH=$opt{pagelink_width}}}
+
+${1-W ... X-(this)-Y ...}
+$set{w,$min{3,$add{$thispage,-1}}}
+$set{x,$max{$add{$opt{w},1},$add{$thispage,-3}}}
+$set{y,$min{$lastpage,$add{$thispage,8}}}
+$PREV
+$map{$range{1,$opt{w}},$PAGE{$_}}
+$if{$ne{$add{$opt{w},1},$opt{x}},...}
+$map{$range{$opt{x},$add{$thispage,-1}},$PAGE{$_}}
+$SPAGE{$thispage}
+$map{$range{$add{$thispage,1},$opt{y}},$PAGE{$_}}
+$if{$ne{$opt{y},$lastpage},...}
+$NEXT
+}
+}}
+</div><br />
+$if{$dbname,<INPUT TYPE=hidden NAME=DB VALUE="$html{$dbname}">}
+$if{$ne{$topdoc,0},<INPUT TYPE=hidden NAME=TOPDOC VALUE=$topdoc>}
+$if{$ne{$hitsperpage,10},<INPUT TYPE=hidden NAME=HITSPERPAGE VALUE=$hitsperpage>}
+$if{$fmt,<INPUT TYPE=hidden NAME=FMT VALUE="$html{$fmt}">}
+$if{$cgi{COLLAPSE},<INPUT TYPE=hidden NAME=COLLAPSE VALUE="$html{$cgi{COLLAPSE}}">}
+$if{$queryterms,<INPUT TYPE=hidden NAME=xP VALUE="$html{$queryterms}">}
+<INPUT TYPE=hidden NAME=xDB VALUE="$html{$dbname}">
+<INPUT TYPE=hidden NAME=xFILTERS VALUE="$html{$filters}">
+$list{$relevants,<INPUT TYPE=hidden NAME=R VALUE=",.,">}
+$if{$cgi{THRESHOLD},<INPUT TYPE=hidden NAME=THRESHOLD VALUE="$html{$cgi{THRESHOLD}}">}
+</FORM>
+<hr><div align=right><i><small><a href="http://www.xapian.org/">$html{$version}</a></small></i></div>