diff --git a/controllers/almanach.go b/controllers/almanach.go index dc5f080..eafda2f 100644 --- a/controllers/almanach.go +++ b/controllers/almanach.go @@ -1,7 +1,9 @@ package controllers import ( + "net/http" "sort" + "strings" "sync" "github.com/Theodor-Springmann-Stiftung/musenalm/app" @@ -16,9 +18,9 @@ import ( const ( URL_ALMANACH = "/almanach/{id}/" - URL_ALMANACH_CONTENTS = "/almanach/{id}/contents/" + URL_ALMANACH_CONTENTS = "/almanach/{id}/contents-view/" TEMPLATE_ALMANACH = "/almanach/" - TEMPLATE_ALMANACH_CONTENTS = "/almanach/contents/" + TEMPLATE_ALMANACH_CONTENTS = "/almanach/contents-view/" ) // Simple in-memory cache for sorted entries @@ -92,6 +94,11 @@ func (p *AlmanachPage) Setup(router *router.Router[*core.RequestEvent], ia pagem func (p *AlmanachPage) GET(engine *templating.Engine, app core.App) HandleFunc { return func(e *core.RequestEvent) error { + path := e.Request.URL.Path + if strings.Contains(path, "/contents/") && strings.HasSuffix(path, "/edit/") { + return e.Redirect(http.StatusTemporaryRedirect, strings.TrimSuffix(path, "/")) + } + id := e.Request.PathValue("id") data := make(map[string]any) filters := NewBeitraegeFilterParameters(e) diff --git a/controllers/almanach_contents_edit.go b/controllers/almanach_contents_edit.go index 61e618c..6f99f20 100644 --- a/controllers/almanach_contents_edit.go +++ b/controllers/almanach_contents_edit.go @@ -17,21 +17,21 @@ import ( "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" "github.com/pocketbase/pocketbase/tools/filesystem" + "github.com/pocketbase/pocketbase/tools/router" ) const ( - URL_ALMANACH_CONTENTS_EDIT = "contents/edit" - URL_ALMANACH_CONTENTS_NEW = "contents/new" - URL_ALMANACH_CONTENTS_ITEM_EDIT = "contents/{contentMusenalmId}/edit" - URL_ALMANACH_CONTENTS_DELETE = "contents/delete" - URL_ALMANACH_CONTENTS_EDIT_EXTENT = "contents/edit/extent" - URL_ALMANACH_CONTENTS_UPLOAD = "contents/upload" - URL_ALMANACH_CONTENTS_DELETE_SCAN = "contents/scan/delete" - TEMPLATE_ALMANACH_CONTENTS_EDIT = "/almanach/contents/edit/" - TEMPLATE_ALMANACH_CONTENTS_ITEM_EDIT = "/almanach/contents/edit_item/" - TEMPLATE_ALMANACH_CONTENTS_IMAGES_PANEL = "/almanach/contents/images_panel/" + URL_ALMANACH_CONTENTS_EDIT = "contents/edit" + URL_ALMANACH_CONTENTS_NEW = "contents/new" + URL_ALMANACH_CONTENTS_ITEM_EDIT = "contents/{contentMusenalmId}/edit" + URL_ALMANACH_CONTENTS_DELETE = "contents/delete" + URL_ALMANACH_CONTENTS_EDIT_EXTENT = "contents/edit/extent" + URL_ALMANACH_CONTENTS_UPLOAD = "contents/upload" + URL_ALMANACH_CONTENTS_DELETE_SCAN = "contents/scan/delete" + TEMPLATE_ALMANACH_CONTENTS_EDIT = "/contents/edit/" + TEMPLATE_ALMANACH_CONTENTS_ITEM_EDIT = "/contents/edit_item/" + TEMPLATE_ALMANACH_CONTENTS_IMAGES_PANEL = "/contents/images_panel/" ) func init() { @@ -955,9 +955,9 @@ type contentAgentRelationPayload struct { } type contentAgentRelationsPayload struct { - Relations []contentAgentRelationPayload + Relations []contentAgentRelationPayload NewRelations []contentAgentRelationPayload - DeletedIDs []string + DeletedIDs []string } type contentAgentRender struct { diff --git a/views/routes/almanach/body.gohtml b/views/routes/almanach/body.gohtml index a985698..247bb47 100644 --- a/views/routes/almanach/body.gohtml +++ b/views/routes/almanach/body.gohtml @@ -63,7 +63,7 @@ {{- if $model.result.HasContents -}}
+
+
+

Inhalt

+
+
+ {{- if $model.filters.Type -}} + {{- $i := len $model.result.Contents -}} + {{- if eq $i 1 -}} + {{- $i }} Beitrag der Kategorie {{ $model.filters.Type }} · + {{- else -}} + {{- $i }} Beiträge der Kategorie {{ $model.filters.Type }} · + {{- end -}} + {{- else if $model.filters.OnlyScans -}} +   + {{- $i := len $model.result.Contents -}} + {{- if eq $i 1 -}} + {{- $i }} Digitalisat · + {{- else -}} + {{- $i }} Digitalisate · + {{- end -}} + {{- else -}} + {{- if eq (len $model.result.Contents) 1 -}} + {{- len $model.result.Contents }} erfasster Beitrag · + {{- else -}} + {{- len $model.result.Contents }} erfasste Beiträge · + {{- end -}} + {{- end -}} + Anzeige nach Reihenfolge +
+ {{- if or $model.filters.Type $model.filters.OnlyScans -}} + + {{- end -}} +
+
+
+
+
+ {{- if gt (len $model.result.Types) 1 -}} +
+
+ + + +
+
+ {{- end -}} + {{- if $model.result.HasScans -}} +
+
+ + + +
+
+ {{- end -}} +
+
+ {{- range $i, $c := $model.result.Contents -}} + {{- $rels := index $model.result.ContentsAgents $c.Id -}} + {{- template "_content" Arr $c $model.result.Entry $rels $model.result.Agents false false false $model.request -}} + {{- end -}} +
+
+
diff --git a/views/routes/almanach/components/entrydata.gohtml b/views/routes/almanach/components/entrydata.gohtml index a1a5d6c..0e8fba4 100644 --- a/views/routes/almanach/components/entrydata.gohtml +++ b/views/routes/almanach/components/entrydata.gohtml @@ -57,7 +57,7 @@
- Beiträge bearbeiten + Beiträge bearbeiten
{{- end -}} diff --git a/views/routes/almanach/contents/body.gohtml b/views/routes/almanach/contents-view/body.gohtml similarity index 100% rename from views/routes/almanach/contents/body.gohtml rename to views/routes/almanach/contents-view/body.gohtml diff --git a/views/routes/almanach/edit/body.gohtml b/views/routes/almanach/edit/body.gohtml index a853ba7..2d2a78e 100644 --- a/views/routes/almanach/edit/body.gohtml +++ b/views/routes/almanach/edit/body.gohtml @@ -45,7 +45,7 @@ type AlmanachResult struct { Almanach {{- if not $model.is_new -}} - + Beiträge {{- else -}} diff --git a/views/routes/components/_content_edit_form.gohtml b/views/routes/components/_content_edit_form.gohtml index 001cd79..9d21630 100644 --- a/views/routes/components/_content_edit_form.gohtml +++ b/views/routes/components/_content_edit_form.gohtml @@ -36,7 +36,7 @@
- + Zurueck diff --git a/views/routes/almanach/contents/detail/body.gohtml b/views/routes/contents/detail/body.gohtml similarity index 100% rename from views/routes/almanach/contents/detail/body.gohtml rename to views/routes/contents/detail/body.gohtml diff --git a/views/routes/almanach/contents/edit/body.gohtml b/views/routes/contents/edit/body.gohtml similarity index 99% rename from views/routes/almanach/contents/edit/body.gohtml rename to views/routes/contents/edit/body.gohtml index 371afe7..c20d91a 100644 --- a/views/routes/almanach/contents/edit/body.gohtml +++ b/views/routes/contents/edit/body.gohtml @@ -40,7 +40,7 @@
{{- if $model.result.PrevByID -}}
- +
@@ -50,7 +50,7 @@
{{- if $model.result.NextByID -}}
- +
@@ -71,7 +71,7 @@
{{ $model.result.PrevByTitle.PreferredTitle }}
@@ -88,7 +88,7 @@
{{ $model.result.NextByTitle.PreferredTitle }}
diff --git a/views/routes/almanach/contents/edit/head.gohtml b/views/routes/contents/edit/head.gohtml similarity index 100% rename from views/routes/almanach/contents/edit/head.gohtml rename to views/routes/contents/edit/head.gohtml diff --git a/views/routes/almanach/contents/edit_item/body.gohtml b/views/routes/contents/edit_item/body.gohtml similarity index 97% rename from views/routes/almanach/contents/edit_item/body.gohtml rename to views/routes/contents/edit_item/body.gohtml index 876bf1f..a9995bd 100644 --- a/views/routes/almanach/contents/edit_item/body.gohtml +++ b/views/routes/contents/edit_item/body.gohtml @@ -15,7 +15,7 @@ Almanach {{- end -}} - + Beiträge
@@ -118,7 +118,7 @@ {{- end -}}
@@ -266,7 +266,7 @@ {{- end -}}

- + Liste diff --git a/views/routes/almanach/contents/edit_item/head.gohtml b/views/routes/contents/edit_item/head.gohtml similarity index 100% rename from views/routes/almanach/contents/edit_item/head.gohtml rename to views/routes/contents/edit_item/head.gohtml diff --git a/views/routes/almanach/contents/images_panel/body.gohtml b/views/routes/contents/images_panel/body.gohtml similarity index 100% rename from views/routes/almanach/contents/images_panel/body.gohtml rename to views/routes/contents/images_panel/body.gohtml diff --git a/views/routes/almanach/contents/list/body.gohtml b/views/routes/contents/list/body.gohtml similarity index 100% rename from views/routes/almanach/contents/list/body.gohtml rename to views/routes/contents/list/body.gohtml