From 0ae6f5c00af66bbdfc301f2a27676469c647677e Mon Sep 17 00:00:00 2001 From: xoy Date: Tue, 18 Feb 2025 19:45:28 +0100 Subject: [PATCH] [Project base] --- main.go | 38 +++++++++++++++++++------ static/css/admin.css | 0 static/css/main.css | 31 +++++++++++++++++++-- static/css/search.css | 54 ++++++++++++++++++++++++++++++++++++ types.go | 15 ++++++++++ views/admin/edit.html | 16 +++++++++++ views/admin/overview.html | 28 +++++++++++++++++++ views/admin/tables.html | 7 +++++ views/alert.html | 9 ++++++ views/partials/base-top.html | 2 +- views/search.html | 29 +++++++++++++++++++ 11 files changed, 217 insertions(+), 12 deletions(-) create mode 100644 static/css/admin.css create mode 100644 views/admin/edit.html create mode 100644 views/admin/overview.html create mode 100644 views/admin/tables.html create mode 100644 views/alert.html diff --git a/main.go b/main.go index 4e318ff..900c561 100644 --- a/main.go +++ b/main.go @@ -18,31 +18,51 @@ func main() { navItems := []NavItem{ NewNavItem("Suche", "/search"), + NewNavItem("Verwaltung", "/admin"), } app.Get("/", func(c *fiber.Ctx) error { return c.Render("search", fiber.Map{ - "Title": "Suche", - "Stylenames": NewStyleItemList("colors", "main", "search"), - "NavItems": navItems, + "Title": "Suche", + "Stylenames": NewStyleItemList("colors", "main", "search"), + "NavItems": navItems, + "ActivePage": "/search", + "SearchResultCount": -1, }) }) app.Get("/search", func(c *fiber.Ctx) error { return c.Render("search", fiber.Map{ - "Title": "Suche", - "Stylenames": NewStyleItemList("colors", "main", "search"), - "NavItems": navItems, + "Title": "Suche", + "Stylenames": NewStyleItemList("colors", "main", "search"), + "NavItems": navItems, + "ActivePage": "/search", + "SearchResultCount": -1, }) }) app.Post("/search", func(c *fiber.Ctx) error { return c.Render("search", fiber.Map{ - "Title": "Suche", - "Stylenames": NewStyleItemList("colors", "main", "search"), - "NavItems": navItems, + "Title": "Suche", + "Stylenames": NewStyleItemList("colors", "main", "search"), + "NavItems": navItems, + "ActivePage": "/search", + "SearchResultCount": 0, }) }) + app.Get("/admin", func(c *fiber.Ctx) error { + return c.Render("admin/tables", fiber.Map{ + "Title": "Verwaltung", + "Stylenames": NewStyleItemList("colors", "main", "admin"), + "NavItems": navItems, + "ActivePage": "/admin", + }) + }) + + app.Get("/admin/locations/overview", func(c *fiber.Ctx) error { + return c.Render("admin/overview") + }) + log.Fatal(app.Listen(":3000")) } diff --git a/static/css/admin.css b/static/css/admin.css new file mode 100644 index 0000000..e69de29 diff --git a/static/css/main.css b/static/css/main.css index 877777e..60742c7 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -25,7 +25,11 @@ a:visited { header, footer { background-color: var(--bg-light); - height: 100px; + height: 150px; +} + +footer { + height: 50px; } header { @@ -38,11 +42,14 @@ header > h1 { padding: 0; margin: 0; text-align: center; + font-size: 4.5em; } -header > nav, footer > nav { +:is(header, footer) > nav { display: flex; justify-content: center; + gap: 20px; + font-size: 1.5em; } footer > nav { @@ -54,6 +61,26 @@ footer > nav > a { margin: auto; } +:is(header, footer) > nav > a::before { + content: '< '; +} + +:is(header, footer) > nav > a::after { + content: ' >'; +} + +:is(header, footer) > nav > a:is(:hover, .active)::before { + content: '\00a0>'; +} + +:is(header, footer) > nav > a:is(:hover, .active)::after { + content: '<\00a0'; +} + +:is(header, footer) > nav > a:visited { + color: var(--link); +} + main { min-height: calc(100vh - 200px); } \ No newline at end of file diff --git a/static/css/search.css b/static/css/search.css index e69de29..7f0efaa 100644 --- a/static/css/search.css +++ b/static/css/search.css @@ -0,0 +1,54 @@ +main { + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + gap: 50px; +} + +main > form { + display: flex; + margin-bottom: 50px; +} + +main > form > input { + width: 420px; + height: 50px; + border-radius: 0px; + border-bottom-left-radius: 25px; + border-top-left-radius: 25px; + border: none; + font-size: 24px; + padding: 0 10px 0 10px; + background-color: var(--bg-light); + color: var(--fg); + border-right: 2px solid var(--bg-border); +} + +main > form > input:focus { + outline: none; +} + +main > form > button { + width: 50px; + height: 50px; + border: none; + border-radius: 0px; + border-bottom-right-radius: 25px; + border-top-right-radius: 25px; + cursor: pointer; + background-color: var(--bg-light); + font-size: 24px; +} + +main > table { + width: 800px; + border-collapse: collapse; + background-color: var(--bg-light); +} + +main > table tr :is(td, th) { + border: 2px solid var(--bg-border); + padding: 5px; + text-align: center; +} \ No newline at end of file diff --git a/types.go b/types.go index 942f3bb..a5ba263 100644 --- a/types.go +++ b/types.go @@ -1,5 +1,7 @@ package main +// Web + type NavItem struct { Caption string Destination string @@ -14,3 +16,16 @@ type Stylename string func NewStyleItemList(stylenames ...Stylename) []Stylename { return stylenames } + +// Database + +type Location struct { + id int + parent int + Name string + Description string +} + +func (l *Location) GetParent() *Location { + return nil +} diff --git a/views/admin/edit.html b/views/admin/edit.html new file mode 100644 index 0000000..58fdbd8 --- /dev/null +++ b/views/admin/edit.html @@ -0,0 +1,16 @@ +{{template "partials/base-top" .}} + +
+ {{ range .InputFields }} + + + {{ end }} + + + +
+ +{{template "partials/base-bottom" .}} \ No newline at end of file diff --git a/views/admin/overview.html b/views/admin/overview.html new file mode 100644 index 0000000..409ca63 --- /dev/null +++ b/views/admin/overview.html @@ -0,0 +1,28 @@ +{{template "partials/base-top" .}} + + + + {{ range .Columns }} + + {{ end }} + + {{ range .Rows }} + + {{ range .Columns }} + + {{ end }} + + + {{ end }} +
{{ . }}
{{ . }} +
+ + +
+
+ + +
+
+ +{{template "partials/base-bottom" .}} \ No newline at end of file diff --git a/views/admin/tables.html b/views/admin/tables.html new file mode 100644 index 0000000..f46f18c --- /dev/null +++ b/views/admin/tables.html @@ -0,0 +1,7 @@ +{{template "partials/base-top" .}} + +{{ range .Tables }} +{{ .Caption }} +{{ end }} + +{{template "partials/base-bottom" .}} \ No newline at end of file diff --git a/views/alert.html b/views/alert.html new file mode 100644 index 0000000..3717a6a --- /dev/null +++ b/views/alert.html @@ -0,0 +1,9 @@ +{{template "partials/base-top" .}} + +
+

{{ .Title }}

+

{{ .Message }}

+ 🆗 +
+ +{{template "partials/base-bottom" .}} \ No newline at end of file diff --git a/views/partials/base-top.html b/views/partials/base-top.html index 3ba3c37..1e5d351 100644 --- a/views/partials/base-top.html +++ b/views/partials/base-top.html @@ -13,7 +13,7 @@

fisch

diff --git a/views/search.html b/views/search.html index 846db32..d4bdd79 100644 --- a/views/search.html +++ b/views/search.html @@ -5,4 +5,33 @@ + +{{ if eq .SearchResultCount -1 }} + +{{ else }} + +{{ if gt .SearchResultCount 0 }} + + + + + + + + + + + + +
OrtKistenbezeichnungMöglicher Inhalt
AAA
+ +{{ else }} + +

Keine Ergebnisse gefunden.

+ +{{ end }} + +{{ end }} + + {{template "partials/base-bottom" .}} \ No newline at end of file