Files
spyda/internal/templates/_partials.html
James Mills 6dc7510e8f Fixed pager
2021-02-03 01:56:56 +10:00

53 lines
1.4 KiB
HTML

{{ define "pager" }}
{{ if $.Pager.HasPages }}
<nav class="pagination-nav">
<ul>
<li>
{{ if $.Pager.HasPrev }}
<a href="?q={{ $.SearchQuery }}&p={{ $.Pager.PrevPage }}">Prev</a>
{{ else }}
<a href="#" data-tooltip="No more results">Prev</a>
{{ end }}
</li>
</ul>
<ul>
<li><small>Viewing page {{ $.Pager.Page }}/{{ $.Pager.PageNums }} of {{ $.Pager.Nums }} results (Search took: {{ $.SearchTook }})</small></li>
</ul>
<ul>
<li>
{{ if $.Pager.HasNext }}
<a href="?q={{ $.SearchQuery }}&p={{ $.Pager.NextPage }}">Next</a>
{{ else }}
<a href="#" data-tooltip="No more results">Next</a>
{{ end }}
</li>
</ul>
</nav>
{{ end }}
{{ end }}
{{ define "item" }}
<article>
<hgroup>
<h2><a href="{{ $.URL }}">{{ $.Title }}</a></h2>
<h3>Updated {{ $.UpdatedAt | time }}</h3>
</hgroup>
<p{{ if $.Summary }}>{{ .Summary }}{{ else }} class="placeholder">No summary available{{ end }}</p>
<p class="small"><a href="{{ $.URL }}">{{ $.URL }}</a> {{ .Length }} <a href="/cache/{{ .ID }}">View cached</a></p>
</article>
{{ end }}
{{ define "results" }}
<div class="grid">
<div>
{{ template "pager" $.Pager }}
{{ range $idx, $item := $.Results }}
{{ template "item" (dict "Item" $item) }}
{{ else }}
<small><i>No search results found.</i></small>
{{ end }}
{{ template "pager" $.Pager }}
</div>
</div>
{{ end }}