Site menu now has properly generated <li> labels.
[cocanwiki.git] / scripts / search.ml
index 0ee9f2e..456c0e9 100644 (file)
@@ -1,7 +1,7 @@
 (* COCANWIKI - a wiki written in Objective CAML.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * Copyright (C) 2004 Merjis Ltd.
- * $Id: search.ml,v 1.6 2004/11/02 18:47:54 rich Exp $
+ * $Id: search.ml,v 1.8 2004/11/02 22:26:36 rich Exp $
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -35,6 +35,8 @@ let split_words = Pcre.regexp "\\W+"
 let run r (q : cgi) (dbh : Dbi.connection) hostid host user =
   let template = get_template dbh hostid "search.html" in
 
+  template#set "canonical_hostname" host.canonical_hostname;
+
   (* Get the query, if it exists. *)
   let query = try q#param "q" with Not_found -> "" in
   let have_query = not (string_is_whitespace query) in
@@ -58,6 +60,8 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid host user =
     if have_query then (
       (* Get the keywords from the query string. *)
       let keywords = Pcre.split ~rex:split_words query in
+      let keywords =
+       List.filter (fun s -> not (string_is_whitespace s)) keywords in
       let keywords = List.map String.lowercase keywords in
 
       (* Turn the keywords into a tsearch2 ts_query string. *)