library.html
| 1 | {{define "library"}} |
| 2 | <div class="page-header"> |
| 3 | <h2>Library</h2> |
| 4 | <div class="actions"> |
| 5 | <form method="get" action="/library" class="inline filter-form"> |
| 6 | <input type="hidden" name="path" value="{{.Data.Path}}"> |
| 7 | <input type="text" name="filter" placeholder="Search..." value="{{.Data.Filter}}"> |
| 8 | <select name="sort"> |
| 9 | <option value="date" {{if eq .Data.SortBy "date"}}selected{{end}}>Date</option> |
| 10 | <option value="title" {{if eq .Data.SortBy "title"}}selected{{end}}>Title</option> |
| 11 | <option value="duration" {{if eq .Data.SortBy "duration"}}selected{{end}}>Duration</option> |
| 12 | </select> |
| 13 | <button type="submit">Filter</button> |
| 14 | </form> |
| 15 | </div> |
| 16 | </div> |
| 17 | |
| 18 | {{if .Data.Path}} |
| 19 | <nav class="breadcrumbs"> |
| 20 | <a href="/library">Home</a> |
| 21 | {{$parts := splitPath .Data.Path}} |
| 22 | {{$last := sub (len $parts) 1}} |
| 23 | {{$currentPath := ""}} |
| 24 | {{range $i, $part := $parts}} |
| 25 | {{$currentPath = printf "%s/%s" $currentPath $part}} |
| 26 | <span>/</span> |
| 27 | {{if eq $i $last}} |
| 28 | <a href="/library?path={{urlEncodePath $currentPath}}" aria-current="page" class="current">{{$part}}</a> |
| 29 | {{else}} |
| 30 | <a href="/library?path={{urlEncodePath $currentPath}}">{{$part}}</a> |
| 31 | {{end}} |
| 32 | {{end}} |
| 33 | </nav> |
| 34 | {{end}} |
| 35 | |
| 36 | {{$parentPath := .Data.Path}} |
| 37 | <div class="library-grid"> |
| 38 | {{range .Data.Folders}} |
| 39 | <a href="/library?path={{urlEncodePath (printf "%s/%s" $parentPath .)}}" class="folder-item"> |
| 40 | <div class="folder-icon">📁</div> |
| 41 | <div class="folder-name">{{baseName .}}</div> |
| 42 | </a> |
| 43 | {{end}} |
| 44 | |
| 45 | {{range .Data.Items}} |
| 46 | <a href="/library/item/{{urlEncodePath .RelPath}}" class="media-item {{if gt (len .MediaFiles) 0}}{{if (index .MediaFiles 0).IsAudio}}audio{{else}}video{{end}}{{end}}"> |
| 47 | <div class="media-thumbnail"> |
| 48 | <img src="/media/item/{{urlEncodePath .RelPath}}/thumbnail" alt="" loading="lazy"> |
| 49 | {{if ge .Duration 0}} |
| 50 | <span class="media-duration">{{formatDuration .Duration}}</span> |
| 51 | {{end}} |
| 52 | </div> |
| 53 | <div class="media-info"> |
| 54 | <div class="media-title">{{.Name}}</div> |
| 55 | </div> |
| 56 | </a> |
| 57 | {{end}} |
| 58 | </div> |
| 59 | |
| 60 | {{if and (eq (len .Data.Folders) 0) (eq (len .Data.Items) 0)}} |
| 61 | <div class="empty-state"> |
| 62 | <p>No media found. <a href="/download">Start a download</a> or add existing files.</p> |
| 63 | </div> |
| 64 | {{end}} |
| 65 | {{end}} |
| 66 |