Compute lucene-style scores for our hits.
[beagle.git] / Renderers / DefaultHitRenderer.cs
blob3c9da1696a3d55c7b7047ad277807b996a89e33e
1 //
2 // GNOME Dashboard
3 //
4 // DefaultMatchRenderer.cs: The vanilla renderer for match types with
5 // no type-specific renderer to call their own. Cold, lonely match
6 // types.
7 //
8 // Author:
9 // Nat Friedman <nat@nat.org>
12 // Copyright (C) 2003 Nat Friedman
13 // Copyright (C) 2004 Novell, Inc.
15 // Permission is hereby granted, free of charge, to any person obtaining a copy
16 // of this software and associated documentation files (the "Software"), to deal
17 // in the Software without restriction, including without limitation the rights
18 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19 // copies of the Software, and to permit persons to whom the Software is
20 // furnished to do so, subject to the following conditions:
22 // The above copyright notice and this permission notice shall be included in all
23 // copies or substantial portions of the Software.
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 // SOFTWARE.
35 using System;
36 using System.Collections;
38 //[assembly:Dashboard.MatchRendererFactory ("Dashboard.DefaultMatchRenderer")]
40 namespace Beagle {
42 class DefaultHitRenderer : HitRendererHtml {
44 public DefaultHitRenderer ()
46 type = "Default";
49 protected override string HitsToHtml (ArrayList hits)
51 string html = "";
53 foreach (Hit hit in hits)
54 html += HTMLRenderSingleHit (hit);
56 return html;
59 private string HTMLRenderSingleHit (Hit hit)
61 if (hit ["Icon"] == null && hit ["Text"] == null)
62 return "";
64 string html;
66 html = String.Format (
67 "<table border=0 cellpadding=0 cellspacing=0>" +
68 "<tr>");
70 if (hit ["Icon"] != null)
71 html += String.Format (
72 " <td valign=center>" +
73 + " <a href=\"{0}\"><img src=\"{1}\" border=0></a>" +
74 " </td>",
75 hit ["Action"],
76 hit ["Icon"]);
78 html += String.Format ("<td>&nbsp;&nbsp;</td>" +
79 " <td valign=top>" +
80 " <a href=\"{0}\" style=\"text-decoration: none;\">{1}" +
81 " </td>" +
82 "</tr>" +
83 "</table>",
84 hit ["Action"],
85 hit ["Text"]);
87 return html;