bootstrap
This commit is contained in:
parent
821a1439a7
commit
153d46d830
|
@ -23,8 +23,8 @@ import (
|
||||||
|
|
||||||
var world *model.DfWorld
|
var world *model.DfWorld
|
||||||
|
|
||||||
//go:embed resources/frontend
|
//go:embed static
|
||||||
var frontend embed.FS
|
var static embed.FS
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
f := flag.String("f", "", "open a file")
|
f := flag.String("f", "", "open a file")
|
||||||
|
@ -108,6 +108,9 @@ func main() {
|
||||||
|
|
||||||
return r
|
return r
|
||||||
},
|
},
|
||||||
|
"html": func(value any) template.HTML {
|
||||||
|
return template.HTML(fmt.Sprint(value))
|
||||||
|
},
|
||||||
}
|
}
|
||||||
t := templates.New(functions)
|
t := templates.New(functions)
|
||||||
|
|
||||||
|
@ -167,7 +170,7 @@ func main() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spa := spaHandler{staticFS: frontend, staticPath: "resources/frontend", indexPath: "index.html"}
|
spa := spaHandler{staticFS: static, staticPath: "static", indexPath: "index.html"}
|
||||||
router.PathPrefix("/").Handler(spa)
|
router.PathPrefix("/").Handler(spa)
|
||||||
|
|
||||||
fmt.Println("Serving at :8080")
|
fmt.Println("Serving at :8080")
|
||||||
|
@ -209,7 +212,7 @@ func (h spaHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
// }
|
// }
|
||||||
// prepend the path with the path to the static directory
|
// prepend the path with the path to the static directory
|
||||||
path = h.staticPath + path
|
path = h.staticPath + path
|
||||||
fmt.Println(path)
|
fmt.Println(r.URL, "->", path)
|
||||||
|
|
||||||
_, err := h.staticFS.Open(path)
|
_, err := h.staticFS.Open(path)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
// Code generated by legendsbrowser; DO NOT EDIT.
|
|
||||||
package model
|
package model
|
||||||
|
|
||||||
func (x *HistoricalEventAddHfEntityHonor) Html() string {
|
func (x *HistoricalEventAddHfEntityHonor) Html() string {
|
||||||
|
@ -49,8 +48,20 @@ func (x *HistoricalEventCeremony) Html() string { return "UNKNWON HistoricalEven
|
||||||
func (x *HistoricalEventChangeHfBodyState) Html() string {
|
func (x *HistoricalEventChangeHfBodyState) Html() string {
|
||||||
return "UNKNWON HistoricalEventChangeHfBodyState"
|
return "UNKNWON HistoricalEventChangeHfBodyState"
|
||||||
}
|
}
|
||||||
func (x *HistoricalEventChangeHfJob) Html() string { return "UNKNWON HistoricalEventChangeHfJob" }
|
func (x *HistoricalEventChangeHfJob) Html() string { return "UNKNWON HistoricalEventChangeHfJob" }
|
||||||
func (x *HistoricalEventChangeHfState) Html() string { return "UNKNWON HistoricalEventChangeHfState" }
|
func (x *HistoricalEventChangeHfState) Html() string {
|
||||||
|
switch x.State {
|
||||||
|
case HistoricalEventChangeHfStateState_Settled:
|
||||||
|
switch x.Reason {
|
||||||
|
case HistoricalEventChangeHfStateReason_BeWithMaster:
|
||||||
|
return hf(x.Hfid) + " moved to study " + site(x.SiteId, "in") + " in order to be with the master"
|
||||||
|
default:
|
||||||
|
return hf(x.Hfid) + " settled " + site(x.SiteId, "in")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "UNKNWON HistoricalEventChangeHfState"
|
||||||
|
}
|
||||||
|
|
||||||
func (x *HistoricalEventChangedCreatureType) Html() string {
|
func (x *HistoricalEventChangedCreatureType) Html() string {
|
||||||
return "UNKNWON HistoricalEventChangedCreatureType"
|
return "UNKNWON HistoricalEventChangedCreatureType"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
func (e *Entity) Position(id int) *EntityPosition {
|
func (e *Entity) Position(id int) *EntityPosition {
|
||||||
for _, p := range e.EntityPosition {
|
for _, p := range e.EntityPosition {
|
||||||
if p.Id_ == id {
|
if p.Id_ == id {
|
||||||
|
@ -26,3 +28,19 @@ func containsInt(list []int, id int) bool {
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var world *DfWorld
|
||||||
|
|
||||||
|
func hf(id int) string {
|
||||||
|
if x, ok := world.HistoricalFigures[id]; ok {
|
||||||
|
return fmt.Sprintf(`<a href="/hf/%d">%s</a>`, x.Id(), x.Name())
|
||||||
|
}
|
||||||
|
return "UNKNOWN HISTORICAL FIGURE"
|
||||||
|
}
|
||||||
|
|
||||||
|
func site(id int, prefix string) string {
|
||||||
|
if x, ok := world.Sites[id]; ok {
|
||||||
|
return fmt.Sprintf(`%s <a href="/site/%d">%s</a>`, prefix, x.Id(), x.Name())
|
||||||
|
}
|
||||||
|
return "UNKNOWN SITE"
|
||||||
|
}
|
||||||
|
|
|
@ -48,7 +48,6 @@ func Parse(file string) (*DfWorld, error) {
|
||||||
}
|
}
|
||||||
defer xmlFile.Close()
|
defer xmlFile.Close()
|
||||||
|
|
||||||
var world *DfWorld
|
|
||||||
BaseLoop:
|
BaseLoop:
|
||||||
for {
|
for {
|
||||||
tok, err := d.Token()
|
tok, err := d.Token()
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
{{template "layout.html" .}}
|
|
||||||
|
|
||||||
{{define "title"}}<h1>{{.Title}}</h1>{{end}}
|
|
||||||
|
|
||||||
{{define "content"}}
|
|
||||||
<h1>HF</h1>
|
|
||||||
{{end}}
|
|
|
@ -1,15 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>{{block "title" .}}{{end}}</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div class="main">{{block "content" .}}{{end}}</div>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
|
@ -1,4 +1,7 @@
|
||||||
{
|
{
|
||||||
|
"Artifact": {
|
||||||
|
"Writing": "StructureLocalId"
|
||||||
|
},
|
||||||
"HistoricalEventAddHfEntityLink": {
|
"HistoricalEventAddHfEntityLink": {
|
||||||
"LinkType": "Link"
|
"LinkType": "Link"
|
||||||
},
|
},
|
||||||
|
@ -13,6 +16,19 @@
|
||||||
"Involved": "SiteId",
|
"Involved": "SiteId",
|
||||||
"Site": "SiteId"
|
"Site": "SiteId"
|
||||||
},
|
},
|
||||||
|
"HistoricalEventHfDoesInteraction": {
|
||||||
|
"InteractionAction": "Interaction"
|
||||||
|
},
|
||||||
|
"HistoricalEventMasterpieceItem": {
|
||||||
|
"Maker": "Hfid",
|
||||||
|
"MakerEntity": "EntityId",
|
||||||
|
"Site": "SiteId"
|
||||||
|
},
|
||||||
|
"HistoricalEventMerchant": {
|
||||||
|
"Destination": "DepotEntityId",
|
||||||
|
"Site": "SiteId",
|
||||||
|
"Source": "TraderEntityId"
|
||||||
|
},
|
||||||
"HistoricalEventPeaceAccepted": {
|
"HistoricalEventPeaceAccepted": {
|
||||||
"Site": "SiteId"
|
"Site": "SiteId"
|
||||||
},
|
},
|
||||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
File diff suppressed because one or more lines are too long
|
@ -2,7 +2,7 @@
|
||||||
{{- range $event := events . }}
|
{{- range $event := events . }}
|
||||||
<li>
|
<li>
|
||||||
[{{ $event.Id }}] In {{ if gt $event.Seconds72 -1 }}{{ season $event.Seconds72 }} of {{ end }}{{ $event.Year }} {{
|
[{{ $event.Id }}] In {{ if gt $event.Seconds72 -1 }}{{ season $event.Seconds72 }} of {{ end }}{{ $event.Year }} {{
|
||||||
$event.Details.Html }} {{ json $event.Details }}
|
html $event.Details.Html }} {{ json $event.Details }}
|
||||||
</li>
|
</li>
|
||||||
{{- end}}
|
{{- end}}
|
||||||
</ul>
|
</ul>
|
|
@ -6,6 +6,8 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>{{block "title" .}}{{end}}</title>
|
<title>{{block "title" .}}{{end}}</title>
|
||||||
|
<link href="/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<script src="/js/bootstrap.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
Loading…
Reference in New Issue