Page target navigation

This commit is contained in:
Simon Martens
2025-09-19 16:41:00 +02:00
parent 04d62d9e67
commit 2574124588
22 changed files with 1582 additions and 203 deletions

View File

@@ -53,11 +53,35 @@ func PageIcon(iconType string) template.HTML {
return template.HTML(`<i class="ri-file-text-line text-black text-sm" style="margin-left: 2px; transform: scaleX(-1); display: inline-block;"></i><i class="ri-file-text-line text-slate-400 text-sm"></i>`)
case "odd":
return template.HTML(`<i class="ri-file-text-line text-slate-400 text-sm" style="margin-left: 2px; transform: scaleX(-1); display: inline-block;"></i><i class="ri-file-text-line text-black text-sm" ></i>`)
case "single":
return template.HTML(`<i class="ri-file-text-line text-black text-sm"></i>`)
default:
return template.HTML(`<i class="ri-file-text-line text-black text-sm"></i>`)
}
}
// GetPieceURL generates a piece view URL from year, issue number, and page
func GetPieceURL(year, issueNum, page int) string {
pieceID := fmt.Sprintf("%d-%03d-%03d", year, issueNum, page)
return "/beitrag/" + pieceID
}
// IssueContext formats an issue reference into a readable context string
func IssueContext(issueRef interface{}) string {
// Handle both direct IssueRef and map formats
switch ref := issueRef.(type) {
case map[string]interface{}:
if year, ok := ref["year"].(int); ok {
if nr, ok := ref["nr"].(int); ok {
return fmt.Sprintf("%d Nr. %d", year, nr)
}
}
return "Unbekannte Ausgabe"
default:
return "Unbekannte Ausgabe"
}
}
func (e *Engine) funcs() error {
e.mu.Lock()
e.mu.Unlock()
@@ -114,6 +138,10 @@ func (e *Engine) funcs() error {
// Page icons for ausgabe templates
e.AddFunc("PageIcon", PageIcon)
// Piece view helpers
e.AddFunc("GetPieceURL", GetPieceURL)
e.AddFunc("IssueContext", IssueContext)
return nil
}