-
Notifications
You must be signed in to change notification settings - Fork 17
/
Index.cshtml
51 lines (47 loc) · 2.06 KB
/
Index.cshtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
@using DemoSite.Business.ViewModelBuilders
@using OpenAccessRuntime.util.classhelper
@using PagedList.Mvc
@model DemoSite.Models.ViewModels.SearchPageViewModel
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="row">
<div class="col-lg-6 col-lg-push-3">
@using (Html.BeginForm(null, null, FormMethod.Get)) {
<div id="searchfield" class="input-group">
@Html.TextBox("q", Model.Query, new {@class = "form-control"})
<span class="input-group-btn">
<button id="searchButton" class="btn btn-primary" type="submit"><i class="glyphicon glyphicon-search"></i> Search</button>
</span>
</div>
}
</div>
</div>
<div id="searchresults">
@if (!string.IsNullOrEmpty(Model.Query))
{
if (Model.SearchResult.Any())
{
foreach (var searchHit in Model.SearchResult)
{
<p>
<a href="@searchHit.Path">@searchHit.Title</a><br />
<span class="url">@searchHit.Path</span><!-- [@searchHit.Score]--><br />
@if (!string.IsNullOrEmpty(searchHit.Excerpt)) {
@Html.Raw(searchHit.Excerpt)<br/>
}
else if (searchHit.MetaData.ContainsKey("summary") && !string.IsNullOrEmpty(searchHit.MetaData["summary"])) {
@Html.Raw(searchHit.MetaData["summary"])<br />
}
<span class="label label-warning">@searchHit.MetaData["category"]</span>
</p>
}
@Html.PagedListPager(Model.SearchResult, page => Url.Action(null, Model.CurrentPage.PageUrl.ToString().TrimStart('/'), new { q = Model.Query, page }))
<p>Showing @Model.SearchResult.FirstItemOnPage to @Model.SearchResult.LastItemOnPage of @Model.SearchResult.TotalItemCount search hits</p>
}
else
{
<p><i>No pages were found matching the search criteria.</i></p>
}
}
</div>