diff --git a/dbmodels/queries.go b/dbmodels/queries.go index b655b49..aa7a48f 100644 --- a/dbmodels/queries.go +++ b/dbmodels/queries.go @@ -58,6 +58,15 @@ func RContentsAgents_Contents(app core.App, id []any) ([]*RContentsAgents, error ) } +func RContentsAgents_Content(app core.App, id string) ([]*RContentsAgents, error) { + return TableByFields[[]*RContentsAgents]( + app, + RelationTableName(CONTENTS_TABLE, AGENTS_TABLE), + CONTENTS_TABLE, + id, + ) +} + func REntriesSeries_Entries(app core.App, ids []any) ([]*REntriesSeries, error) { return TableByFields[[]*REntriesSeries]( app, @@ -139,6 +148,11 @@ func Contents_Entry(app core.App, id string) ([]*Content, error) { ) } +func Contents_MusenalmID(app core.App, id string) (*Content, error) { + ret, err := TableByField[Content](app, CONTENTS_TABLE, MUSENALMID_FIELD, id) + return &ret, err +} + func Places_ID(app core.App, id string) (*Place, error) { ret, err := TableByField[Place](app, PLACES_TABLE, ID_FIELD, id) return &ret, err diff --git a/pagemodels/pagedata.go b/pagemodels/pagedata.go index c9d3ed1..353a141 100644 --- a/pagemodels/pagedata.go +++ b/pagemodels/pagedata.go @@ -1,6 +1,7 @@ package pagemodels const ( + P_BEITRAG_NAME = "beitrag" P_DATENSCHUTZ_NAME = "datenschutz" P_SUCHE_NAME = "suche" diff --git a/pages/almanach.go b/pages/almanach.go index 1dcf78f..53ce945 100644 --- a/pages/almanach.go +++ b/pages/almanach.go @@ -18,7 +18,10 @@ const ( func init() { rp := &AlmanachPage{ StaticPage: pagemodels.StaticPage{ - Name: pagemodels.P_REIHEN_NAME, + Name: pagemodels.P_REIHEN_NAME, + URL: URL_ALMANACH, + Template: TEMPLATE_ALMANACH, + Layout: templating.DEFAULT_LAYOUT_NAME, }, } app.Register(rp) @@ -29,40 +32,26 @@ type AlmanachPage struct { } func (p *AlmanachPage) Setup(router *router.Router[*core.RequestEvent], app core.App, engine *templating.Engine) error { - router.GET(URL_ALMANACH, func(e *core.RequestEvent) error { + router.GET(p.URL, func(e *core.RequestEvent) error { id := e.Request.PathValue("id") data := make(map[string]interface{}) result, err := NewAlmanachResult(app, id) if err != nil { engine.Response404(e, err, nil) } - data["result"] = result - err = p.getAbbr(app, data) - if err != nil { - return engine.Response404(e, err, data) + + abbrs, err := pagemodels.GetAbks(app) + if err == nil { + data["abbrs"] = abbrs } - return p.Get(e, engine, data) + return engine.Response200(e, p.Template, data) }) return nil } -func (p *AlmanachPage) getAbbr(app core.App, data map[string]interface{}) error { - abbrs, err := pagemodels.GetAbks(app) - if err != nil { - return err - } - - data["abbrs"] = abbrs - return nil -} - -func (p *AlmanachPage) Get(request *core.RequestEvent, engine *templating.Engine, data map[string]interface{}) error { - return engine.Response200(request, TEMPLATE_ALMANACH, data) -} - type AlmanachResult struct { Entry *dbmodels.Entry Places []*dbmodels.Place diff --git a/pages/beitrag.go b/pages/beitrag.go new file mode 100644 index 0000000..0df134e --- /dev/null +++ b/pages/beitrag.go @@ -0,0 +1,140 @@ +package pages + +import ( + "github.com/Theodor-Springmann-Stiftung/musenalm/app" + "github.com/Theodor-Springmann-Stiftung/musenalm/dbmodels" + "github.com/Theodor-Springmann-Stiftung/musenalm/helpers/datatypes" + "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_BEITRAG = "/beitrag/{id}" + TEMPLATE_BEITRAG = "/beitrag/" +) + +func init() { + rp := &BeitragPage{ + StaticPage: pagemodels.StaticPage{ + Name: pagemodels.P_BEITRAG_NAME, + URL: URL_BEITRAG, + Template: TEMPLATE_BEITRAG, + Layout: templating.DEFAULT_LAYOUT_NAME, + }, + } + app.Register(rp) +} + +type BeitragPage struct { + pagemodels.StaticPage +} + +func (p *BeitragPage) Setup(router *router.Router[*core.RequestEvent], app core.App, engine *templating.Engine) error { + router.GET(p.URL, func(e *core.RequestEvent) error { + id := e.Request.PathValue("id") + data := make(map[string]interface{}) + result, err := NewBeitragResult(app, id) + if err != nil { + engine.Response404(e, err, nil) + } + data["result"] = result + + abbrs, err := pagemodels.GetAbks(app) + if err == nil { + data["abbrs"] = abbrs + } + + return engine.Response200(e, p.Template, data) + }) + + return nil +} + +type BeitragResult struct { + Entry *dbmodels.Entry + Places []*dbmodels.Place + Series []*dbmodels.Series + Content *dbmodels.Content + Agents map[string]*dbmodels.Agent // <- Key is agent id + EntriesSeries map[string]*dbmodels.REntriesSeries // <- Key is series id + EntriesAgents []*dbmodels.REntriesAgents + ContentsAgents []*dbmodels.RContentsAgents // <- Key is content id +} + +func NewBeitragResult(app core.App, id string) (*BeitragResult, error) { + content, err := dbmodels.Contents_MusenalmID(app, id) + if err != nil { + return nil, err + } + + entry, err := dbmodels.Entries_ID(app, content.Entry()) + if err != nil { + return nil, err + } + + places, err := dbmodels.Places_IDs(app, datatypes.ToAny(entry.Places())) + if err != nil { + return nil, err + } + + srelations, err := dbmodels.REntriesSeries_Entry(app, entry.Id) + if err != nil { + return nil, err + } + + sids := []any{} + srelationsMap := make(map[string]*dbmodels.REntriesSeries) + for _, s := range srelations { + sids = append(sids, s.Series()) + srelationsMap[s.Series()] = s + } + + series, err := dbmodels.Series_IDs(app, sids) + if err != nil { + return nil, err + } + + arelations, err := dbmodels.REntriesAgents_Entry(app, entry.Id) + if err != nil { + return nil, err + } + + acrelations, err := dbmodels.RContentsAgents_Content(app, content.Id) + if err != nil { + return nil, err + } + + aids := []any{} + arelationsMap := make(map[string]*dbmodels.REntriesAgents) + for _, r := range arelations { + aids = append(aids, r.Agent()) + arelationsMap[r.Agent()] = r + } + + for _, r := range acrelations { + aids = append(aids, r.Agent()) + } + + agents, err := dbmodels.Agents_IDs(app, aids) + if err != nil { + return nil, err + } + + agentsMap := make(map[string]*dbmodels.Agent) + for _, a := range agents { + agentsMap[a.Id] = a + } + + return &BeitragResult{ + Entry: entry, + Places: places, + Series: series, + Content: content, + Agents: agentsMap, + EntriesSeries: srelationsMap, + EntriesAgents: arelations, + ContentsAgents: acrelations, + }, nil +} diff --git a/views/routes/almanach/body.gohtml b/views/routes/almanach/body.gohtml index 5fd423c..40bef19 100644 --- a/views/routes/almanach/body.gohtml +++ b/views/routes/almanach/body.gohtml @@ -60,13 +60,26 @@ {{ template "entrydata" $model }} - -
- {{- range $i, $c := $model.result.Contents -}} - {{- $rels := index $model.result.ContentsAgents $c.Id -}} - {{- $coll := index $model.result.CInfoByContent $c.MusenalmID -}} - {{- if and $coll (index $coll 0) -}} - {{- end -}} - {{- template "_content" Arr $c $model.result.Entry $rels $model.result.Agents -}} - {{- end -}} -
+{{- if $model.result.Contents | len -}} +
+
+
+

Inhalt

+
+ {{- len $model.result.Contents }} erfasste Beiträge · + Anzeige nach Reihenfolge +
+
+
+
+
+ {{- range $i, $c := $model.result.Contents -}} + {{- $rels := index $model.result.ContentsAgents $c.Id -}} + {{- $coll := index $model.result.CInfoByContent $c.MusenalmID -}} + {{- if and $coll (index $coll 0) -}} + {{- end -}} + {{- template "_content" Arr $c $model.result.Entry $rels $model.result.Agents -}} + {{- end -}} +
+
+{{- end -}} diff --git a/views/routes/almanach/components/entrydata.gohtml b/views/routes/almanach/components/entrydata.gohtml index f9222c7..718c87d 100644 --- a/views/routes/almanach/components/entrydata.gohtml +++ b/views/routes/almanach/components/entrydata.gohtml @@ -15,13 +15,14 @@ {{ $isFra := false }} {{ $isEng := false }} +{{- $hasContents := len $model.result.Contents -}} -
+ +
Almanach
-
-
-
-
+
+
+
Almanach-Nummer
{{ $model.result.Entry.MusenalmID }}
diff --git a/views/routes/beitrag/body.gohtml b/views/routes/beitrag/body.gohtml new file mode 100644 index 0000000..b942e77 --- /dev/null +++ b/views/routes/beitrag/body.gohtml @@ -0,0 +1,64 @@ +{{- $model := . }} +{{/* type BeitragResult struct { + Entry *dbmodels.Entry + Places []*dbmodels.Place + Series []*dbmodels.Series + Content *dbmodels.Content + Agents map[string]*dbmodels.Agent // <- Key is agent id + EntriesSeries map[string]*dbmodels.REntriesSeries // <- Key is series id + EntriesAgents []*dbmodels.REntriesAgents + ContentsAgents []*dbmodels.RContentsAgents // <- Key is content id + } +*/}} + + + + +
+
Einzelbeitrag
+

+ {{ $model.result.Entry.PreferredTitle }}, + {{ if $model.result.Content.Extent -}} + S. + {{ $model.result.Content.Extent }} + {{ else -}} + Nr. + {{ $model.result.Content.MusenalmID }} + {{- end -}} +

+ + {{- $arr := $model.result.Content.MusenalmType -}} + {{- if $arr -}} + {{- range $i, $p := $arr -}} + + {{- $p -}} + + {{- end -}} + {{- end -}} + + +
+ {{- template "_content" Arr $model.result.Content $model.result.Entry $model.result.ContentsAgents $model.result.Agents true -}} +
+
diff --git a/views/routes/components/_content.gohtml b/views/routes/components/_content.gohtml index 8be7baa..45b0bdb 100644 --- a/views/routes/components/_content.gohtml +++ b/views/routes/components/_content.gohtml @@ -3,6 +3,7 @@ .2 - *Entry .3 - []*RContentsAgents .4 - map[string]*Agent + .5 bool SingleView */}} {{- $content := index . 0 -}} @@ -10,29 +11,48 @@ {{- $rcas := index . 2 -}} {{- $agents := index . 3 -}} +{{- $singleView := false -}} +{{- if gt (len .) 4 -}} + {{- $singleView = index . 4 -}} +{{- end -}} +
-
- {{- if $content.Extent -}} -
- S. - {{- $content.Extent -}} -
- {{- end -}} - {{- if $content.MusenalmType -}} -
- {{- range $_, $t := $content.MusenalmType -}} -
- {{- $t -}} -
- {{- end -}} -
- {{- end -}} + {{- if not $singleView -}} +
+ {{- if $content.Extent -}} +
+ S. + {{- $content.Extent -}} +
+ {{- end -}} + {{- if $content.MusenalmType -}} +
+ {{- range $_, $t := $content.MusenalmType -}} +
+ {{- $t -}} +
+ {{- end -}} +
+ {{- end -}} +
+ {{- end -}} -
+ {{- if $singleView -}} +
Almanach
+
+ + {{- $entry.PreferredTitle -}} + + {{- if $content.Extent -}} + , S. + {{- $content.Extent -}} + {{- end -}} +
+ {{- end -}} {{- if $content.TitleStmt -}}
Titel
{{- $content.TitleStmt -}}
@@ -48,17 +68,15 @@ {{- if $rcas -}}
Personen
- {{- range $_, $rca := $rcas -}} -
+
+ {{- range $_, $rca := $rcas -}} {{- $agent := index $agents $rca.Agent -}} - {{- if $agent -}} -
- {{- $agent.Name -}} - ({{ $agent.BiographicalData -}}) -
- {{- end -}} -
- {{- end -}} +
+ {{- $agent.Name -}} + ({{ $agent.BiographicalData -}}) +
+ {{- end -}} +
{{- end -}} {{- if $content.Annotation -}} @@ -72,47 +90,75 @@
+ {{- if not $singleView -}} + {{- $scans := $content.ImagePaths -}} + {{- $slen := len $scans -}} + {{- $double := false -}} + {{- if gt $slen 2 -}} + {{- $double = true -}} + {{- end -}} +
+ {{- if $scans -}} +
+ {{- range $_, $scan := $scans -}} +
+ + + +
+ {{- end -}} +
+ {{- end -}} +
+ +
+
+ NR + {{ $content.MusenalmID -}} +
+ +
+ {{- end -}} +
+ +{{- if $singleView -}} {{- $scans := $content.ImagePaths -}} {{- $slen := len $scans -}} {{- $double := false -}} {{- if gt $slen 2 -}} {{- $double = true -}} {{- end -}} -
+
{{- if $scans -}} -
- {{- range $_, $scan := $scans -}} +
+ {{- range $i, $scan := $scans -}}
+ src="{{- $scan -}}?thumb=0x1000" + class="max-h-[32rem] border-6 hover:border-zinc-400 object-cover cursor-pointer" />
{{- end -}}
{{- end -}}
- -
-
- NR - {{ $content.MusenalmID -}} -
- -
-
+{{- end -}} diff --git a/views/transform/site.css b/views/transform/site.css index 219c1d7..34e4c4a 100644 --- a/views/transform/site.css +++ b/views/transform/site.css @@ -361,6 +361,25 @@ } #entrydata { + @apply relative; + } + + #entrydata:not(#entrydata.contentsentrydata) { + @apply border border-zinc-300; + } + + #entrydata.contentsentrydata { + @apply border-t border-r border-zinc-300 pb-16; + } + + #entrydata.contentsentrydata:after { + content: ""; + @apply absolute top-0 left-0 w-[1px] h-[50%] bg-zinc-300; + } + + #entrydata.contentsentrydata:before { + content: ""; + @apply absolute bottom-0 right-0 h-[1px] w-[50%] bg-zinc-300; } int-link {