mirror of
https://github.com/Theodor-Springmann-Stiftung/lenz-web.git
synced 2025-10-29 01:05:32 +00:00
Hand, Some other changes
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package functions
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
xmlparsing "github.com/Theodor-Springmann-Stiftung/lenz-web/xml"
|
||||
"github.com/Theodor-Springmann-Stiftung/lenz-web/xmlmodels"
|
||||
)
|
||||
|
||||
type outType int
|
||||
@@ -99,7 +101,8 @@ func (s *LenzParseState) String() string {
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
func ParseGeneric(s string) string {
|
||||
func Parse(lib *xmlmodels.Library) func(s string) string {
|
||||
return func(s string) string {
|
||||
if len(s) == 0 {
|
||||
return ""
|
||||
}
|
||||
@@ -122,6 +125,91 @@ func ParseGeneric(s string) string {
|
||||
|
||||
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)
|
||||
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,
|
||||
@@ -152,4 +240,5 @@ func ParseGeneric(s string) string {
|
||||
}
|
||||
|
||||
return ps.String()
|
||||
}
|
||||
}
|
||||
|
||||
2
lenz.go
2
lenz.go
@@ -53,7 +53,7 @@ func main() {
|
||||
|
||||
engine := templating.New(&views.LayoutFS, &views.RoutesFS)
|
||||
engine.AddFuncs(lib.FuncMap())
|
||||
engine.AddFunc("ParseGeneric", functions.ParseGeneric)
|
||||
engine.AddFunc("ParseGeneric", functions.Parse(lib))
|
||||
storage := memory.New(memory.Config{
|
||||
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">
|
||||
{{- Safe (ParseGeneric .text.Content) -}}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{{ $model := . }}
|
||||
|
||||
|
||||
<div class="flex flex-row">
|
||||
<div class="flex flex-row grow">
|
||||
<div class="mr-4 text-6xl">{{ $model.Letter }}</div>
|
||||
<div class="pt-0.5">
|
||||
<div>{{ $model.Earliest.Text -}}</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{{- $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 -}}
|
||||
</a>
|
||||
{{- end -}}
|
||||
|
||||
@@ -68,13 +68,12 @@
|
||||
}
|
||||
|
||||
.stdlink {
|
||||
@apply underline decoration-dotted;
|
||||
@apply underline decoration-dotted hover:decoration-solid;
|
||||
}
|
||||
|
||||
nav a[aria-current="page"] {
|
||||
@apply font-bold text-red-500;
|
||||
}
|
||||
|
||||
.text {
|
||||
@apply font-serif max-w-[80ch] relative;
|
||||
}
|
||||
@@ -109,6 +108,34 @@
|
||||
@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 {
|
||||
@apply hidden;
|
||||
}
|
||||
@@ -176,7 +203,23 @@
|
||||
top: 55%;
|
||||
}
|
||||
|
||||
.text .note {
|
||||
@apply w-full bg-slate-100 italic;
|
||||
.text .note,
|
||||
.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