mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 09:15:33 +00:00
Single Reihen Page
This commit is contained in:
@@ -246,3 +246,15 @@ func SeriesForYear(app core.App, year int) ([]*Series, SeriesEntries, map[string
|
|||||||
|
|
||||||
return SeriesForEntries(app, series)
|
return SeriesForEntries(app, series)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SeriesForId(app core.App, id string) (*Series, error) {
|
||||||
|
s := &Series{}
|
||||||
|
err := app.RecordQuery(SERIES_TABLE).
|
||||||
|
Where(dbx.HashExp{MUSENALMID_FIELD: id}).
|
||||||
|
One(s)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s, nil
|
||||||
|
}
|
||||||
|
|||||||
64
pages/reihe.go
Normal file
64
pages/reihe.go
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
package pages
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/Theodor-Springmann-Stiftung/musenalm/app"
|
||||||
|
"github.com/Theodor-Springmann-Stiftung/musenalm/dbmodels"
|
||||||
|
"github.com/Theodor-Springmann-Stiftung/musenalm/pagemodels"
|
||||||
|
"github.com/Theodor-Springmann-Stiftung/musenalm/templating"
|
||||||
|
"github.com/pocketbase/pocketbase/core"
|
||||||
|
"github.com/pocketbase/pocketbase/tools/router"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
URL_REIHE = "/reihe/{id}/"
|
||||||
|
TEMPLATE_REIHE = "/reihe/"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
rp := &ReihePage{
|
||||||
|
Page: pagemodels.Page{
|
||||||
|
Name: pagemodels.P_REIHEN_NAME,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
app.Register(rp)
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReihePage struct {
|
||||||
|
pagemodels.Page
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *ReihePage) Setup(router *router.Router[*core.RequestEvent], app core.App, engine *templating.Engine) error {
|
||||||
|
router.GET(URL_REIHE, func(e *core.RequestEvent) error {
|
||||||
|
id := e.Request.PathValue("id")
|
||||||
|
data := make(map[string]interface{})
|
||||||
|
reihe, err := dbmodels.SeriesForId(app, id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
data["series"] = reihe
|
||||||
|
|
||||||
|
rmap, emap, err := dbmodels.EntriesForSeriesses(app, []*dbmodels.Series{reihe})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
data["relations"] = rmap
|
||||||
|
data["entries"] = emap
|
||||||
|
|
||||||
|
return p.Get(e, engine, data)
|
||||||
|
|
||||||
|
})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *ReihePage) Get(request *core.RequestEvent, engine *templating.Engine, data map[string]interface{}) error {
|
||||||
|
var builder strings.Builder
|
||||||
|
err := engine.Render(&builder, TEMPLATE_REIHE, data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return request.HTML(http.StatusOK, builder.String())
|
||||||
|
}
|
||||||
@@ -15,7 +15,6 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
URL_REIHEN = "/reihen/"
|
URL_REIHEN = "/reihen/"
|
||||||
URL_REIHE = "/reihen/{id}/"
|
|
||||||
PARAM_LETTER = "letter"
|
PARAM_LETTER = "letter"
|
||||||
PARAM_SEARCH = "search"
|
PARAM_SEARCH = "search"
|
||||||
PARAM_PERSON = "agent"
|
PARAM_PERSON = "agent"
|
||||||
|
|||||||
6
views/routes/reihe/body.gohtml
Normal file
6
views/routes/reihe/body.gohtml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{{ if .series }}
|
||||||
|
{{ .series.Title }}
|
||||||
|
<div>
|
||||||
|
{{ Safe .series.Annotation }}
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
1
views/routes/reihe/head.gohtml
Normal file
1
views/routes/reihe/head.gohtml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<title>Musenalm - Reihen</title>
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
{{ range $id, $r := .series }}
|
{{ range $id, $r := .series }}
|
||||||
<div>
|
<div>
|
||||||
{{ $r.Title }}
|
<a href="/reihe/{{ $r.MusenalmID }}">{{ $r.Title }}</a>
|
||||||
<div>
|
<div>
|
||||||
{{ Safe $r.Annotation }}
|
{{ Safe $r.Annotation }}
|
||||||
</div>
|
</div>
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
<div class="mt-8">
|
<div class="mt-8">
|
||||||
{{ range $id, $r := .altseries }}
|
{{ range $id, $r := .altseries }}
|
||||||
<div>
|
<div>
|
||||||
{{ $r.Title }}
|
<a href="/reihe/{{ $r.MusenalmID }}">{{ $r.Title }}</a>
|
||||||
<div>
|
<div>
|
||||||
{{ Safe $r.Annotation }}
|
{{ Safe $r.Annotation }}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user