diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..d78d53e --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module git.send.nrw/sendnrw/hikos + +go 1.23.1 diff --git a/main.go b/main.go new file mode 100644 index 0000000..70c1576 --- /dev/null +++ b/main.go @@ -0,0 +1,118 @@ +package main + +import ( + "fmt" + "html/template" + "net/http" + "os" + "os/signal" + "strconv" + "strings" + "syscall" + "time" +) + +func getenv(k, d string) string { + if v := os.Getenv(k); v != "" { + return v + } + return d +} + +func enabled(k string, def bool) bool { + b, err := strconv.ParseBool(strings.ToLower(os.Getenv(k))) + if err != nil { + return def + } + return b +} + +func cacheControl(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Cache-Control", "public, max-age=31536000, immutable") + next.ServeHTTP(w, r) + }) +} + +func main() { + + // Signal-Kanal einrichten + stop := make(chan os.Signal, 1) + signal.Notify(stop, syscall.SIGINT, syscall.SIGTERM) + + // Goroutine, die auf Signale wartet + go func() { + <-stop + fmt.Println("Stop Sign...") + prepareExit() + os.Exit(0) + }() + + // --- Verzeichnisse konfigurierbar machen ------------------------- + staticDir := getenv("BLOG_STATIC_DIR", "./static") + templatesDir := getenv("BLOG_TEMPLATES_DIR", "./static/templates") + /*storeEnabled := enabled("STORE_ENABLE", false)*/ + + /*TickCatalog = nil + if err := LoadTickCatalog(ticksDir + "/ticks.json"); err != nil { + fmt.Println("Fehler beim Laden:", err) + } + + fmt.Println("Geladener Katalog:", TickCatalog) + + cloneRepo(gitRepo, gitBranch, gitDir)*/ + + funcs := template.FuncMap{ + "now": time.Now, // jetzt‑Zeit bereitstellen + } + + // Basislayout zuerst parsen + layout := template.Must(template.New("base").Funcs(funcs).ParseFiles(templatesDir + "/base.html")) + + // LIST‑Seite: base + list.html + /*tplList = template.Must(layout.Clone()) + template.Must(tplList.Funcs(funcs).ParseFiles(templatesDir + "/list.html")) + tplArticle = template.Must(layout.Clone()) + template.Must(tplArticle.Funcs(funcs).ParseFiles(templatesDir + "/article.html")) + tplPage := template.Must(layout.Clone()) + template.Must(tplPage.ParseFiles(templatesDir + "/page.html"))*/ + + mux := http.NewServeMux() + + // Handler für / + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + layout.ExecuteTemplate(w, "layout", nil) + }) + + mux.HandleFunc("/post/", func(w http.ResponseWriter, r *http.Request) { + + }) + + mux.HandleFunc("/page/", func(w http.ResponseWriter, r *http.Request) { + + }) + + mux.Handle("/static/", cacheControl(http.StripPrefix("/static/", http.FileServer(http.Dir(staticDir))))) + + mux.HandleFunc("/store", func(w http.ResponseWriter, r *http.Request) { + + }) + + StopServer(http.ListenAndServe(":8080", mux)) + +} + +func prepareExit() { + fmt.Println("~", "Running exit tasks...") + /*if err := SaveTickCatalog(getenv("BLOG_TICKS_DIR", "/ticks") + "/ticks.json"); err != nil { + fmt.Println("Fehler beim Speichern:", err) + } + fmt.Println("Geladener Katalog:", TickCatalog)*/ + fmt.Println("~", "Exit completed.") +} + +func StopServer(e error) { + fmt.Println("~", "Stopping server...") + prepareExit() + fmt.Println("~", "Server stopped!") +} diff --git a/static/css/main.css b/static/css/main.css new file mode 100644 index 0000000..c1a51c5 --- /dev/null +++ b/static/css/main.css @@ -0,0 +1,76 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; + } + + body, html { + height: 100%; + width: 100%; + } + + .container { + display: flex; + height: 100%; + width: 100%; + } + + #bereich-a { + width: 72.5%; + display: flex; + flex-direction: column; + height: 100%; + } + + #bereich-b { + width: 27.5%; + display: flex; + flex-direction: column; + height: 100%; + } + + .top { + height: 80px; + display: grid; + grid-template-columns: 50% 5% 7.5% 10%; + } + + .top > div { + background-color: #ccc; /* Beispiel für Formularfelder */ + } + + .bottom { + flex-grow: 1; + display: grid; + grid-template-columns: 27.5% 7.5% 7.5% 7.5% 5% 7.5% 10%; + } + + .bottom > div { + background-color: #ddd; /* Beispiel für die Unterteile */ + } + + #bereich-b .top { + height: 80px; + display: grid; + grid-template-columns: 100%; + } + + #bereich-b .top > div { + background-color: #bbb; /* Beispiel für Formularfelder */ + } + + #bereich-b .bottom { + flex-grow: 1; + background-color: #f5f5f5; /* Beispiel für unteren Bereich */ + } + + table { + width: 100%; + border-collapse: collapse; /* Für eine saubere Darstellung */ + } + + th, td { + border: 1px solid #ddd; /* Beispiel für einen Rahmen */ + padding: 8px; + text-align: center; /* Beispiel für Textzentrierung */ + } \ No newline at end of file diff --git a/static/fonts/FiraCode-VF.woff2 b/static/fonts/FiraCode-VF.woff2 new file mode 100644 index 0000000..e755a9d Binary files /dev/null and b/static/fonts/FiraCode-VF.woff2 differ diff --git a/static/fonts/InterVariable.woff2 b/static/fonts/InterVariable.woff2 new file mode 100644 index 0000000..5a8d3e7 Binary files /dev/null and b/static/fonts/InterVariable.woff2 differ diff --git a/static/img/favicon.ico b/static/img/favicon.ico new file mode 100644 index 0000000..52b302f Binary files /dev/null and b/static/img/favicon.ico differ diff --git a/static/templates/base.html b/static/templates/base.html new file mode 100644 index 0000000..cd20ad0 --- /dev/null +++ b/static/templates/base.html @@ -0,0 +1,77 @@ +{{ define "layout" }} + + +
+ + + +Spalte 1 | +Spalte 2 | +Spalte 3 | +Spalte 4 | +Spalte 5 | +Spalte 6 | +Spalte 7 | +
---|---|---|---|---|---|---|
Teil 1 | +Teil 2 | +Teil 3 | +Teil 4 | +Teil 5 | +Teil 6 | +Teil 7 | +
Teil 8 | +Teil 9 | +Teil 10 | +Teil 11 | +Teil 12 | +Teil 13 | +Teil 14 | +