build
This commit is contained in:
parent
a30c1515f0
commit
5aa0bc5a8d
|
@ -5,3 +5,4 @@ legendsbrowser
|
|||
*.png
|
||||
/*.json
|
||||
.DS_Store
|
||||
bin
|
|
@ -0,0 +1,10 @@
|
|||
build:
|
||||
cd backend && GOOS=linux GOARCH=386 go build -o ../bin/legendsbrowser-linux-386 main.go
|
||||
cd backend && GOOS=linux GOARCH=amd64 go build -o ../bin/legendsbrowser-linux-x64 main.go
|
||||
cd backend && GOOS=windows GOARCH=386 go build -o ../bin/legendsbrowser-386.exe main.go
|
||||
cd backend && GOOS=windows GOARCH=amd64 go build -o ../bin/legendsbrowser-x64.exe main.go
|
||||
cd backend && GOOS=darwin GOARCH=amd64 go build -o ../bin/legendsbrowser-macos-x64 main.go
|
||||
cd backend && GOOS=darwin GOARCH=arm64 go build -o ../bin/legendsbrowser-macos-m1 main.go
|
||||
|
||||
run:
|
||||
cd backend && go run main.go
|
|
@ -9,6 +9,7 @@ import (
|
|||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
@ -73,43 +74,7 @@ func main() {
|
|||
}
|
||||
|
||||
world = w
|
||||
|
||||
fmt.Println("Hallo Welt!")
|
||||
runtime.GC()
|
||||
// world.Process()
|
||||
|
||||
// model.ListOtherElements("world", &[]*model.World{&world})
|
||||
// model.ListOtherElements("region", &world.Regions)
|
||||
// model.ListOtherElements("underground regions", &world.UndergroundRegions)
|
||||
// model.ListOtherElements("landmasses", &world.Landmasses)
|
||||
// model.ListOtherElements("sites", &world.Sites)
|
||||
// model.ListOtherElements("world constructions", &world.WorldConstructions)
|
||||
// model.ListOtherElements("artifacts", &world.Artifacts)
|
||||
// model.ListOtherElements("entities", &world.Entities)
|
||||
// model.ListOtherElements("hf", &world.HistoricalFigures)
|
||||
// model.ListOtherElements("events", &world.HistoricalEvents)
|
||||
// model.ListOtherElements("collections", &world.HistoricalEventCollections)
|
||||
// model.ListOtherElements("era", &world.HistoricalEras)
|
||||
// model.ListOtherElements("danceForm", &world.DanceForms)
|
||||
// model.ListOtherElements("musicalForm", &world.MusicalForms)
|
||||
// model.ListOtherElements("poeticForm", &world.PoeticForms)
|
||||
// model.ListOtherElements("written", &world.WrittenContents)
|
||||
|
||||
// server.RegisterResource(router, "region", world.Regions)
|
||||
// // server.RegisterResource(router, "undergroundRegion", world.UndergroundRegions)
|
||||
// server.RegisterResource(router, "landmass", world.Landmasses)
|
||||
// server.RegisterResource(router, "site", world.Sites)
|
||||
// server.RegisterResource(router, "worldConstruction", world.WorldConstructions)
|
||||
// server.RegisterResource(router, "artifact", world.Artifacts)
|
||||
// server.RegisterResource(router, "hf", world.HistoricalFigures)
|
||||
// server.RegisterResource(router, "collection", world.HistoricalEventCollections)
|
||||
// server.RegisterResource(router, "entity", world.Entities)
|
||||
// server.RegisterResource(router, "event", world.HistoricalEvents)
|
||||
// // server.RegisterResource(router, "era", world.HistoricalEras)
|
||||
// server.RegisterResource(router, "danceForm", world.DanceForms)
|
||||
// server.RegisterResource(router, "musicalForm", world.MusicalForms)
|
||||
// server.RegisterResource(router, "poeticForm", world.PoeticForms)
|
||||
// server.RegisterResource(router, "written", world.WrittenContents)
|
||||
|
||||
RegisterResourcePage(router, "/entity/{id}", t, "entity.html", func(id int) any { return world.Entities[id] })
|
||||
RegisterResourcePage(router, "/hf/{id}", t, "hf.html", func(id int) any { return world.HistoricalFigures[id] })
|
||||
|
@ -123,10 +88,32 @@ func main() {
|
|||
spa := spaHandler{staticFS: static, staticPath: "static", indexPath: "index.html"}
|
||||
router.PathPrefix("/").Handler(spa)
|
||||
|
||||
openbrowser("http://localhost:8080")
|
||||
|
||||
fmt.Println("Serving at :8080")
|
||||
http.ListenAndServe(":8080", router)
|
||||
}
|
||||
|
||||
func openbrowser(url string) {
|
||||
var err error
|
||||
|
||||
switch runtime.GOOS {
|
||||
case "linux":
|
||||
err = exec.Command("xdg-open", url).Start()
|
||||
case "windows":
|
||||
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
|
||||
case "darwin":
|
||||
err = exec.Command("open", url).Start()
|
||||
default:
|
||||
err = fmt.Errorf("unsupported platform")
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Println("navigate to http://localhost:8080 in your browser")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func allEventTypes() []string {
|
||||
types := make(map[string]bool)
|
||||
for _, e := range world.HistoricalEvents {
|
||||
|
|
|
@ -933,7 +933,6 @@ func (x *HistoricalEventHfDied) Html(c *context) string {
|
|||
return hf + " drowned" + loc
|
||||
case HistoricalEventHfDiedCause_DrownAlt, HistoricalEventHfDiedCause_ExecDrowned:
|
||||
return hf + " was drowned" + slayer + loc
|
||||
case HistoricalEventHfDiedCause_DrownAltTwo:
|
||||
case HistoricalEventHfDiedCause_EncaseIce, HistoricalEventHfDiedCause_FreezingWater:
|
||||
return hf + " was encased in ice" + loc
|
||||
case HistoricalEventHfDiedCause_ExecGeneric, HistoricalEventHfDiedCause_ExecutionGeneric:
|
||||
|
@ -949,7 +948,6 @@ func (x *HistoricalEventHfDied) Html(c *context) string {
|
|||
return hf + " starved" + loc
|
||||
case HistoricalEventHfDiedCause_Infection:
|
||||
return hf + " succumbed to infection" + loc
|
||||
case HistoricalEventHfDiedCause_LeaptFromHeight:
|
||||
case HistoricalEventHfDiedCause_Melt:
|
||||
return hf + " melted" + loc
|
||||
case HistoricalEventHfDiedCause_Murder, HistoricalEventHfDiedCause_Murdered:
|
||||
|
@ -972,9 +970,9 @@ func (x *HistoricalEventHfDied) Html(c *context) string {
|
|||
return hf + " was struck down" + slayer + loc
|
||||
case HistoricalEventHfDiedCause_Suffocate, HistoricalEventHfDiedCause_Air:
|
||||
return hf + " suffocated, slain by " + slayer + loc
|
||||
case HistoricalEventHfDiedCause_SuicideDrowned:
|
||||
case HistoricalEventHfDiedCause_SuicideDrowned, HistoricalEventHfDiedCause_DrownAltTwo:
|
||||
return hf + " drowned " + util.If(world.HistoricalFigures[x.Hfid].Female(), "herself ", "himself ") + loc
|
||||
case HistoricalEventHfDiedCause_SuicideLeaping:
|
||||
case HistoricalEventHfDiedCause_SuicideLeaping, HistoricalEventHfDiedCause_LeaptFromHeight:
|
||||
return hf + " leapt from a great height" + loc
|
||||
case HistoricalEventHfDiedCause_Thirst:
|
||||
return hf + " died of thirst" + loc
|
||||
|
|
|
@ -31,7 +31,7 @@ func NewDebug(funcMap template.FuncMap) *Template {
|
|||
}
|
||||
}
|
||||
|
||||
var DebugTemplates = true
|
||||
var DebugTemplates = false
|
||||
|
||||
func (t *Template) Render(w io.Writer, name string, data interface{}) error {
|
||||
if DebugTemplates {
|
||||
|
|
Loading…
Reference in New Issue