From: 2weiEmu Date: Wed, 29 Jan 2025 15:50:56 +0000 (+0100) Subject: added basic debug mode X-Git-Url: https://git.saalbach.dev/?a=commitdiff_plain;h=61b965273f2663222e88c06e1641ba87e748e43f;p=creative-path-pep.git added basic debug mode --- diff --git a/Makefile b/Makefile index cf5a684..7544ca1 100644 --- 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 be1b7ee..dca3640 100644 --- 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) } } diff --git a/pkg/handlers/handlers.go b/pkg/handlers/handlers.go index e98c0cb..6fc0177 100644 --- a/pkg/handlers/handlers.go +++ b/pkg/handlers/handlers.go @@ -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")) + } +} diff --git a/static/css/index.css b/static/css/index.css index 966df95..5b4eef9 100644 --- a/static/css/index.css +++ b/static/css/index.css @@ -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 { +} diff --git a/static/templates/index.html b/static/templates/index.html index ffee1c1..6c06d57 100644 --- a/static/templates/index.html +++ b/static/templates/index.html @@ -11,7 +11,11 @@