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 result = paginate ~size:results_per_page ~page result in
27 if results_no > 0 then
28 let mode = "typeonly" in
30 let idx = ref ((page - 1) * results_per_page + List.length result + 1) in
36 <td valign=\"top\">%d.</td>
37 <td><span class=\"uri\">%s</span></td>
41 <td><ht:OBJECT uri=\"%s\" mode=\"%s\"/></td>
47 sprintf "<b>%d</b> result%s found"
48 results_no (if results_no > 1 then "s" else "")
52 "<table xmlns:ht=\"http://www.cs.unibo.it/helm/namespaces/helm-theory\">
59 ("no results found", "")
61 let html_of_interpretations interps =
62 let choice_of_interp interp =
63 sprintf "<table>\n%s\n</table>"
67 sprintf "<tr><td><em>%s</em></td><td>%s</td></tr>" k v)
70 let interp_no = ref ~-1 in
71 sprintf "<table class=\"interp\">\n%s\n</table>"
77 <td><input type=\"radio\" name=\"param.interp\" value=\"%d\" /></td>
81 (incr interp_no; !interp_no)
82 (choice_of_interp interp))