fix: add back link to public folders
All checks were successful
CI / hygiene (push) Successful in 2s
Build and Deploy / build-and-deploy (push) Successful in 30s
CI / test (push) Successful in 20s

This commit is contained in:
Grendgi
2026-06-16 17:02:29 +03:00
parent c397ff2c90
commit 51aba865eb

View File

@@ -379,7 +379,7 @@ func (h *NodeHandler) PublicMeta(w http.ResponseWriter, r *http.Request) {
writeInternalError(w, r, err, "failed to list folder") writeInternalError(w, r, err, "failed to list folder")
return return
} }
h.renderPublicFolder(w, r, node, children) h.renderPublicFolder(w, r, node, children, false)
return return
} }
h.renderPublicUnavailable(w, node) h.renderPublicUnavailable(w, node)
@@ -415,7 +415,7 @@ func (h *NodeHandler) PublicChildMeta(w http.ResponseWriter, r *http.Request) {
writeInternalError(w, r, err, "failed to list folder") writeInternalError(w, r, err, "failed to list folder")
return return
} }
h.renderPublicFolder(w, r, node, children) h.renderPublicFolder(w, r, node, children, true)
return return
} }
h.renderPublicUnavailable(w, node) h.renderPublicUnavailable(w, node)
@@ -563,8 +563,12 @@ func (h *NodeHandler) renderPublicPreview(w http.ResponseWriter, node *model.Nod
</html>`) </html>`)
} }
func (h *NodeHandler) renderPublicFolder(w http.ResponseWriter, r *http.Request, node *model.Node, children []model.Node) { func (h *NodeHandler) renderPublicFolder(w http.ResponseWriter, r *http.Request, node *model.Node, children []model.Node, showBack bool) {
token := chi.URLParam(r, "token") token := chi.URLParam(r, "token")
backLink := ""
if showBack && node.ParentID != nil && *node.ParentID != "" {
backLink = `<a class="back-link" href="` + html.EscapeString(h.publicNodeURL(token, *node.ParentID)) + `">← Назад к папке выше</a>`
}
items := `<div class="empty">В папке пока нет файлов.</div>` items := `<div class="empty">В папке пока нет файлов.</div>`
if len(children) > 0 { if len(children) > 0 {
var b strings.Builder var b strings.Builder
@@ -608,6 +612,9 @@ func (h *NodeHandler) renderPublicFolder(w http.ResponseWriter, r *http.Request,
h1 { margin: 0; font-size: 22px; line-height: 1.35; font-weight: 800; } h1 { margin: 0; font-size: 22px; line-height: 1.35; font-weight: 800; }
.meta { margin-top: 6px; color: #9aa7bd; font-size: 14px; } .meta { margin-top: 6px; color: #9aa7bd; font-size: 14px; }
main { padding: 24px; } main { padding: 24px; }
.nav { max-width: 980px; margin: 0 auto 14px; }
.back-link { display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border: 1px solid #263044; border-radius: 8px; background: #151a2a; color: #c7d2fe; text-decoration: none; font-weight: 700; }
.back-link:hover { border-color: #6366f1; background: #191f34; }
.list { display: grid; gap: 10px; max-width: 980px; margin: 0 auto; } .list { display: grid; gap: 10px; max-width: 980px; margin: 0 auto; }
.item { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 14px; align-items: center; min-height: 58px; padding: 12px 14px; border: 1px solid #263044; border-radius: 10px; background: #151a2a; color: inherit; text-decoration: none; } .item { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 14px; align-items: center; min-height: 58px; padding: 12px 14px; border: 1px solid #263044; border-radius: 10px; background: #151a2a; color: inherit; text-decoration: none; }
.item:hover { border-color: #6366f1; background: #191f34; } .item:hover { border-color: #6366f1; background: #191f34; }
@@ -624,7 +631,7 @@ func (h *NodeHandler) renderPublicFolder(w http.ResponseWriter, r *http.Request,
<h1>`+html.EscapeString(node.Title)+`</h1> <h1>`+html.EscapeString(node.Title)+`</h1>
<div class="meta">Публичный просмотр папки</div> <div class="meta">Публичный просмотр папки</div>
</header> </header>
<main>`+items+`</main> <main><div class="nav">`+backLink+`</div>`+items+`</main>
</div> </div>
</body> </body>
</html>`) </html>`)