4 let pp_request (req: Http_types.request) =
9 | "/locate" -> "Locate"
12 let pp_error title msg =
13 sprintf "<hr size='1' /><div><b class='error'>%s:</b> %s</div>" title msg
15 let paginate ~size ~page l =
16 let min = 1 + (page-1) * size in
17 let max = page * size in
21 | i, hd :: tl when i < min -> aux (i+1) tl
22 | i, hd :: tl when i >= min && i <= max -> hd :: aux (i+1) tl
25 assert (size > 0 && page > 0);
28 (** pretty print a list of URIs to an HELM theory file *)
29 let theory_of_result (req: Http_types.request) page result =
30 let results_per_page =
31 Helm_registry.get_int "search_engine.results_per_page"
33 let results_no = List.length result in
34 let result = paginate ~size:results_per_page ~page result in
35 let query_kind = pp_request req in
36 let template query_kind summary results =
38 "<div class='resultsbar'>
41 <td class='left'><b class='query_kind'>%s</b></td>
42 <td class='right'>%s</td>
50 query_kind summary results
52 if results_no > 0 then
53 let mode = "typeonly" in
55 let idx = ref ((page - 1) * results_per_page + List.length result + 1) in
61 <td valign=\"top\">%d.</td>
62 <td><ht:OBJECT uri=\"%s\" mode=\"%s\"/></td>
68 (sprintf "<b>%d</b> result%s found"
69 results_no (if results_no > 1 then "s" else ""))
71 "<table xmlns:ht=\"http://www.cs.unibo.it/helm/namespaces/helm-theory\">
76 template query_kind "no results found" ""
78 let html_of_interpretations interps =
80 sprintf "<input type=\"radio\" name=\"param.interp\" value=\"%d\" />" n
83 String.concat "<br />"
85 (fun (id, value) -> sprintf "<span>%s = %s</span>" id value)
88 let rec aux n = function
90 | interp::tl -> ((radio_button n)^(text interp))::(aux (n+1) tl)
92 String.concat "<br />" (aux 0 interps)