]> git.example.dev Git - creative-path-pep.git/commitdiff
made it so it's easier to keep track of scripts
author2weiEmu <saalbach.robert@outlook.de>
Wed, 29 Jan 2025 21:39:06 +0000 (22:39 +0100)
committer2weiEmu <saalbach.robert@outlook.de>
Wed, 29 Jan 2025 21:39:06 +0000 (22:39 +0100)
pkg/handlers/handlers.go
static/css/index.css
static/js/index.js [new file with mode: 0644]
static/templates/index.html

index 6fc017705570b345522541a481b0f7f30b4a206c..406eecb958774120100ec0b8b4a5a15edf526e14 100644 (file)
@@ -1,17 +1,36 @@
 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"))
@@ -23,7 +42,9 @@ func HandleIndexDebug(w http.ResponseWriter, r *http.Request) {
        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"))
index 5b4eef95ad6ae812f20b2f7bdc309e64daa0fe8b..f1f0a365aaa1a4da209ea77369f997aed53840ce 100644 (file)
@@ -54,5 +54,13 @@ h1 {
        border-right: 3px solid black;
 }
 
+#save-collapse-button {
+       background: none;
+       outline: none;
+       border: none;
+       color: var(--primary);
+       font-size: large;
+}
+
 .inner-sidebar {
 }
diff --git a/static/js/index.js b/static/js/index.js
new file mode 100644 (file)
index 0000000..7905a73
--- /dev/null
@@ -0,0 +1 @@
+console.log("Loaded index.js")
index 6c06d57af1bb9d0dc8745fc8e74f278e34b8bc18..050cf9cf6719d1d541dc36a5d25d70b63f7992ce 100644 (file)
@@ -5,15 +5,15 @@
                <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">
 
@@ -22,5 +22,5 @@
                </div>
        </body>
 
-
+       {{ .Scripts }}
 </html>