Flresh out search template

This commit is contained in:
James Mills
2021-01-30 23:13:06 +10:00
parent ca9ab1bf61
commit 9ae2a31cfa
2 changed files with 109 additions and 28 deletions

View File

@@ -25,3 +25,99 @@
</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 }}

View File

@@ -1,29 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>veri</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
</head>
<body>
<header>
<a href="/"><h1>veri</h1></a>
</header>
<main>
<form action="/search" method="get">
<input type="text" id="search" name="q"><br><br>
<input type="submit" value="Search">
</form>
<p class="bold">These results are not ranked, they are just in alphabetical order of URL (this will change)</p>
<ol>
{{ if not . }}<p>No search results</p>{{ end }}
{{ range . }}
<li><a href="{{ .URL }}"><h3>{{ .Title }}</h3></a><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={{ .ID }}">View cached</a></p>
{{define "content"}}
<article class="container">
{{ with $.Results }}
<ol>
{{ range . }}
<li><a href="{{ .URL }}"><h3>{{ .Title }}</h3></a><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={{ .ID }}">View cached</a></p>
{{ end }}
</ol>
<p>If your page appears here and you do not want it to, please contact <a href="/support">Support</a>.</p>
{{ else }}
<p>No search results</p>
{{ end }}
</ol>
<p>If your page appears here and you do not want it to, please contact <a href="mailto:~ols/indexing@lists.sr.ht">~ols/indexing@lists.sr.ht</a>. Contact the same email if you want your page considered for indexing. Be aware this is a public mailing list.</p>
<footer>
<p><a href="https://sr.ht/~ols/veri/">about</a></p>
</footer>
</body>
</html>
</article>
{{end}}