package handlers
import (
+ "fmt"
"net/http"
"text/template"
)
+var scriptNames = []string{
+ "index.js",
+}
+
+const scriptFormat = `<script defer type="text/javascript" asp-append-version="true" src="%s" args="%s"></script>`
+
+func formatAllScripts(args string) string {
+ totalFormat := ""
+ for _, name := range scriptNames {
+ totalFormat += fmt.Sprintf(scriptFormat, name, args)
+ }
+ fmt.Println("totalFormat:", totalFormat)
+ return totalFormat
+}
+
type IndexPageStruct struct {
+ Scripts string
}
var indexTemplate, err = template.ParseFiles("static/templates/index.html")
func HandleIndex(w http.ResponseWriter, r *http.Request) {
- err := indexTemplate.Execute(w, IndexPageStruct{})
+ err := indexTemplate.Execute(w, IndexPageStruct{
+ formatAllScripts(""),
+ })
if err != nil {
w.Write([]byte("error oopsie woopsie"))
if err != nil {
w.Write([]byte("error oopsie woopsie"))
}
- err = indexTemplate.Execute(w, IndexPageStruct{})
+ err = indexTemplate.Execute(w, IndexPageStruct{
+ formatAllScripts(""),
+ })
if err != nil {
w.Write([]byte("error oopsie woopsie"))
<link href="/css/index.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="/images/favicon.ico">
- <title>FacCalc</title>
+ <title>Phi Factory</title>
</head>
<body>
<div id="sidebar">
<div>
<div class="dualbar">
- <h1>FactorioCalc</h1>
- <button class="right-align"><<</button>
+ <h1>PhiFactory</h1>
+ <button class="right-align" id="save-collapse-button"><<</button>
</div>
<div class="inner-sidebar">
</div>
</body>
-
+ {{ .Scripts }}
</html>