From ff310265e4d7bf1b714f5f0372bee580b01ef504 Mon Sep 17 00:00:00 2001 From: Simon Martens Date: Thu, 16 Jan 2025 16:19:19 +0100 Subject: [PATCH] More CSS & sorting of T array by keys --- functions/embedding.go | 37 +++++---- providers/xmlprovider/xmlitemarray.go | 76 +++++++++++++++++++ providers/xmlprovider/xmlprovider.go | 2 + templating/engine.go | 10 +-- views/assets/style.css | 2 +- views/routes/body.gohtml | 6 +- views/routes/components/_akteur.gohtml | 13 ++++ .../components/_inhaltsverzeichnis.gohtml | 13 ++-- .../_inhaltsverzeichnis_eintrag.gohtml | 48 +++++++++--- xmlmodels/pieces.go | 23 ++++++ 10 files changed, 190 insertions(+), 40 deletions(-) create mode 100644 providers/xmlprovider/xmlitemarray.go diff --git a/functions/embedding.go b/functions/embedding.go index d84f98a..c866f58 100644 --- a/functions/embedding.go +++ b/functions/embedding.go @@ -9,15 +9,25 @@ import ( "sync" ) -var embed_cache sync.Map +type Embedder struct { + embed_cache sync.Map + fs fs.FS +} + +func NewEmbedder(fs fs.FS) *Embedder { + return &Embedder{ + fs: fs, + embed_cache: sync.Map{}, + } +} // INFO: We initialize the cache in both functions, which is only valid if both of these get // called in the same context, eg. when creating a template engine. -func EmbedSafe(fs fs.FS) func(string) template.HTML { +func (e *Embedder) EmbedSafe() func(string) template.HTML { return func(path string) template.HTML { path = strings.TrimSpace(path) path = filepath.Clean(path) - val, err := getFileData(fs, path) + val, err := e.getFileData(path) if err != nil { return template.HTML("") } @@ -26,11 +36,11 @@ func EmbedSafe(fs fs.FS) func(string) template.HTML { } } -func Embed(fs fs.FS) func(string) string { +func (e *Embedder) Embed() func(string) string { return func(path string) string { path = strings.TrimSpace(path) path = filepath.Clean(path) - val, err := getFileData(fs, path) + val, err := e.getFileData(path) if err != nil { return "" } @@ -39,16 +49,12 @@ func Embed(fs fs.FS) func(string) string { } } -func ClearEmbedCache() { - embed_cache.Clear() -} - -func getFileData(fs fs.FS, path string) ([]byte, error) { - if val, ok := embed_cache.Load(path); ok { +func (e *Embedder) getFileData(path string) ([]byte, error) { + if val, ok := e.embed_cache.Load(path); ok { return val.([]byte), nil } - f, err := fs.Open(path) + f, err := e.fs.Open(path) if err != nil { return nil, err } @@ -59,12 +65,11 @@ func getFileData(fs fs.FS, path string) ([]byte, error) { return nil, err } - embed_cache.Store(path, data) + e.embed_cache.Store(path, data) return data, nil } -func EmbedXSLT(fs fs.FS) func(string) template.HTML { - embed_cache.Clear() +func (e *Embedder) EmbedXSLT() func(string) template.HTML { return func(path string) template.HTML { path = strings.TrimSpace(path) path = filepath.Clean(path) @@ -76,7 +81,7 @@ func EmbedXSLT(fs fs.FS) func(string) template.HTML { return template.HTML("[ERROR: " + "file is not an XSLT file" + "]") } - val, err := getFileData(fs, path) + val, err := e.getFileData(path) if err != nil { return template.HTML("[ERROR: " + err.Error() + "]") } diff --git a/providers/xmlprovider/xmlitemarray.go b/providers/xmlprovider/xmlitemarray.go new file mode 100644 index 0000000..f15bd08 --- /dev/null +++ b/providers/xmlprovider/xmlitemarray.go @@ -0,0 +1,76 @@ +package xmlprovider + +import ( + "strconv" + "strings" +) + +func Sort[T XMLItem](i, j T) int { + + keys_a := i.Keys() + keys_b := j.Keys() + + if len(keys_a) == 0 && len(keys_b) == 0 { + return 0 + } + + if len(keys_a) == 0 && len(keys_b) > 0 { + return -1 + } + + if len(keys_a) > 0 && len(keys_b) == 0 { + return 1 + } + + sort_a := strings.Split(keys_a[0], "-") + sort_b := strings.Split(keys_b[0], "-") + + for i, item := range sort_a { + if i >= len(sort_b) { + return 1 + } + + // INFO: this is a bit lazy since + // - we are comparing bit values not unicode code points + // - the comparison is case sensitive + int_a, err := strconv.Atoi(item) + if err != nil { + if item < sort_b[i] { + return -1 + } + + if item > sort_b[i] { + return 1 + } + + continue + } + + int_b, err := strconv.Atoi(sort_b[i]) + if err != nil { + if item < sort_b[i] { + return -1 + } + + if item > sort_b[i] { + return 1 + } + + continue + } + + if int_a < int_b { + return -1 + } + + if int_a > int_b { + return 1 + } + } + + if len(sort_b) > len(sort_a) { + return -1 + } + + return 0 +} diff --git a/providers/xmlprovider/xmlprovider.go b/providers/xmlprovider/xmlprovider.go index 5ea2029..878b608 100644 --- a/providers/xmlprovider/xmlprovider.go +++ b/providers/xmlprovider/xmlprovider.go @@ -125,6 +125,8 @@ func (p *XMLProvider[T]) Cleanup(latest ParseMeta) { p.Array = append(p.Array, *item) p.addResolvable(*item) } + + slices.SortFunc(p.Array, Sort) } func (p *XMLProvider[T]) addResolvable(item T) { diff --git a/templating/engine.go b/templating/engine.go index 14cf273..208b393 100644 --- a/templating/engine.go +++ b/templating/engine.go @@ -57,12 +57,10 @@ func (e *Engine) funcs() error { e.AddFunc("Safe", functions.Safe) // Embedding of file contents - functions.ClearEmbedCache() - e.AddFunc("EmbedSafe", functions.EmbedSafe(views.StaticFS)) - e.AddFunc("Embed", functions.Embed(views.StaticFS)) - - // Embedding of XSLT files - e.AddFunc("EmbedXSLT", functions.EmbedXSLT(views.StaticFS)) + embedder := functions.NewEmbedder(views.StaticFS) + e.AddFunc("EmbedSafe", embedder.EmbedSafe()) + e.AddFunc("Embed", embedder.Embed()) + e.AddFunc("EmbedXSLT", embedder.EmbedXSLT()) return nil } diff --git a/views/assets/style.css b/views/assets/style.css index e8faecc..313d583 100644 --- a/views/assets/style.css +++ b/views/assets/style.css @@ -1 +1 @@ -*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:"Source Sans 3",Merriweather Sans,ui-sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width: 640px){.container{max-width:640px}}@media (min-width: 768px){.container{max-width:768px}}@media (min-width: 1024px){.container{max-width:1024px}}@media (min-width: 1280px){.container{max-width:1280px}}@media (min-width: 1536px){.container{max-width:1536px}}html{font-size:15.5px}body{--tw-bg-opacity: 1;background-color:rgb(248 250 252 / var(--tw-bg-opacity, 1))}h1,h2,h3,h4{font-family:Merriweather,ui-serif;font-weight:700}a{-webkit-hyphens:none;hyphens:none;--tw-text-opacity: 1;color:rgb(51 65 85 / var(--tw-text-opacity, 1));text-decoration-line:underline;text-decoration-style:dotted}a:hover{--tw-text-opacity: 1;color:rgb(15 23 42 / var(--tw-text-opacity, 1));text-decoration-style:solid}ul{margin-top:.5rem;margin-bottom:.5rem}li{margin-left:3.5rem;list-style-type:disc}a[aria-current=page]{--tw-text-opacity: 1 !important;color:rgb(239 68 68 / var(--tw-text-opacity, 1))!important}.font-variant-small-caps{font-variant-caps:small-caps}main{flex-shrink:0;flex-grow:1}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.absolute{position:absolute}.relative{position:relative}.bottom-0\.5{bottom:.125rem}.col-span-1{grid-column:span 1 / span 1}.col-span-10{grid-column:span 10 / span 10}.\!m-0{margin:0!important}.mx-auto{margin-left:auto;margin-right:auto}.ml-2{margin-left:.5rem}.mt-12{margin-top:3rem}.mt-2{margin-top:.5rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.table{display:table}.grid{display:grid}.hidden{display:none}.h-full{height:100%}.min-h-screen{min-height:100vh}.w-6\/12{width:50%}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.max-w-screen-2xl{max-width:1536px}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.grid-cols-11{grid-template-columns:repeat(11,minmax(0,1fr))}.grid-cols-subgrid{grid-template-columns:subgrid}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-end{align-items:flex-end}.justify-center{justify-content:center}.gap-x-2{-moz-column-gap:.5rem;column-gap:.5rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-y-2{row-gap:.5rem}.gap-y-4{row-gap:1rem}.border{border-width:1px}.bg-slate-100{--tw-bg-opacity: 1;background-color:rgb(241 245 249 / var(--tw-bg-opacity, 1))}.bg-slate-200{--tw-bg-opacity: 1;background-color:rgb(226 232 240 / var(--tw-bg-opacity, 1))}.bg-slate-50{--tw-bg-opacity: 1;background-color:rgb(248 250 252 / var(--tw-bg-opacity, 1))}.\!p-0{padding:0!important}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.pb-4{padding-bottom:1rem}.pr-1{padding-right:.25rem}.pt-8{padding-top:2rem}.text-right{text-align:right}.text-2xl{font-size:1.5rem;line-height:2rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.leading-none{line-height:1}.\!no-underline{text-decoration-line:none!important}.no-underline{text-decoration-line:none}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.\[a-zA-Z\:\\-\\\.\]{a-z-a--z:\-\.} +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:"Source Sans 3",Merriweather Sans,ui-sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width: 640px){.container{max-width:640px}}@media (min-width: 768px){.container{max-width:768px}}@media (min-width: 1024px){.container{max-width:1024px}}@media (min-width: 1280px){.container{max-width:1280px}}@media (min-width: 1536px){.container{max-width:1536px}}html{font-size:15.5px}body{--tw-bg-opacity: 1;background-color:rgb(248 250 252 / var(--tw-bg-opacity, 1))}h1,h2,h3,h4{font-family:Merriweather,ui-serif;font-weight:700}a{-webkit-hyphens:none;hyphens:none;--tw-text-opacity: 1;color:rgb(51 65 85 / var(--tw-text-opacity, 1));text-decoration-line:underline;text-decoration-style:dotted}a:hover{--tw-text-opacity: 1;color:rgb(15 23 42 / var(--tw-text-opacity, 1));text-decoration-style:solid}ul{margin-top:.5rem;margin-bottom:.5rem}li{margin-left:3.5rem;list-style-type:disc}a[aria-current=page]{--tw-text-opacity: 1 !important;color:rgb(239 68 68 / var(--tw-text-opacity, 1))!important}.font-variant-small-caps{font-variant-caps:small-caps}main{flex-shrink:0;flex-grow:1}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.collapse{visibility:collapse}.absolute{position:absolute}.relative{position:relative}.bottom-0\.5{bottom:.125rem}.col-span-1{grid-column:span 1 / span 1}.col-span-10{grid-column:span 10 / span 10}.\!m-0{margin:0!important}.mx-auto{margin-left:auto;margin-right:auto}.ml-0{margin-left:0}.ml-2{margin-left:.5rem}.mt-12{margin-top:3rem}.mt-2{margin-top:.5rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.table{display:table}.grid{display:grid}.hidden{display:none}.h-full{height:100%}.min-h-screen{min-height:100vh}.w-6\/12{width:50%}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.max-w-screen-2xl{max-width:1536px}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.list-disc{list-style-type:disc}.grid-cols-11{grid-template-columns:repeat(11,minmax(0,1fr))}.grid-cols-subgrid{grid-template-columns:subgrid}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-end{align-items:flex-end}.justify-center{justify-content:center}.gap-x-2{-moz-column-gap:.5rem;column-gap:.5rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-y-2{row-gap:.5rem}.gap-y-4{row-gap:1rem}.border{border-width:1px}.bg-slate-100{--tw-bg-opacity: 1;background-color:rgb(241 245 249 / var(--tw-bg-opacity, 1))}.bg-slate-200{--tw-bg-opacity: 1;background-color:rgb(226 232 240 / var(--tw-bg-opacity, 1))}.bg-slate-50{--tw-bg-opacity: 1;background-color:rgb(248 250 252 / var(--tw-bg-opacity, 1))}.\!p-0{padding:0!important}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.pb-4{padding-bottom:1rem}.pr-1{padding-right:.25rem}.pt-4{padding-top:1rem}.pt-8{padding-top:2rem}.text-right{text-align:right}.text-2xl{font-size:1.5rem;line-height:2rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.leading-none{line-height:1}.\!no-underline{text-decoration-line:none!important}.no-underline{text-decoration-line:none}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.\[a-zA-Z\:\\-\\\.\]{a-z-a--z:\-\.} diff --git a/views/routes/body.gohtml b/views/routes/body.gohtml index d1e34f0..9c03f0a 100644 --- a/views/routes/body.gohtml +++ b/views/routes/body.gohtml @@ -16,18 +16,20 @@
{{ range $index, $month := .model.Issues }} + +
- {{ $first := index $month 0 }}

{{ (MonthName $first.Datum.When.Month) }}

+
{{ range $issue := $month }}
{{ $date := $issue.Datum.When }} -
+
{{ $issue.Number.No }}
diff --git a/views/routes/components/_akteur.gohtml b/views/routes/components/_akteur.gohtml index abcefa0..689e1b3 100644 --- a/views/routes/components/_akteur.gohtml +++ b/views/routes/components/_akteur.gohtml @@ -58,6 +58,19 @@
{{ $url.Chardata }}
{{ end }} + + {{ $pieces := LookupPieces $w.Item }} + {{ if len $pieces }} +
+ {{ range $_, $p := $pieces }} + {{- range $_, $i := $p.Item.IssueRefs -}} + + {{- end -}} + {{ end }} +
+ {{ end }} {{ end }}
{{ end }} diff --git a/views/routes/issue/components/_inhaltsverzeichnis.gohtml b/views/routes/issue/components/_inhaltsverzeichnis.gohtml index e5dd5f1..a1b64ee 100644 --- a/views/routes/issue/components/_inhaltsverzeichnis.gohtml +++ b/views/routes/issue/components/_inhaltsverzeichnis.gohtml @@ -1,16 +1,15 @@ {{ $model := .model }} -
Inhalt
{{ range $page := $model.Pieces.Pages }} -
-
Seite {{ $page }}
- +
+
Seite {{ $page }}
+
    {{ range $piece := (index $model.Pieces.Items $page) }} +
  1. {{ template "_inhaltsverzeichnis_eintrag" $piece }} - {{ if gt (len $piece.IssueRefs) 1 }}
    @@ -33,9 +32,11 @@
{{ end }} - + {{ end }} + +
{{ end }}
diff --git a/views/routes/issue/components/_inhaltsverzeichnis_eintrag.gohtml b/views/routes/issue/components/_inhaltsverzeichnis_eintrag.gohtml index b14642e..9b5b34b 100644 --- a/views/routes/issue/components/_inhaltsverzeichnis_eintrag.gohtml +++ b/views/routes/issue/components/_inhaltsverzeichnis_eintrag.gohtml @@ -1,20 +1,50 @@ {{ $piece := . }} -Eintrag! + -{{ $authorset := false }} -
- {{ range $agentref := $piece.AgentRefs }} - {{ if (or (eq $agentref.Category "") (eq $agentref.Category "autor")) }} - {{ $agent := GetAgent $agentref.Ref }} - - {{- if gt (len $agent.Names) 0 -}} -
{{- index $agent.Names 0 -}}
+{{ if $piece.AgentRefs }} +
+ {{ range $agentref := $piece.AgentRefs }} + {{ if (or (eq $agentref.Category "") (eq $agentref.Category "autor")) }} + {{ $agent := GetAgent $agentref.Ref }} + {{- if gt (len $agent.Names) 0 -}} + + {{- index $agent.Names 0 -}} + + {{ end }} + {{ end }} + {{ end }} +
+{{ end }} + + + +
+ + {{ if $piece.CategoryRefs }} + {{ range $catref := $piece.CategoryRefs }} + {{ $category := GetCategory $catref.Ref }} + {{- if gt (len $category.Names) 0 -}} +
{{- index $category.Names 0 -}}
+ {{ end }} + {{ end }} + {{ end }} + + + + {{ if $piece.WorkRefs }} + {{ range $workref := $piece.WorkRefs }} + {{ $work := GetWork $workref.Ref }} + {{- if $work.PreferredTitle -}} +
{{- index $work.PreferredTitle -}}
+ {{- else if $work.Citation.Title -}} +
{{- index $work.Citation.Title -}}
{{ end }} {{ end }} {{ end }}
+ {{ range $annotation := $piece.AnnotationNote.Annotations }}
{{ $annotation.Inner.InnerXML }} diff --git a/xmlmodels/pieces.go b/xmlmodels/pieces.go index e7dc75d..f09a977 100644 --- a/xmlmodels/pieces.go +++ b/xmlmodels/pieces.go @@ -67,16 +67,30 @@ func (p Piece) ReferencesIssue(y, no int) (*IssueRef, bool) { return nil, false } +// INFO: we can't use a pointer reciever here, the interface won't allow it func (p Piece) References() xmlprovider.ResolvingMap[Piece] { refs := make(xmlprovider.ResolvingMap[Piece]) x := CategoryRef{} + for _, ref := range p.CategoryRefs { + if ref.Category != "" { + refs[x.Name()] = append(refs[x.Name()], xmlprovider.Resolved[Piece]{ + Item: &p, + Reference: ref.Category, + Cert: !ref.Unsicher, + Conjecture: false, + Comment: ref.Inner.InnerXML, + }) + } + } + for _, ref := range p.IssueRefs { if ref.When.Year == 0 || ref.Nr == 0 { continue } if ref.Category != "" { refs[x.Name()] = append(refs[x.Name()], xmlprovider.Resolved[Piece]{ + Item: &p, Reference: ref.Category, Cert: !ref.Unsicher, Conjecture: false, @@ -84,6 +98,7 @@ func (p Piece) References() xmlprovider.ResolvingMap[Piece] { }) } refs[ref.Name()] = append(refs[ref.Name()], xmlprovider.Resolved[Piece]{ + Item: &p, Reference: strconv.Itoa(ref.When.Year) + "-" + strconv.Itoa(ref.Nr), Category: ref.Category, Cert: !ref.Unsicher, @@ -96,6 +111,7 @@ func (p Piece) References() xmlprovider.ResolvingMap[Piece] { for _, ref := range p.PlaceRefs { if ref.Category != "" { refs[x.Name()] = append(refs[x.Name()], xmlprovider.Resolved[Piece]{ + Item: &p, Reference: ref.Category, Cert: !ref.Unsicher, Conjecture: false, @@ -103,6 +119,7 @@ func (p Piece) References() xmlprovider.ResolvingMap[Piece] { }) } refs[ref.Name()] = append(refs[ref.Name()], xmlprovider.Resolved[Piece]{ + Item: &p, Reference: ref.Ref, Category: ref.Category, Cert: !ref.Unsicher, @@ -115,6 +132,7 @@ func (p Piece) References() xmlprovider.ResolvingMap[Piece] { for _, ref := range p.AgentRefs { if ref.Category != "" { refs[x.Name()] = append(refs[x.Name()], xmlprovider.Resolved[Piece]{ + Item: &p, Reference: ref.Category, Cert: !ref.Unsicher, Conjecture: false, @@ -122,6 +140,7 @@ func (p Piece) References() xmlprovider.ResolvingMap[Piece] { }) } refs[ref.Name()] = append(refs[ref.Name()], xmlprovider.Resolved[Piece]{ + Item: &p, Reference: ref.Ref, Category: ref.Category, Cert: !ref.Unsicher, @@ -134,6 +153,7 @@ func (p Piece) References() xmlprovider.ResolvingMap[Piece] { for _, ref := range p.WorkRefs { if ref.Category != "" { refs[x.Name()] = append(refs[x.Name()], xmlprovider.Resolved[Piece]{ + Item: &p, Reference: ref.Category, Cert: !ref.Unsicher, Conjecture: false, @@ -141,6 +161,7 @@ func (p Piece) References() xmlprovider.ResolvingMap[Piece] { }) } refs[ref.Name()] = append(refs[ref.Name()], xmlprovider.Resolved[Piece]{ + Item: &p, Reference: ref.Ref, Category: ref.Category, Cert: !ref.Unsicher, @@ -152,6 +173,7 @@ func (p Piece) References() xmlprovider.ResolvingMap[Piece] { for _, ref := range p.PieceRefs { if ref.Category != "" { refs[x.Name()] = append(refs[x.Name()], xmlprovider.Resolved[Piece]{ + Item: &p, Reference: ref.Category, Cert: !ref.Unsicher, Conjecture: false, @@ -160,6 +182,7 @@ func (p Piece) References() xmlprovider.ResolvingMap[Piece] { }) } refs[ref.Name()] = append(refs[ref.Name()], xmlprovider.Resolved[Piece]{ + Item: &p, Reference: ref.Ref, Category: ref.Category, Cert: !ref.Unsicher,