diff --git a/views/routes/ausgabe/components/_inhaltsverzeichnis.gohtml b/views/routes/ausgabe/components/_inhaltsverzeichnis.gohtml index 05fc689..e8d8fa3 100644 --- a/views/routes/ausgabe/components/_inhaltsverzeichnis.gohtml +++ b/views/routes/ausgabe/components/_inhaltsverzeichnis.gohtml @@ -73,35 +73,16 @@ {{ end }}"> {{ add $index 1 }} - - {{- $issueKey := printf "%d-%d" $issue.When.Year $issue.Nr -}} - {{- $issueData := GetIssue $issueKey -}} - {{- if $issueData -}} - {{ $issueData.Datum.When.Day }}.{{ $issueData.Datum.When.Month }}.{{ $issueData.Datum.When.Year }} - {{- else -}} - {{ $issue.When.Year }} Nr. - {{ $issue.Nr }} - {{- end -}} - {{- if $issue.Von }} - S. - {{ $issue.Von }} - {{- end -}} - + + {{ template "_citation" $issue }} + {{ end }} @@ -210,35 +191,16 @@ {{ end }}"> {{ add $index 1 }} - - {{- $issueKey := printf "%d-%d" $issue.When.Year $issue.Nr -}} - {{- $issueData := GetIssue $issueKey -}} - {{- if $issueData -}} - {{ $issueData.Datum.When.Day }}.{{ $issueData.Datum.When.Month }}.{{ $issueData.Datum.When.Year }} - {{- else -}} - {{ $issue.When.Year }} Nr. - {{ $issue.Nr }} - {{- end -}} - {{- if $issue.Von }} - S. - {{ $issue.Von }} - {{- end -}} - + + {{ template "_citation" $issue }} + {{ end }} diff --git a/views/routes/components/_akteur.gohtml b/views/routes/components/_akteur.gohtml index 8f9b210..f86f641 100644 --- a/views/routes/components/_akteur.gohtml +++ b/views/routes/components/_akteur.gohtml @@ -67,9 +67,9 @@
{{ range $_, $p := $workPieces }} {{ range $_, $issue := $p.Item.IssueRefs }} - - {{ $issue.Nr }}/{{ $issue.When }}{{ if $issue.Von }} [S. {{ $issue.Von }}{{ if $issue.Bis }}-{{ $issue.Bis }}{{ end }}]{{ end }} - + + {{ template "_citation" $issue }} + {{ end }} {{ end }}
@@ -87,9 +87,9 @@
{{ range $_, $p := $pieces }} {{ range $_, $issue := $p.Item.IssueRefs }} - - {{ $issue.Nr }}/{{ $issue.When }}{{ if $issue.Von }} [S. {{ $issue.Von }}{{ if $issue.Bis }}-{{ $issue.Bis }}{{ end }}]{{ end }} - + + {{ template "_citation" $issue }} + {{ end }} {{ end }}
diff --git a/views/routes/components/_citation.gohtml b/views/routes/components/_citation.gohtml new file mode 100644 index 0000000..74d0338 --- /dev/null +++ b/views/routes/components/_citation.gohtml @@ -0,0 +1,68 @@ +{{- /* + Global citation component for resolving IssueRef elements + Usage: {{ template "_citation" $issueRef }} + + Input: xmlmodels.IssueRef with fields: + - .Nr (int): Issue number + - .Von (int): Starting page + - .Bis (int): Ending page (optional) + - .Beilage (int): Beilage number (optional) + - .When (DateAttributes): Date information + + Outputs: citation text + link with minimal formatting + Automatically detects current page and styles accordingly +*/ -}} + +{{- $issue := . -}} +{{- $issueKey := printf "%d-%d" $issue.When.Year $issue.Nr -}} +{{- $issueData := GetIssue $issueKey -}} +{{- $url := printf "/%s/%d" $issue.When $issue.Nr -}} + +{{- if $issueData -}} +{{ $issueData.Datum.When.Day }}.{{ $issueData.Datum.When.Month }}.{{ $issueData.Datum.When.Year }} +{{- else -}} +{{ $issue.When.Year }} Nr. {{ $issue.Nr }} +{{- end -}} +{{- if $issue.Von }} S. {{ $issue.Von }}{{- if and $issue.Bis (ne $issue.Von $issue.Bis) -}} +-{{ $issue.Bis }} +{{- end -}} +{{- end -}} + + + \ No newline at end of file diff --git a/views/routes/search/body.gohtml b/views/routes/search/body.gohtml index b19e8e4..c18fe1b 100644 --- a/views/routes/search/body.gohtml +++ b/views/routes/search/body.gohtml @@ -105,7 +105,7 @@ {{ range $_, $p := $pieces }} {{- range $_, $i := $p.Item.IssueRefs -}}
- {{ $i.Nr }}/{{ $i.When }} + {{ template "_citation" $i }}
{{- end -}} {{ end }}