bootstrap
This commit is contained in:
parent
821a1439a7
commit
153d46d830
|
@ -23,8 +23,8 @@ import (
|
|||
|
||||
var world *model.DfWorld
|
||||
|
||||
//go:embed resources/frontend
|
||||
var frontend embed.FS
|
||||
//go:embed static
|
||||
var static embed.FS
|
||||
|
||||
func main() {
|
||||
f := flag.String("f", "", "open a file")
|
||||
|
@ -108,6 +108,9 @@ func main() {
|
|||
|
||||
return r
|
||||
},
|
||||
"html": func(value any) template.HTML {
|
||||
return template.HTML(fmt.Sprint(value))
|
||||
},
|
||||
}
|
||||
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)
|
||||
|
||||
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
|
||||
path = h.staticPath + path
|
||||
fmt.Println(path)
|
||||
fmt.Println(r.URL, "->", path)
|
||||
|
||||
_, err := h.staticFS.Open(path)
|
||||
if os.IsNotExist(err) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// Code generated by legendsbrowser; DO NOT EDIT.
|
||||
package model
|
||||
|
||||
func (x *HistoricalEventAddHfEntityHonor) Html() string {
|
||||
|
@ -49,8 +48,20 @@ func (x *HistoricalEventCeremony) Html() string { return "UNKNWON HistoricalEven
|
|||
func (x *HistoricalEventChangeHfBodyState) Html() string {
|
||||
return "UNKNWON HistoricalEventChangeHfBodyState"
|
||||
}
|
||||
func (x *HistoricalEventChangeHfJob) Html() string { return "UNKNWON HistoricalEventChangeHfJob" }
|
||||
func (x *HistoricalEventChangeHfState) Html() string { return "UNKNWON HistoricalEventChangeHfState" }
|
||||
func (x *HistoricalEventChangeHfJob) Html() string { return "UNKNWON HistoricalEventChangeHfJob" }
|
||||
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 {
|
||||
return "UNKNWON HistoricalEventChangedCreatureType"
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package model
|
||||
|
||||
import "fmt"
|
||||
|
||||
func (e *Entity) Position(id int) *EntityPosition {
|
||||
for _, p := range e.EntityPosition {
|
||||
if p.Id_ == id {
|
||||
|
@ -26,3 +28,19 @@ func containsInt(list []int, id int) bool {
|
|||
}
|
||||
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()
|
||||
|
||||
var world *DfWorld
|
||||
BaseLoop:
|
||||
for {
|
||||
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": {
|
||||
"LinkType": "Link"
|
||||
},
|
||||
|
@ -13,6 +16,19 @@
|
|||
"Involved": "SiteId",
|
||||
"Site": "SiteId"
|
||||
},
|
||||
"HistoricalEventHfDoesInteraction": {
|
||||
"InteractionAction": "Interaction"
|
||||
},
|
||||
"HistoricalEventMasterpieceItem": {
|
||||
"Maker": "Hfid",
|
||||
"MakerEntity": "EntityId",
|
||||
"Site": "SiteId"
|
||||
},
|
||||
"HistoricalEventMerchant": {
|
||||
"Destination": "DepotEntityId",
|
||||
"Site": "SiteId",
|
||||
"Source": "TraderEntityId"
|
||||
},
|
||||
"HistoricalEventPeaceAccepted": {
|
||||
"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 . }}
|
||||
<li>
|
||||
[{{ $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>
|
||||
{{- end}}
|
||||
</ul>
|
|
@ -6,6 +6,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>
|
||||
<link href="/css/bootstrap.min.css" rel="stylesheet">
|
||||
<script src="/js/bootstrap.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
|
Loading…
Reference in New Issue