Files
donniemarko/internal/web/templates/noteList.tmpl
2026-02-01 11:55:16 +01:00

55 lines
2.2 KiB
Cheetah

{{ define "noteList" }}
<aside>
<header>
<h1 class="main-logo"><a href="/">Donnie Marko</a></h1>
<form method="GET" action="/" class="search-form">
<input type="text" name="search" class="search-bar" placeholder="Search... (empty query to clear)">
<input type="submit" value="ok"/>
</form>
<form method="GET" action="/">
<select name="sort" value="sort" class="sort-dropdown">
<option value="" disabled {{ if eq "" .SortBy }}selected{{ end }}>Sort by</option>
<option value="recent" {{ if eq "recent" .SortBy }}selected{{ end }}>Recent</option>
<option value="oldest" {{ if eq "oldest" .SortBy }}selected{{ end }}>Oldest</option>
<option value="alpha" {{ if eq "alpha" .SortBy }}selected{{ end }}>Alphabetical</option>
<option value="ralpha" {{ if eq "ralpha" .SortBy }}selected{{ end }}>Reverse Alphabetical</option>
</select>
<input type="submit" value="sort" />
</form>
</header>
{{ template "renderSearch" . }}
</aside>
{{ end }}
{{ define "renderSearch" }}
{{ if ne .SearchTerm "" }}<h2>Matching results for query '{{ .SearchTerm }}'</h2>{{ end }}
<ul class="search-results">
{{ range .Nodes }}
{{ if .IsEnd }}
<li {{ if eq .Hash $.LastActive }}class="active-note"{{ end }}>
<input type="checkbox"/>
<a href="/notes/{{ .Hash }}" data-hash="{{ .Hash }}">{{ .Title }}</a>
<span class="last-modified">{{ .LastModified }}</span>
</li>
{{ end }}
{{ end }}
</ul>
{{ end }}
{{/* not used for now, the opposition between flat list from hashmap and tree structure is confusing */}}
{{ define "renderTree" }}
<ul>
{{ range . }}
{{ if .IsEnd }}
<li><input type="checkbox"/><a href="/notes/{{ .Hash }}" data-hash="{{ .Hash }}">{{ .Title }}</a><span class="last-modified">{{ .LastModified }}</span></li>
{{ else }}
{{ if .Children }}
<li><div class="folder"><input type="checkbox"/><span class="folder">{{ .Path }}</span></folder>
{{ template "renderTree" .Children }}
</li>
{{ end }}
{{ end }}
{{ end }}
</ul>
{{ end }}