+a-z nav on alma pages

This commit is contained in:
Simon Martens
2026-01-12 20:14:47 +01:00
parent 98b9888e83
commit bcf7d1847d
3 changed files with 70 additions and 31 deletions

View File

@@ -67,6 +67,9 @@ type AlmanachResult struct {
Types []string Types []string
HasScans bool HasScans bool
PrevByTitle *dbmodels.Entry
NextByTitle *dbmodels.Entry
} }
func NewAlmanachResult(app core.App, id string, params BeitraegeFilterParameters) (*AlmanachResult, error) { func NewAlmanachResult(app core.App, id string, params BeitraegeFilterParameters) (*AlmanachResult, error) {
@@ -167,6 +170,11 @@ func NewAlmanachResult(app core.App, id string, params BeitraegeFilterParameters
agentsMap[a.Id] = a agentsMap[a.Id] = a
} }
prevByTitle, nextByTitle, err := entryNeighborsByPreferredTitle(app, entry.Id)
if err != nil {
return nil, err
}
ret := &AlmanachResult{ ret := &AlmanachResult{
Entry: entry, Entry: entry,
Places: places, Places: places,
@@ -179,6 +187,8 @@ func NewAlmanachResult(app core.App, id string, params BeitraegeFilterParameters
ContentsAgents: caMap, ContentsAgents: caMap,
Types: types, Types: types,
HasScans: hs, HasScans: hs,
PrevByTitle: prevByTitle,
NextByTitle: nextByTitle,
} }
ret.Collections() ret.Collections()
@@ -186,6 +196,32 @@ func NewAlmanachResult(app core.App, id string, params BeitraegeFilterParameters
} }
func entryNeighborsByPreferredTitle(app core.App, entryID string) (*dbmodels.Entry, *dbmodels.Entry, error) {
entries := []*dbmodels.Entry{}
if err := app.RecordQuery(dbmodels.ENTRIES_TABLE).All(&entries); err != nil {
return nil, nil, err
}
if len(entries) == 0 {
return nil, nil, nil
}
dbmodels.Sort_Entries_Title_Year(entries)
for index, item := range entries {
if item.Id != entryID {
continue
}
var prev *dbmodels.Entry
var next *dbmodels.Entry
if index > 0 {
prev = entries[index-1]
}
if index+1 < len(entries) {
next = entries[index+1]
}
return prev, next, nil
}
return nil, nil, nil
}
func (r *AlmanachResult) Collections() { func (r *AlmanachResult) Collections() {
ids := []int{} ids := []int{}
collections := []*dbmodels.Content{} collections := []*dbmodels.Content{}

View File

@@ -116,32 +116,6 @@ func NewAlmanachEditResult(app core.App, id string, filters BeitraegeFilterParam
}, nil }, nil
} }
func entryNeighborsByPreferredTitle(app core.App, entryID string) (*dbmodels.Entry, *dbmodels.Entry, error) {
entries := []*dbmodels.Entry{}
if err := app.RecordQuery(dbmodels.ENTRIES_TABLE).All(&entries); err != nil {
return nil, nil, err
}
if len(entries) == 0 {
return nil, nil, nil
}
dbmodels.Sort_Entries_Title_Year(entries)
for index, item := range entries {
if item.Id != entryID {
continue
}
var prev *dbmodels.Entry
var next *dbmodels.Entry
if index > 0 {
prev = entries[index-1]
}
if index+1 < len(entries) {
next = entries[index+1]
}
return prev, next, nil
}
return nil, nil, nil
}
func (p *AlmanachEditPage) POSTSave(engine *templating.Engine, app core.App) HandleFunc { func (p *AlmanachEditPage) POSTSave(engine *templating.Engine, app core.App) HandleFunc {
return func(e *core.RequestEvent) error { return func(e *core.RequestEvent) error {
id := e.Request.PathValue("id") id := e.Request.PathValue("id")

View File

@@ -22,6 +22,34 @@
<div class="container-oversize mt-12 pb-0 mb-0"> <div class="container-oversize mt-12 pb-0 mb-0">
<div class="pb-1.5 mx-32 flex flex-row items-center justify-between gap-2"> <div class="pb-1.5 mx-32 flex flex-row items-center justify-between gap-2">
<div><i class="ri-book-line"></i> Almanach</div> <div><i class="ri-book-line"></i> Almanach</div>
<div class="flex items-center gap-6">
<!-- Alphabetical Navigation (visible to all users) -->
<div class="flex items-center gap-3">
{{- if $model.result.PrevByTitle -}}
<tool-tip position="top" class="!inline">
<div class="data-tip">{{ $model.result.PrevByTitle.PreferredTitle }}</div>
<a
href="/almanach/{{ $model.result.PrevByTitle.MusenalmID }}"
class="text-gray-700 hover:text-slate-950 no-underline">
<i class="ri-arrow-left-s-line"></i>
</a>
</tool-tip>
{{- end -}}
<span class="text-gray-800 font-bold no-underline">
A&thinsp;-&thinsp;Z
</span>
{{- if $model.result.NextByTitle -}}
<tool-tip position="top" class="!inline">
<div class="data-tip">{{ $model.result.NextByTitle.PreferredTitle }}</div>
<a
href="/almanach/{{ $model.result.NextByTitle.MusenalmID }}"
class="text-gray-700 hover:text-slate-950 no-underline">
<i class="ri-arrow-right-s-line"></i>
</a>
</tool-tip>
{{- end -}}
</div>
<!-- Edit Button (admin/editor only) -->
{{- if (IsAdminOrEditor $model.request.user) -}} {{- if (IsAdminOrEditor $model.request.user) -}}
<div> <div>
<i class="ri-edit-line"></i> <i class="ri-edit-line"></i>
@@ -29,6 +57,7 @@
</div> </div>
{{- end -}} {{- end -}}
</div> </div>
</div>
<div class="pt-0 {{ if $hasContents -}}contentsentrydata{{- end -}}" id="entrydata"> <div class="pt-0 {{ if $hasContents -}}contentsentrydata{{- end -}}" id="entrydata">
<div class="container-normal !py-8"> <div class="container-normal !py-8">
<div class="flex flex-col"> <div class="flex flex-col">