init
This commit is contained in:
118
main.go
Normal file
118
main.go
Normal file
@@ -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!")
|
||||||
|
}
|
76
static/css/main.css
Normal file
76
static/css/main.css
Normal file
@@ -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 */
|
||||||
|
}
|
BIN
static/fonts/FiraCode-VF.woff2
Normal file
BIN
static/fonts/FiraCode-VF.woff2
Normal file
Binary file not shown.
BIN
static/fonts/InterVariable.woff2
Normal file
BIN
static/fonts/InterVariable.woff2
Normal file
Binary file not shown.
BIN
static/img/favicon.ico
Normal file
BIN
static/img/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
77
static/templates/base.html
Normal file
77
static/templates/base.html
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
{{ define "layout" }}
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<meta name="description" content="HiKoS">
|
||||||
|
<title>HiKoS</title>
|
||||||
|
<link rel="icon" type="image/vnd.icon" href="/static/img/favicon.ico">
|
||||||
|
<link rel="stylesheet" href="/static/css/main.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div id="bereich-a">
|
||||||
|
<div class="top">
|
||||||
|
<div>Formular 1</div> <!-- Entspricht der Breite der ersten 4 unteren Spalten -->
|
||||||
|
<div>Formular 2</div>
|
||||||
|
<div>Formular 3</div>
|
||||||
|
<div>Formular 4</div>
|
||||||
|
</div>
|
||||||
|
<div class="bottom">
|
||||||
|
<table>
|
||||||
|
<colgroup>
|
||||||
|
<col style="width: 27.5%">
|
||||||
|
<col style="width: 7.5%">
|
||||||
|
<col style="width: 7.5%">
|
||||||
|
<col style="width: 7.5%">
|
||||||
|
<col style="width: 5%">
|
||||||
|
<col style="width: 7.5%">
|
||||||
|
<col style="width: 10%">
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Spalte 1</th>
|
||||||
|
<th>Spalte 2</th>
|
||||||
|
<th>Spalte 3</th>
|
||||||
|
<th>Spalte 4</th>
|
||||||
|
<th>Spalte 5</th>
|
||||||
|
<th>Spalte 6</th>
|
||||||
|
<th>Spalte 7</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>Teil 1</td>
|
||||||
|
<td>Teil 2</td>
|
||||||
|
<td>Teil 3</td>
|
||||||
|
<td>Teil 4</td>
|
||||||
|
<td>Teil 5</td>
|
||||||
|
<td>Teil 6</td>
|
||||||
|
<td>Teil 7</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Teil 8</td>
|
||||||
|
<td>Teil 9</td>
|
||||||
|
<td>Teil 10</td>
|
||||||
|
<td>Teil 11</td>
|
||||||
|
<td>Teil 12</td>
|
||||||
|
<td>Teil 13</td>
|
||||||
|
<td>Teil 14</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="bereich-b">
|
||||||
|
<div class="top">
|
||||||
|
<div>Formular 1</div>
|
||||||
|
</div>
|
||||||
|
<div class="bottom">
|
||||||
|
<div>Teil 1</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
{{ end }}
|
Reference in New Issue
Block a user