From a8dd860711efd4283c3e4aafab10e5b5b86f2a50 Mon Sep 17 00:00:00 2001 From: yequari Date: Sun, 23 Jul 2023 00:34:21 -0700 Subject: [PATCH] add webmaster view, update css, make templates prettier --- cmd/web/handlers.go | 9 +++-- ui/html/base.tmpl.html | 5 ++- ui/html/pages/home.tmpl.html | 2 +- ui/html/pages/siteview.tmpl.html | 11 ++++++ ui/html/pages/view.tmpl.html | 13 ------- ui/html/pages/webmasterview.tmpl.html | 6 +++ ui/static/css/main.css | 53 +++++++++++++++++++++++++++ 7 files changed, 79 insertions(+), 20 deletions(-) create mode 100644 ui/html/pages/siteview.tmpl.html delete mode 100644 ui/html/pages/view.tmpl.html create mode 100644 ui/html/pages/webmasterview.tmpl.html create mode 100644 ui/static/css/main.css diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go index 379d168..371af77 100644 --- a/cmd/web/handlers.go +++ b/cmd/web/handlers.go @@ -2,7 +2,6 @@ package main import ( "errors" - "fmt" "net/http" "git.32bit.cafe/yequari/webring/internal/models" @@ -36,8 +35,10 @@ func (app *application) webmasterView(w http.ResponseWriter, r *http.Request) { } return } - - fmt.Fprintf(w, "%+v", webmaster) + + app.render(w, http.StatusOK, "webmasterview.tmpl.html", &templateData{ + Webmaster: webmaster, + }) } func (app *application) webmasterCreate(w http.ResponseWriter, r *http.Request) { @@ -71,7 +72,7 @@ func (app *application) siteEntryView(w http.ResponseWriter, r *http.Request) { return } - app.render(w, http.StatusOK, "view.tmpl.html", &templateData{ + app.render(w, http.StatusOK, "siteview.tmpl.html", &templateData{ SiteEntry: siteEntry, Webmaster: webmaster, }) diff --git a/ui/html/base.tmpl.html b/ui/html/base.tmpl.html index 2957ff9..586c52e 100644 --- a/ui/html/base.tmpl.html +++ b/ui/html/base.tmpl.html @@ -3,11 +3,12 @@ - {{template "title" .}} - 32-Bit Cafe + + {{template "title" .}} - 32-Bit Cafe Webring
-

Webring

+

32-Bit Cafe Webring

{{template "nav" .}}
diff --git a/ui/html/pages/home.tmpl.html b/ui/html/pages/home.tmpl.html index 5710007..ca6ce95 100644 --- a/ui/html/pages/home.tmpl.html +++ b/ui/html/pages/home.tmpl.html @@ -1,5 +1,4 @@ {{define "title"}}Home{{end}} - {{define "main"}}

Latest Websites

{{ if .SiteEntries }} @@ -8,6 +7,7 @@
  • {{.Name}} (info)
  • {{ end }} +Browse All {{ else }}

    There's nothing to see here yet!

    {{ end }} diff --git a/ui/html/pages/siteview.tmpl.html b/ui/html/pages/siteview.tmpl.html new file mode 100644 index 0000000..aded634 --- /dev/null +++ b/ui/html/pages/siteview.tmpl.html @@ -0,0 +1,11 @@ +{{define "title"}}Site Entry #{{.SiteEntry.Id}}{{end}} +{{define "main"}} +
    + +
    +{{end}} diff --git a/ui/html/pages/view.tmpl.html b/ui/html/pages/view.tmpl.html deleted file mode 100644 index 6e83c19..0000000 --- a/ui/html/pages/view.tmpl.html +++ /dev/null @@ -1,13 +0,0 @@ -{{define "title"}}Site Entry #{{.SiteEntry.Id}}{{end}} -{{define "main"}} -
    - - -
    -{{end}} diff --git a/ui/html/pages/webmasterview.tmpl.html b/ui/html/pages/webmasterview.tmpl.html new file mode 100644 index 0000000..1e6abab --- /dev/null +++ b/ui/html/pages/webmasterview.tmpl.html @@ -0,0 +1,6 @@ +{{define "title"}}Webmaster {{.Webmaster.Name}}{{end}} +{{define "main"}} +
    +

    {{.Webmaster.Name}}

    +
    +{{end}} diff --git a/ui/static/css/main.css b/ui/static/css/main.css new file mode 100644 index 0000000..fae7ea1 --- /dev/null +++ b/ui/static/css/main.css @@ -0,0 +1,53 @@ +* { + box-sizing: border-box; + margin: 0; + padding: 0; + font-size: 18px; + font-family: "Ubuntu Mono", monospace; +} + +html, body { + height: 100%; +} + +body { + line-height: 1.5; + background-color: gray; + overflow-y: scroll; +} + +header, nav, main, footer { + padding: 2px calc((100% -800px)/2) 0; +} + +header { + max-width: 640px; + margin: 0 auto; + padding-top: 33px; + padding-bottom: 27px; + background-color: white; + text-align: center; +} + +nav { + padding-top: 17px; + padding-bottom: 15px; + height: 60px; +} + +main { + max-width: 640px; + margin: 54px auto; + min-height: calc(100vh - 345px); + overflow: auto; + background-color: white; +} + +h2 { + margin: 0; + padding: 10px 0; +} + +.metadata { + +}