Created
November 30, 2020 15:47
-
-
Save hectorcorrea/6cd3dc01f5052d7f42d87f2a1566a584 to your computer and use it in GitHub Desktop.
Sample results.html for SolrDora using hard-coded fields. Allows to easily set the display order.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ define "content" }} | |
<style> | |
em { | |
background: #e9e91966; | |
} | |
</style> | |
<div class="row"> | |
<div class="col-md-4"> | |
<form action="/search" method="GET"> | |
<input type="text" id="q" name="q" value="{{ .Q }}" placeholder="enter text" autofocus/> | |
<div style="display:none;" id="facets_form"> | |
<!-- reset paging when submitting a new search --> | |
<input type="text" id="start" name="start" value="0" /> | |
<input type="text" id="rows" name="rows" value="10" /> | |
<!-- preserve the facets when submitting a new search --> | |
{{ range $facet := .Facets }} | |
{{ range .Values }} | |
{{ if .Active }} | |
<input type="text" id="fq" name="fq" value="{{ $facet.Field }}|{{ .Text }}" /> | |
{{ end }} | |
{{ end }} | |
{{ end }} | |
</div> | |
<button type="submit">Search</button> | |
</form> | |
</div> | |
<div class="col-md-8"> | |
{{ if ne .Q "" }} | |
<p>Searched for:<b> {{ .Q }}</b><a href="{{ safeURL .UrlNoQ }}"> (remove)</a></p> | |
{{ end }} | |
{{ range $facet := .Facets }} | |
{{ range .Values }} | |
{{ if .Active }} | |
<p>{{ $facet.Title }} > {{ .Text }} <a href="{{ safeURL .RemoveUrl }}">(remove)</a></p> | |
{{ end }} | |
{{ end }} | |
{{ end }} | |
<p>Found: {{ .NumFound }}, showing {{ .First }} - {{ .Last }}</p> | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-md-4"> | |
<!-- facets --> | |
{{ range $facet := .Facets }} | |
<div class="panel panel-info"> | |
<div class="panel-heading"> | |
<h3 class="panel-title">{{ .Title }}</h3> | |
</div> | |
<div class="panel-body"> | |
{{ range .Values }} | |
<p> | |
{{ if .Active }} | |
<span class="badge" style="float: right;">{{ .Count }}</span> | |
{{ .Text }} <a href="{{ safeURL .RemoveUrl }}">(remove)</a> | |
{{ else }} | |
<span class="badge" style="float: right;">{{ .Count }}</span> | |
<a href="{{ safeURL .AddUrl }}">{{ .Text }}</a> | |
{{ end }} | |
</p> | |
{{ end }} | |
</div> | |
</div> | |
{{ end }} | |
</div> | |
<div class="col-md-8"> | |
<!-- TODO disable prev/next based on current page and num found --> | |
<div class="btn-group" role="group" aria-label="..."> | |
<a class="btn btn-default" href="{{ .PrevPageUrl }}" title="View previous {{ .Rows }}">Previous</a> | |
<a class="btn btn-default" href="{{ .NextPageUrl }}" title="View next {{ .Rows }}">Next</a> | |
</div> | |
<div> </div> | |
<!-- search results --> | |
<div class="list-group"> | |
{{ range .Documents }} | |
<div class="list-group-item"> | |
{{ $doc := . }} | |
<!-- id --> | |
<p><a href="/view/{{ .Id }}">{{ .Id }}</a></p> | |
<!-- Title is single value field. | |
We display the highlighted value (if any) or $doc.Value. --> | |
<p><b>Title:</b> | |
{{ if $doc.IsHighlighted "title_txt_en" }} | |
{{ $doc.HighlightFor "title_txt_en" | safeHTML }} | |
{{ else }} | |
{{ $doc.Value "title_txt_en" }} | |
{{ end }} | |
</p> | |
<!-- Authors is a multi-value field. | |
We display the highlighted value (if any) or loop through $doc.Values for this field. --> | |
<p> | |
{{ if $doc.IsHighlighted "authors_all_txts_en" }} | |
<b>Authors:</b> {{ $doc.HighlightFor "authors_all_txts_en" | safeHTML }} | |
{{ else }} | |
{{ range $i, $value := $doc.Values "authors_all_txts_en" }} | |
{{ if eq $i 0 }} | |
<b>Authors:</b> | |
{{ end }} | |
{{ $value }} // | |
{{ end }} | |
{{ end }} | |
</p> | |
<!-- Subject is multi-value field. | |
We display the highlighted value (if any) or loop through $doc.Values for this field. --> | |
<p> | |
{{ if $doc.IsHighlighted "subjects_txts_en" }} | |
<b>Subjects:</b> {{ $doc.HighlightFor "subjects_txts_en" | safeHTML }} | |
{{ else }} | |
{{ range $i, $value := $doc.Values "subjects_txts_en" }} | |
{{ if eq $i 0 }} | |
<b>Subjects:</b> | |
{{ end }} | |
{{ $value }} // | |
{{ end }} | |
{{ end }} | |
</p> | |
</div> | |
{{ end }} | |
</div> | |
</div> | |
</div> | |
{{ end }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment