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