]> git.example.dev Git - creative-path-pep.git/commitdiff
added basic debug mode
author2weiEmu <saalbach.robert@outlook.de>
Wed, 29 Jan 2025 15:50:56 +0000 (16:50 +0100)
committer2weiEmu <saalbach.robert@outlook.de>
Wed, 29 Jan 2025 15:50:56 +0000 (16:50 +0100)
Makefile
main.go
pkg/handlers/handlers.go
static/css/index.css
static/templates/index.html

index cf5a684f280a5e307d2e330dec0fe2b25a698adf..7544ca13c78bb20ef86e73de15be95fbf40d16c3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,8 @@ DEPLOY_BASE =
 
 default: $(OBJECTS)
        $(CMD) run $(OBJECTS)
+debug: $(OBJECTS)
+       $(CMD) run $(OBJECTS) -debug
 
 build: $(OBJECTS)
        $(CMD) build -o $(TARGET) $(OBJECTS)
diff --git a/main.go b/main.go
index be1b7ee85918dc67edc8c21148242d2aa446764e..dca3640eca1482fe4f628ed33520f0c694e6195c 100644 (file)
--- a/main.go
+++ b/main.go
@@ -18,6 +18,8 @@ import (
 func main() {
        paramDeploy := flag.Bool(
                "d", false, "A flag specifying the deploy mode of the server.")
+       paramDebug := flag.Bool(
+               "debug", false, "A flag specifying whether the server should be in debug mode.")
        paramPort := flag.Int(
                "p", 8000, "The port the server should be deployed on.")
        _ = flag.String(
@@ -37,6 +39,10 @@ func main() {
        logger.RequestLog = log.New(logFile, "[REQUEST] ", logger.LoggerFlags)
        logger.ErrorLog = log.New(logFile, "[ERROR] ", logger.LoggerFlags)
 
+       if *paramDebug {
+               fmt.Println("Running in debug mode.")
+       }
+
        cssDir := http.Dir("static/css")
        imgDir := http.Dir("static/images")
        jsDir := http.Dir("static/js")
@@ -48,7 +54,12 @@ func main() {
        } 
 
        router := mux.NewRouter()
-       router.HandleFunc("/", handlers.HandleIndex)
+
+       if *paramDebug {
+               router.HandleFunc("/", handlers.HandleIndexDebug)
+       } else {
+               router.HandleFunc("/", handlers.HandleIndex)
+       }
 
        http.Handle("/", router)
        http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(cssDir)))
@@ -67,6 +78,6 @@ func main() {
        }
 
        if err != nil {
-               logger.ErrorLog.Fatalf("Listen and serve failed with:", err)
+               logger.ErrorLog.Fatalf("Listen and serve failed with: %v", err)
        }
 }
index e98c0cb9ba0fd8fdd82df18f2298fb1a1a390907..6fc017705570b345522541a481b0f7f30b4a206c 100644 (file)
@@ -17,3 +17,15 @@ func HandleIndex(w http.ResponseWriter, r *http.Request) {
                w.Write([]byte("error oopsie woopsie"))
        }
 }
+
+func HandleIndexDebug(w http.ResponseWriter, r *http.Request) {
+       indexTemplate, err := template.ParseFiles("static/templates/index.html")
+       if err != nil {
+               w.Write([]byte("error oopsie woopsie"))
+       }
+       err = indexTemplate.Execute(w, IndexPageStruct{})
+
+       if err != nil {
+               w.Write([]byte("error oopsie woopsie"))
+       }
+}
index 966df95ced69eafdd03f1fda5f32a75061c25716..5b4eef95ad6ae812f20b2f7bdc309e64daa0fe8b 100644 (file)
@@ -11,8 +11,6 @@
 @font-face {
        src: url("/fonts/JosefinSans_VariableFont_wght.ttf");
        font-family: JosefinSans;
-       font-weight: 400;
-       font-style: normal;
 }
 
 * {
@@ -28,14 +26,33 @@ body {
        padding: 0;
 }
 
+h1 {
+       color: var(--text);
+       margin-top: 5px;
+       margin-bottom: 5px;
+}
+
+.title {
+       font-weight: bold;
+}
+
+.dualbar {
+       display: flex;
+       width: 100%;
+       justify-content: space-between;
+}
+
 #sidebar {
        position: fixed;
        width: 20%;
        height: 100vh;
        background-color: var(--bg);
+       padding: 5px;
 
        box-shadow: 4px 4px 0px var(--text);
 
        border-right: 3px solid black;
 }
 
+.inner-sidebar {
+}
index ffee1c121f6b764909a8e6cc348dd0d740b8e444..6c06d57af1bb9d0dc8745fc8e74f278e34b8bc18 100644 (file)
        <body>
                <div id="sidebar">
                        <div>
-                               <div>
+                               <div class="dualbar">
+                                       <h1>FactorioCalc</h1>
+                                       <button class="right-align"><<</button>
+                               </div>
+                               <div class="inner-sidebar">
 
                                </div>
                        </div>