Files
spyda/internal/templates/_partials.html
2021-01-30 23:13:06 +10:00

124 lines
4.1 KiB
HTML

{{ define "pager" }}
{{ if .HasPages }}
<nav class="pagination-nav">
<ul>
<li>
{{ if .HasPrev }}
<a href="?p={{ .PrevPage }}">Prev</a>
{{ else }}
<a href="#" data-tooltip="No previous page">Prev</a>
{{ end }}
</li>
</ul>
<ul>
<li><small>Page {{ .Page }}/{{ .PageNums }} of {{ .Nums }} Results</small></li>
</ul>
<ul>
<li>
{{ if .HasNext }}
<a href="?p={{ .NextPage }}">Next</a>
{{ else }}
<a href="#" data-tooltip="No next page">Next</a>
{{ end }}
</li>
</ul>
</nav>
{{ end }}
{{ end }}
{{ define "item" }}
<article id="{{ $.Item.Hash }}" class="h-entry">
<div class="u-author h-card">
<div>
{{ if $.User.Is $.Twt.Twter.URL }}
<a href="{{ $.User.URL | trimSuffix "/twtxt.txt" }}" class="u-url">
<img class="avatar u-photo" src="/user/{{ $.User.Username }}/avatar" alt="" />
</a>
{{ else }}
{{ if isLocalURL $.Twt.Twter.URL }}
<a href="{{ $.Twt.Twter.URL | trimSuffix "/twtxt.txt" }}" class="u-url">
<img class="avatar u-photo" src="/user/{{ $.Twt.Twter.Nick }}/avatar" alt="" />
{{ else }}
<a href="/external?uri={{ $.Twt.Twter.URL }}&nick={{ $.Twt.Twter.Nick }}" class="u-url">
{{ if $.Twt.Twter.Avatar }}
<img class="avatar u-photo" src="{{ $.Twt.Twter.Avatar }}" alt="" />
{{ else }}
<i class="icss-rss" style="font-size:3em"></i>
{{ end }}
{{ end }}
</a>
{{ end }}
</div>
<div class="author">
{{ if $.User.Is $.Twt.Twter.URL }}
<a href="{{ $.User.URL | trimSuffix "/twtxt.txt" }}" class="p-name">me</a>
{{ else }}
{{ if isLocalURL $.Twt.Twter.URL }}
<a href="{{ $.Twt.Twter.URL | trimSuffix "/twtxt.txt" }}" class="p-name">{{ $.Twt.Twter.Nick }}</a>
{{ else }}
<a href="/external?uri={{ $.Twt.Twter.URL }}&nick={{ $.Twt.Twter.Nick }}" class="p-name">
{{ $.Twt.Twter.Nick }}
<span class="p-org">@{{ $.Twt.Twter.URL | hostnameFromURL }}</span>
</a>
{{ end }}
{{ end }}
<div class="publish-time">
<a class="u-url" href="/twt/{{ $.Twt.Hash }}">
<time class="dt-published" datetime="{{ $.Twt.Created | date "2006-01-02T15:04:05Z07:00" }}">
{{ dateInZone ($.Twt.Created | formatForDateTime) $.Twt.Created $.User.DisplayDatesInTimezone }}
</time>
</a>
<span> &nbsp;({{ $.Twt.Created | time }})</span>
{{ if $.Authenticated }}
<span> &nbsp;
<a class="bookmark" href="/bookmark/{{ $.Twt.Hash }}" data-tooltip="{{ if $.User.Bookmarked $.Twt.Hash }}Remove Twt Bookmark{{ else }}Bookmark Twt{{ end }}">
<i class="icss-{{ if $.User.Bookmarked $.Twt.Hash }}circle{{ else }}circle-o{{ end }}"></i>
</a>
</span>
{{ end }}
</div>
</div>
</div>
<div class="p-summary">
{{ $.Twt.Text | formatTwt }}
</div>
<hr />
<nav>
<ul>
{{ if $.Authenticated }}
{{ if eq $.LastTwt.Hash $.Twt.Hash }}
<li><a class="edit" href="#" data-hash="{{ $.Twt.Hash }}" data-text="{{ $.Twt.Text | unparseTwt }}"><i class="icss-edit"></i>Edit</a></li>
<li>&nbsp;</li>
<li><a class="delete" href="#" data-hash="{{ $.Twt.Hash }}"><i class="icss-x"></i>Delete</a></li>
<li>&nbsp;</li>
{{ end }}
<li><a class="reply" href="#" data-reply="{{ $.User.Reply $.Twt }}"><i class="icss-arrow-left"></i>Reply</a></li>
<li>&nbsp;</li>
{{ end }}
{{ with urlForBlog $.Twt }}
<li><a class="blog" href="{{ urlForBlog $.Twt }}"><i class="icss-quill-pen"></i>Blog</a></li>
<li>&nbsp;</li>
{{ end }}
{{ with urlForConv $.Twt }}
<li><a class="conv" href="{{ urlForConv $.Twt }}"><i class="icss-comment"></i>Conversation</a></li>
<li>&nbsp;</li>
{{ end }}
</ul>
</nav>
</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 }}