tagliatelle

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit a842db56bf29283afc0d0a4c2026ec1d09d53577
parent c6528f1857e0ec40a24e8ac6979c755bcfb86f80
Author: breadcat <breadcat@users.noreply.github.com>
Date:   Fri, 10 Jul 2026 15:07:37 +0100

Only show untagged menu entry if untagged files exist

Also show count of untagged files in menu

Diffstat:
Minclude-general.go | 54++++++++++++++++++++++++++++++++++++------------------
Mtemplates/_header.html | 2+-
2 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/include-general.go b/include-general.go @@ -19,17 +19,18 @@ type ListData struct { } type PageData struct { - Title string - Data interface{} - Query string - IP string - Port string - Files []File - Tags map[string][]TagDisplay - Properties map[string][]PropertyDisplay - Breadcrumbs []Breadcrumb - Pagination *Pagination - GallerySize string + Title string + Data interface{} + Query string + IP string + Port string + Files []File + Tags map[string][]TagDisplay + Properties map[string][]PropertyDisplay + Breadcrumbs []Breadcrumb + Pagination *Pagination + GallerySize string + UntaggedCount int } type File struct { @@ -95,11 +96,12 @@ func buildPageData(title string, data interface{}) PageData { log.Printf("Warning: buildPageData: failed to load property nav for page %q: %v", title, err) } return PageData{ - Title: title, - Data: data, - Tags: tagMap, - Properties: propMap, - GallerySize: config.GallerySize, + Title: title, + Data: data, + Tags: tagMap, + Properties: propMap, + GallerySize: config.GallerySize, + UntaggedCount: getUntaggedCount(), } } @@ -137,4 +139,21 @@ func tagsHandler(w http.ResponseWriter, r *http.Request) { pageData := buildPageData("All Tags", nil) pageData.Data = pageData.Tags renderTemplate(w, "tags.html", pageData) -} -\ No newline at end of file +} + +func getUntaggedCount() int { + var count int + + err := db.QueryRow(` + SELECT COUNT(*) + FROM files f + LEFT JOIN file_tags ft ON ft.file_id = f.id + WHERE ft.file_id IS NULL + `).Scan(&count) + + if err != nil { + log.Printf("Warning: getUntaggedCount: %v", err) + return 0 + } + return count +} diff --git a/templates/_header.html b/templates/_header.html @@ -31,7 +31,7 @@ </ul> </li>{{end}} <li><a href="/bulk-tag">Bulk Editor</a></li> -<li><a href="/untagged">Untagged</a></li> +{{if gt .UntaggedCount 0}}<li><a href="/untagged">Untagged ({{.UntaggedCount}})</a></li>{{end}} </ul></li> <li><a href="/properties"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path fill="000000" d="M3.5 4A1.5 1.5 0 0 0 2 5.5v2A1.5 1.5 0 0 0 3.5 9h2A1.5 1.5 0 0 0 7 7.5v-2A1.5 1.5 0 0 0 5.5 4zM3 5.5a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5zM9.5 5a.5.5 0 0 0 0 1h8a.5.5 0 0 0 0-1zm0 2a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm-6 4A1.5 1.5 0 0 0 2 12.5v2A1.5 1.5 0 0 0 3.5 16h2A1.5 1.5 0 0 0 7 14.5v-2A1.5 1.5 0 0 0 5.5 11zM3 12.5a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5zm6.5-.5a.5.5 0 0 0 0 1h8a.5.5 0 0 0 0-1zm0 2a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1z"/></svg><span>Properties</span></a> <ul class="sub-menu">