mirror of
https://github.com/Theodor-Springmann-Stiftung/lenz-web.git
synced 2025-10-29 09:15:33 +00:00
Hand, Some other changes
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
package functions
|
package functions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
xmlparsing "github.com/Theodor-Springmann-Stiftung/lenz-web/xml"
|
xmlparsing "github.com/Theodor-Springmann-Stiftung/lenz-web/xml"
|
||||||
|
"github.com/Theodor-Springmann-Stiftung/lenz-web/xmlmodels"
|
||||||
)
|
)
|
||||||
|
|
||||||
type outType int
|
type outType int
|
||||||
@@ -99,57 +101,144 @@ func (s *LenzParseState) String() string {
|
|||||||
return builder.String()
|
return builder.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseGeneric(s string) string {
|
func Parse(lib *xmlmodels.Library) func(s string) string {
|
||||||
if len(s) == 0 {
|
return func(s string) string {
|
||||||
return ""
|
if len(s) == 0 {
|
||||||
}
|
return ""
|
||||||
|
|
||||||
ps := LenzParseState{CloseElement: true}
|
|
||||||
|
|
||||||
for elem, err := range xmlparsing.Iterate(s, ps) {
|
|
||||||
if err != nil {
|
|
||||||
return err.Error()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if elem.Token.Type < 3 {
|
ps := LenzParseState{CloseElement: true}
|
||||||
if !ps.CloseElement && elem.Token.Type == xmlparsing.EndElement {
|
|
||||||
ps.CloseElement = true
|
for elem, err := range xmlparsing.Iterate(s, ps) {
|
||||||
continue
|
if err != nil {
|
||||||
} else if elem.Token.Type == xmlparsing.EndElement {
|
return err.Error()
|
||||||
ps.Out = append(ps.Out, Default(elem.Token))
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultToken := Default(elem.Token)
|
if elem.Token.Type < 3 {
|
||||||
switch elem.Token.Name {
|
if !ps.CloseElement && elem.Token.Type == xmlparsing.EndElement {
|
||||||
case "line":
|
ps.CloseElement = true
|
||||||
nt := outToken{
|
continue
|
||||||
Type: EmptyElement,
|
} else if elem.Token.Type == xmlparsing.EndElement {
|
||||||
Name: "br",
|
ps.Out = append(ps.Out, Default(elem.Token))
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
if val := elem.Token.Attributes["type"]; val != "empty" {
|
|
||||||
|
defaultToken := Default(elem.Token)
|
||||||
|
switch elem.Token.Name {
|
||||||
|
case "sidenote":
|
||||||
|
nt := outToken{
|
||||||
|
Type: Element,
|
||||||
|
Name: "div",
|
||||||
|
Classes: []string{"sidenote"},
|
||||||
|
}
|
||||||
ps.Out = append(ps.Out, nt)
|
ps.Out = append(ps.Out, nt)
|
||||||
ps.LC += 1
|
if elem.Token.Attributes["annotation"] != "" {
|
||||||
|
note := outToken{
|
||||||
|
Type: Element,
|
||||||
|
Name: "div",
|
||||||
|
Classes: []string{"sidenote-note"},
|
||||||
|
}
|
||||||
|
notecontent := outToken{
|
||||||
|
Type: Text,
|
||||||
|
Value: elem.Token.Attributes["annotation"],
|
||||||
|
}
|
||||||
|
noteend := outToken{
|
||||||
|
Type: EndElement,
|
||||||
|
Name: "div",
|
||||||
|
}
|
||||||
|
ps.Out = append(ps.Out, note, notecontent, noteend)
|
||||||
|
}
|
||||||
|
if elem.Token.Attributes["page"] != "" {
|
||||||
|
note := outToken{
|
||||||
|
Type: Element,
|
||||||
|
Name: "div",
|
||||||
|
Classes: []string{"sidenote-page"},
|
||||||
|
}
|
||||||
|
notecontent := outToken{
|
||||||
|
Type: Text,
|
||||||
|
Value: elem.Token.Attributes["page"],
|
||||||
|
}
|
||||||
|
noteend := outToken{
|
||||||
|
Type: EndElement,
|
||||||
|
Name: "div",
|
||||||
|
}
|
||||||
|
ps.Out = append(ps.Out, note, notecontent, noteend)
|
||||||
|
}
|
||||||
|
if elem.Token.Attributes["pos"] != "" {
|
||||||
|
note := outToken{
|
||||||
|
Type: Element,
|
||||||
|
Name: "div",
|
||||||
|
Classes: []string{"sidenote-pos"},
|
||||||
|
}
|
||||||
|
notecontent := outToken{
|
||||||
|
Type: Text,
|
||||||
|
Value: elem.Token.Attributes["pos"],
|
||||||
|
}
|
||||||
|
noteend := outToken{
|
||||||
|
Type: EndElement,
|
||||||
|
Name: "div",
|
||||||
|
}
|
||||||
|
ps.Out = append(ps.Out, note, notecontent, noteend)
|
||||||
|
}
|
||||||
|
case "hand":
|
||||||
|
nt := outToken{
|
||||||
|
Type: Element,
|
||||||
|
Name: "div",
|
||||||
|
Classes: []string{"hand"},
|
||||||
|
}
|
||||||
|
ps.Out = append(ps.Out, nt)
|
||||||
|
id := elem.Token.Attributes["ref"]
|
||||||
|
idno, err := strconv.Atoi(id)
|
||||||
|
var person *xmlmodels.PersonDef
|
||||||
|
if err == nil {
|
||||||
|
person = lib.Persons.Item(idno)
|
||||||
|
}
|
||||||
|
handtok := outToken{
|
||||||
|
Type: Element,
|
||||||
|
Name: "div",
|
||||||
|
Classes: []string{"hand-person"},
|
||||||
|
}
|
||||||
|
defhand := outToken{
|
||||||
|
Type: Text,
|
||||||
|
Value: "N/A",
|
||||||
|
}
|
||||||
|
if person != nil {
|
||||||
|
defhand.Value = person.Name
|
||||||
|
}
|
||||||
|
handend := outToken{
|
||||||
|
Type: EndElement,
|
||||||
|
Name: "div",
|
||||||
|
}
|
||||||
|
ps.Out = append(ps.Out, handtok, defhand, handend)
|
||||||
|
case "line":
|
||||||
|
nt := outToken{
|
||||||
|
Type: EmptyElement,
|
||||||
|
Name: "br",
|
||||||
|
}
|
||||||
|
if val := elem.Token.Attributes["type"]; val != "empty" {
|
||||||
|
ps.Out = append(ps.Out, nt)
|
||||||
|
ps.LC += 1
|
||||||
|
ps.Out = append(ps.Out, defaultToken)
|
||||||
|
} else {
|
||||||
|
nt.Classes = []string{"empty"}
|
||||||
|
ps.Out = append(ps.Out, nt)
|
||||||
|
ps.CloseElement = false
|
||||||
|
}
|
||||||
|
case "page":
|
||||||
|
ps.LC = 0
|
||||||
|
ps.PC = elem.Token.Attributes["index"]
|
||||||
ps.Out = append(ps.Out, defaultToken)
|
ps.Out = append(ps.Out, defaultToken)
|
||||||
} else {
|
nt := outToken{
|
||||||
nt.Classes = []string{"empty"}
|
Type: Text,
|
||||||
|
Value: "[" + ps.PC + "]",
|
||||||
|
}
|
||||||
ps.Out = append(ps.Out, nt)
|
ps.Out = append(ps.Out, nt)
|
||||||
ps.CloseElement = false
|
default:
|
||||||
|
ps.Out = append(ps.Out, defaultToken)
|
||||||
}
|
}
|
||||||
case "page":
|
|
||||||
ps.LC = 0
|
|
||||||
ps.PC = elem.Token.Attributes["index"]
|
|
||||||
ps.Out = append(ps.Out, defaultToken)
|
|
||||||
nt := outToken{
|
|
||||||
Type: Text,
|
|
||||||
Value: "[" + ps.PC + "]",
|
|
||||||
}
|
|
||||||
ps.Out = append(ps.Out, nt)
|
|
||||||
default:
|
|
||||||
ps.Out = append(ps.Out, defaultToken)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ps.String()
|
return ps.String()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
lenz.go
2
lenz.go
@@ -53,7 +53,7 @@ func main() {
|
|||||||
|
|
||||||
engine := templating.New(&views.LayoutFS, &views.RoutesFS)
|
engine := templating.New(&views.LayoutFS, &views.RoutesFS)
|
||||||
engine.AddFuncs(lib.FuncMap())
|
engine.AddFuncs(lib.FuncMap())
|
||||||
engine.AddFunc("ParseGeneric", functions.ParseGeneric)
|
engine.AddFunc("ParseGeneric", functions.Parse(lib))
|
||||||
storage := memory.New(memory.Config{
|
storage := memory.New(memory.Config{
|
||||||
GCInterval: 24 * time.Hour,
|
GCInterval: 24 * time.Hour,
|
||||||
})
|
})
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,12 +1,21 @@
|
|||||||
{{- template "_letterhead" .meta -}}
|
<div class="flex flex-row w-full border-b pb-2 mb-3">
|
||||||
|
{{- template "_letterhead" .meta -}}
|
||||||
|
|
||||||
{{ if .prev }}
|
|
||||||
<a href="/brief/{{ .prev.Letter }}" class="stdlink">Vorheriger</a>
|
|
||||||
{{ end }}
|
|
||||||
{{ if .next }}
|
|
||||||
<a href="/brief/{{ .next.Letter }}" class="stdlink">Nächster</a>
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
|
<div class="self-end justify-self-end grow-0 ">
|
||||||
|
{{ if .prev }}
|
||||||
|
<a href="/brief/{{ .prev.Letter }}" class="stdlink"
|
||||||
|
><i class="ri-arrow-left-long-line"></i
|
||||||
|
></a>
|
||||||
|
{{ end }}
|
||||||
|
<span class="mx-1 font-variant-small-caps">LKB</span>
|
||||||
|
{{ if .next }}
|
||||||
|
<a href="/brief/{{ .next.Letter }}" class="stdlink"
|
||||||
|
><i class="ri-arrow-right-long-line"></i
|
||||||
|
></a>
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="text">
|
<div class="text">
|
||||||
{{- Safe (ParseGeneric .text.Content) -}}
|
{{- Safe (ParseGeneric .text.Content) -}}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{{ $model := . }}
|
{{ $model := . }}
|
||||||
|
|
||||||
|
|
||||||
<div class="flex flex-row">
|
<div class="flex flex-row grow">
|
||||||
<div class="mr-4 text-6xl">{{ $model.Letter }}</div>
|
<div class="mr-4 text-6xl">{{ $model.Letter }}</div>
|
||||||
<div class="pt-0.5">
|
<div class="pt-0.5">
|
||||||
<div>{{ $model.Earliest.Text -}}</div>
|
<div>{{ $model.Earliest.Text -}}</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{{- $letters := . }}
|
{{- $letters := . }}
|
||||||
|
|
||||||
{{ range $l := $letters -}}
|
{{ range $l := $letters -}}
|
||||||
<a class="block mb-2" href="/brief/{{ $l.Letter }}">
|
<a class="block mb-4" href="/brief/{{ $l.Letter }}">
|
||||||
{{- template "_letterhead" $l -}}
|
{{- template "_letterhead" $l -}}
|
||||||
</a>
|
</a>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|||||||
@@ -68,13 +68,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.stdlink {
|
.stdlink {
|
||||||
@apply underline decoration-dotted;
|
@apply underline decoration-dotted hover:decoration-solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
nav a[aria-current="page"] {
|
nav a[aria-current="page"] {
|
||||||
@apply font-bold text-red-500;
|
@apply font-bold text-red-500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text {
|
.text {
|
||||||
@apply font-serif max-w-[80ch] relative;
|
@apply font-serif max-w-[80ch] relative;
|
||||||
}
|
}
|
||||||
@@ -109,6 +108,34 @@
|
|||||||
@apply inline-block w-4;
|
@apply inline-block w-4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.text .line.tab-2 {
|
||||||
|
@apply inline-block w-8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text .line.tab-3 {
|
||||||
|
@apply inline-block w-12;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text .line.tab-4 {
|
||||||
|
@apply inline-block w-16;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text .line.tab-5 {
|
||||||
|
@apply inline-block w-20;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text .line.tab-6 {
|
||||||
|
@apply inline-block w-24;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text .line.tab-7 {
|
||||||
|
@apply inline-block w-28;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text .line.tab-8 {
|
||||||
|
@apply inline-block w-32;
|
||||||
|
}
|
||||||
|
|
||||||
.text br.index-1 {
|
.text br.index-1 {
|
||||||
@apply hidden;
|
@apply hidden;
|
||||||
}
|
}
|
||||||
@@ -176,7 +203,23 @@
|
|||||||
top: 55%;
|
top: 55%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text .note {
|
.text .note,
|
||||||
@apply w-full bg-slate-100 italic;
|
.text .hand-person,
|
||||||
|
.text .sidenote-note,
|
||||||
|
.text .sidenote-page,
|
||||||
|
.text .sidenote-pos {
|
||||||
|
@apply inline px-2 mr-2 w-full bg-gray-100 font-bold text-gray-700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text .sidenote-page::before {
|
||||||
|
content: "S. ";
|
||||||
|
}
|
||||||
|
|
||||||
|
.text .sidenote-pos::before {
|
||||||
|
content: "Pos: ";
|
||||||
|
}
|
||||||
|
|
||||||
|
.text .hand {
|
||||||
|
@apply inline text-blue-950;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user