Suche: HTMX + Webseite

This commit is contained in:
Simon Martens
2025-02-18 00:33:30 +01:00
parent fd2fa157b2
commit 7aac147686
18 changed files with 348 additions and 69 deletions

View File

@@ -21,10 +21,6 @@ type Agent struct {
AnnotationNote
}
func (a Agent) Name() string {
return "agent"
}
func (a Agent) String() string {
data, _ := json.MarshalIndent(a, "", " ")
return string(data)

View File

@@ -18,10 +18,6 @@ type Category struct {
AnnotationNote
}
func (c Category) Name() string {
return "category"
}
func (c Category) String() string {
data, _ := json.MarshalIndent(c, "", " ")
return string(data)

View File

@@ -33,10 +33,6 @@ type Additional struct {
Bis int `xml:"bis"`
}
func (i Issue) Name() string {
return "issue"
}
func (i Issue) Keys() []string {
res := make([]string, 0, 2)
res = append(res, i.Reference())
@@ -67,7 +63,7 @@ func (i Issue) Readable(_ *Library) map[string]interface{} {
"ID": i.ID,
"Number": i.Number.No,
"Year": i.Datum.When.Year,
"Date": i.Datum.When.String(),
"Date": strconv.Itoa(i.Datum.When.Day) + "." + strconv.Itoa(i.Datum.When.Month) + "." + strconv.Itoa(i.Datum.When.Year),
}
for k, v := range i.AnnotationNote.Readable() {

View File

@@ -11,7 +11,7 @@ import (
)
const (
PIECES_CATEGORY = "piece"
PIECE_TYPE = "piece"
)
type Piece struct {
@@ -29,10 +29,6 @@ type Piece struct {
AnnotationNote
}
func (p Piece) Name() string {
return "piece"
}
func (p Piece) String() string {
data, _ := json.MarshalIndent(p, "", " ")
return string(data)
@@ -79,7 +75,7 @@ func (p Piece) References() xmlprovider.ResolvingMap[Piece] {
for _, ref := range p.CategoryRefs {
if ref.Category != "" {
refs[x.Name()] = append(refs[x.Name()], xmlprovider.Resolved[Piece]{
refs[x.Type()] = append(refs[x.Type()], xmlprovider.Resolved[Piece]{
Item: &p,
Reference: ref.Category,
Cert: !ref.Unsicher,
@@ -94,7 +90,7 @@ func (p Piece) References() xmlprovider.ResolvingMap[Piece] {
continue
}
if ref.Category != "" {
refs[x.Name()] = append(refs[x.Name()], xmlprovider.Resolved[Piece]{
refs[x.Type()] = append(refs[x.Type()], xmlprovider.Resolved[Piece]{
Item: &p,
Reference: ref.Category,
Cert: !ref.Unsicher,
@@ -102,7 +98,7 @@ func (p Piece) References() xmlprovider.ResolvingMap[Piece] {
Comment: ref.Inner.InnerXML,
})
}
refs[ref.Name()] = append(refs[ref.Name()], xmlprovider.Resolved[Piece]{
refs[ref.Type()] = append(refs[ref.Type()], xmlprovider.Resolved[Piece]{
Item: &p,
Reference: strconv.Itoa(ref.When.Year) + "-" + strconv.Itoa(ref.Nr),
Category: ref.Category,
@@ -115,7 +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]{
refs[x.Type()] = append(refs[x.Type()], xmlprovider.Resolved[Piece]{
Item: &p,
Reference: ref.Category,
Cert: !ref.Unsicher,
@@ -123,7 +119,7 @@ func (p Piece) References() xmlprovider.ResolvingMap[Piece] {
Comment: ref.Inner.InnerXML,
})
}
refs[ref.Name()] = append(refs[ref.Name()], xmlprovider.Resolved[Piece]{
refs[ref.Type()] = append(refs[ref.Type()], xmlprovider.Resolved[Piece]{
Item: &p,
Reference: ref.Ref,
Category: ref.Category,
@@ -136,7 +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]{
refs[x.Type()] = append(refs[x.Type()], xmlprovider.Resolved[Piece]{
Item: &p,
Reference: ref.Category,
Cert: !ref.Unsicher,
@@ -144,7 +140,7 @@ func (p Piece) References() xmlprovider.ResolvingMap[Piece] {
Comment: ref.Inner.InnerXML,
})
}
refs[ref.Name()] = append(refs[ref.Name()], xmlprovider.Resolved[Piece]{
refs[ref.Type()] = append(refs[ref.Type()], xmlprovider.Resolved[Piece]{
Item: &p,
Reference: ref.Ref,
Category: ref.Category,
@@ -157,7 +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]{
refs[x.Type()] = append(refs[x.Type()], xmlprovider.Resolved[Piece]{
Item: &p,
Reference: ref.Category,
Cert: !ref.Unsicher,
@@ -165,7 +161,7 @@ func (p Piece) References() xmlprovider.ResolvingMap[Piece] {
Comment: ref.Inner.InnerXML,
})
}
refs[ref.Name()] = append(refs[ref.Name()], xmlprovider.Resolved[Piece]{
refs[ref.Type()] = append(refs[ref.Type()], xmlprovider.Resolved[Piece]{
Item: &p,
Reference: ref.Ref,
Category: ref.Category,
@@ -177,7 +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]{
refs[x.Type()] = append(refs[x.Type()], xmlprovider.Resolved[Piece]{
Item: &p,
Reference: ref.Category,
Cert: !ref.Unsicher,
@@ -186,7 +182,7 @@ func (p Piece) References() xmlprovider.ResolvingMap[Piece] {
MetaData: map[string]string{},
})
}
refs[ref.Name()] = append(refs[ref.Name()], xmlprovider.Resolved[Piece]{
refs[ref.Type()] = append(refs[ref.Type()], xmlprovider.Resolved[Piece]{
Item: &p,
Reference: ref.Ref,
Category: ref.Category,
@@ -261,5 +257,5 @@ func (p Piece) Readable(lib *Library) map[string]interface{} {
}
func (p Piece) Type() string {
return PIECES_CATEGORY
return PIECE_TYPE
}

View File

@@ -18,10 +18,6 @@ type Place struct {
AnnotationNote
}
func (p Place) Name() string {
return "place"
}
func (p Place) String() string {
data, _ := json.MarshalIndent(p, "", " ")
return string(data)

View File

@@ -10,9 +10,8 @@ type AgentRef struct {
Reference
}
func (ar AgentRef) Name() string {
var x Agent
return x.Name()
func (ar AgentRef) Type() string {
return AGENT_TYPE
}
func (ar AgentRef) Readable(lib *Library) map[string]interface{} {
@@ -49,7 +48,7 @@ func (ir IssueRef) Readable(lib *Library) map[string]interface{} {
issuekey := strconv.Itoa(ir.When.Year) + "-" + strconv.Itoa(ir.Nr)
issue := lib.Issues.Item(issuekey)
if issue != nil {
data["IssueDate"] = issue.Datum.When.String()
data["IssueDate"] = strconv.Itoa(issue.Datum.When.Day) + "." + strconv.Itoa(issue.Datum.When.Month) + "." + strconv.Itoa(issue.Datum.When.Year)
}
data["IssueNumber"] = ir.Nr
@@ -57,9 +56,8 @@ func (ir IssueRef) Readable(lib *Library) map[string]interface{} {
return data
}
func (ir IssueRef) Name() string {
var x Issue
return x.Name()
func (ir IssueRef) Type() string {
return ISSUE_TYPE
}
type PlaceRef struct {
@@ -80,9 +78,8 @@ func (pr *PlaceRef) Readable(lib *Library) map[string]interface{} {
return data
}
func (pr PlaceRef) Name() string {
var x Place
return x.Name()
func (pr PlaceRef) Type() string {
return PLACE_TYPE
}
type CategoryRef struct {
@@ -90,9 +87,8 @@ type CategoryRef struct {
Reference
}
func (cr CategoryRef) Name() string {
var x Category
return x.Name()
func (cr CategoryRef) Type() string {
return CATEGORY_TYPE
}
func (cr CategoryRef) Readable(lib *Library) map[string]interface{} {
@@ -134,9 +130,8 @@ func (wr WorkRef) Readable(lib *Library) map[string]interface{} {
return data
}
func (wr WorkRef) Name() string {
var x Work
return x.Name()
func (wr WorkRef) Type() string {
return WORK_TYPE
}
type PieceRef struct {
@@ -145,7 +140,6 @@ type PieceRef struct {
Reference
}
func (pr PieceRef) Name() string {
var x Piece
return x.Name()
func (pr PieceRef) Type() string {
return PIECE_TYPE
}

View File

@@ -8,7 +8,7 @@ import (
)
const (
WORKS_CATEGORY = "work"
WORK_TYPE = "work"
)
type Work struct {
@@ -21,10 +21,6 @@ type Work struct {
AnnotationNote
}
func (w Work) Name() string {
return "work"
}
type Citation struct {
XMLName xml.Name `xml:"zitation"`
Title string `xml:"title"`
@@ -37,7 +33,7 @@ func (w Work) References() xmlprovider.ResolvingMap[Work] {
refs := make(xmlprovider.ResolvingMap[Work])
for _, ref := range w.AgentRefs {
refs[ref.Name()] = append(refs[ref.Name()], xmlprovider.Resolved[Work]{
refs[ref.Type()] = append(refs[ref.Type()], xmlprovider.Resolved[Work]{
Item: &w, // Reference to the current Work item
Reference: ref.Ref, // Reference ID
Category: ref.Category, // Category of the reference
@@ -78,5 +74,5 @@ func (w Work) Readable(lib *Library) map[string]interface{} {
}
func (w Work) Type() string {
return WORKS_CATEGORY
return WORK_TYPE
}