Files
donniemarko/internal/web/templates/noteList.tmpl

56 lines
2.3 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 }}
{{ if ne .TagFilter "" }}<h2>Filtered by tag '{{ .TagFilter }}'</h2>{{ end }}
<ul class="search-results">
{{ range .Notes }}
<li {{ if eq .ID $.LastActive }}class="active-note"{{ end }}>
<div class="note-title">
<a href="/notes/{{ .ID }}" data-hash="{{ .ID }}">{{ if ge (len .Title) 30 }}{{printf "%.30s" .Title }}[...]{{ else }} {{ .Title }}{{ end }}</a>
</div>
<span class="last-modified">{{ .GetUpdateDateRep }}</span>
</li>
{{ 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 }}