Titles for search results

This commit is contained in:
Thomas Hounsell 2014-12-11 12:24:42 +00:00
parent 18740b6336
commit b573550660
3 changed files with 7 additions and 1 deletions

View File

@ -41,6 +41,7 @@ orderby s.IndexOf(query) ascending
{ {
Url = Url.Route("Source Root", new { controller = "build", action = "source", source = s }), Url = Url.Route("Source Root", new { controller = "build", action = "source", source = s }),
Label = s.Replace(query, "<strong>" + query + "</strong>"), Label = s.Replace(query, "<strong>" + query + "</strong>"),
Title = s,
Group = "Source" Group = "Source"
}; };
@ -54,6 +55,7 @@ where string.Format("{0}.{1}", v.Major, v.Minor).StartsWith(query)
{ {
Url = Url.Route("Version Root", new { controller = "build", action = "version", major = v.Major, minor = v.Minor }), Url = Url.Route("Version Root", new { controller = "build", action = "version", major = v.Major, minor = v.Minor }),
Label = string.Format("{0}.{1}", v.Major, v.Minor).Replace(query, "<strong>" + query + "</strong>"), Label = string.Format("{0}.{1}", v.Major, v.Minor).Replace(query, "<strong>" + query + "</strong>"),
Title = "",
Group = "Version" Group = "Version"
}; };
@ -67,6 +69,7 @@ orderby y descending
{ {
Url = Url.Route("Year Root", new { controller = "build", action = "year", year = y }), Url = Url.Route("Year Root", new { controller = "build", action = "year", year = y }),
Label = y.ToString().Replace(query, "<strong>" + query + "</strong>"), Label = y.ToString().Replace(query, "<strong>" + query + "</strong>"),
Title = "",
Group = "Year" Group = "Year"
}; };
@ -80,6 +83,7 @@ orderby l.IndexOf(query) ascending
{ {
Url = Url.Route("Lab Root", new { controller = "build", action = "lab", lab = l }), Url = Url.Route("Lab Root", new { controller = "build", action = "lab", lab = l }),
Label = l.Replace(query, "<strong>" + query + "</strong>"), Label = l.Replace(query, "<strong>" + query + "</strong>"),
Title = l,
Group = "Lab" Group = "Lab"
}; };
@ -94,6 +98,7 @@ b.BuildTime descending
{ {
Url = Url.Route("Actions", new { controller = "build", action = "info", id = b.Id }), Url = Url.Route("Actions", new { controller = "build", action = "info", id = b.Id }),
Label = b.FullBuildString.Replace(query, "<strong>" + query + "</strong>"), Label = b.FullBuildString.Replace(query, "<strong>" + query + "</strong>"),
Title = b.FullBuildString,
Group = "Build" Group = "Build"
}; };

View File

@ -9,6 +9,7 @@ public class SearchResult
{ {
public string Url { get; set; } public string Url { get; set; }
public string Label { get; set; } public string Label { get; set; }
public string Title { get; set; }
public string Group { get; set; } public string Group { get; set; }
} }
} }

View File

@ -169,7 +169,7 @@
@Scripts.Render("~/bundles/jsrender") @Scripts.Render("~/bundles/jsrender")
<script type="text/javascript" src="~/Scripts/bfs.js"></script> <script type="text/javascript" src="~/Scripts/bfs.js"></script>
<script id="result-template" type="text/x-jsrender"> <script id="result-template" type="text/x-jsrender">
<a href="{{:Url}}" class="list-group-item"> <a href="{{:Url}}" class="list-group-item" title="{{:Title}}">
<h4 class="list-group-item-heading">{{:Label}}</h4> <h4 class="list-group-item-heading">{{:Label}}</h4>
<p class="list-group-item-text">{{:Group}}</p> <p class="list-group-item-text">{{:Group}}</p>
</a> </a>