4 let pp_error title msg =
5 sprintf "<div><b class='error'>%s:</b> %s</div><br />" title msg
7 let paginate ~size ~page l =
8 let min = 1 + (page-1) * size in
9 let max = page * size in
13 | i, hd :: tl when i < min -> aux (i+1) tl
14 | i, hd :: tl when i >= min && i <= max -> hd :: aux (i+1) tl
17 assert (size > 0 && page > 0);
20 (** pretty print a list of URIs to an HELM theory file *)
21 let theory_of_result page result =
22 let results_per_page =
23 Helm_registry.get_int "search_engine.results_per_page"
25 let results_no = List.length result in
26 let buffer = Buffer.create (200 * results_no) in
27 let result = paginate ~size:results_per_page ~page result in
28 if results_no > 0 then
29 let mode = "typeonly" in
30 let output_results () =
31 let idx = ref ((page - 1) * results_per_page) in
37 <td valign=\"top\">%d.</td>
38 <td><span class=\"uri\">%s</span></td>
42 <td><ht:OBJECT uri=\"%s\" mode=\"%s\"/></td>
44 !idx uri uri mode) result ;
47 sprintf "<b>%d</b> result%s found"
48 results_no (if results_no > 1 then "s" else "")
51 Buffer.add_string buffer
52 "<table xmlns:ht=\"http://www.cs.unibo.it/helm/namespaces/helm-theory\">";
54 Buffer.add_string buffer "</table>";
55 (summary, Buffer.contents buffer)
58 ("no results found", "")
60 let html_of_interpretations interps =
61 let choice_of_interp interp =
62 sprintf "<table>\n%s\n</table>"
66 sprintf "<tr><td><em>%s</em></td><td>%s</td></tr>" k v)
69 let interp_no = ref ~-1 in
70 sprintf "<table class=\"interp\">\n%s\n</table>"
76 <td><input type=\"radio\" name=\"param.interp\" value=\"%d\" /></td>
80 (incr interp_no; !interp_no)
81 (choice_of_interp interp))