add webmaster view, update css, make templates prettier

This commit is contained in:
yequari 2023-07-23 00:34:21 -07:00
parent 2b761b31c3
commit a8dd860711
7 changed files with 79 additions and 20 deletions

View File

@ -2,7 +2,6 @@ package main
import ( import (
"errors" "errors"
"fmt"
"net/http" "net/http"
"git.32bit.cafe/yequari/webring/internal/models" "git.32bit.cafe/yequari/webring/internal/models"
@ -37,7 +36,9 @@ func (app *application) webmasterView(w http.ResponseWriter, r *http.Request) {
return 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) { 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 return
} }
app.render(w, http.StatusOK, "view.tmpl.html", &templateData{ app.render(w, http.StatusOK, "siteview.tmpl.html", &templateData{
SiteEntry: siteEntry, SiteEntry: siteEntry,
Webmaster: webmaster, Webmaster: webmaster,
}) })

View File

@ -3,11 +3,12 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>{{template "title" .}} - 32-Bit Cafe</title> <link rel="stylesheet" href="/static/css/main.css">
<title>{{template "title" .}} - 32-Bit Cafe Webring</title>
</head> </head>
<body> <body>
<header> <header>
<h1>Webring</h1> <h1>32-Bit Cafe Webring</h1>
{{template "nav" .}} {{template "nav" .}}
</header> </header>
<main> <main>

View File

@ -1,5 +1,4 @@
{{define "title"}}Home{{end}} {{define "title"}}Home{{end}}
{{define "main"}} {{define "main"}}
<h2>Latest Websites</h2> <h2>Latest Websites</h2>
{{ if .SiteEntries }} {{ if .SiteEntries }}
@ -8,6 +7,7 @@
<li><a href="{{.Url}}">{{.Name}}</a> (<a href="/sites/view?id={{.Id}}">info</a>)</li> <li><a href="{{.Url}}">{{.Name}}</a> (<a href="/sites/view?id={{.Id}}">info</a>)</li>
{{ end }} {{ end }}
</ul> </ul>
<a href="/sites">Browse All</a>
{{ else }} {{ else }}
<p>There's nothing to see here yet!</p> <p>There's nothing to see here yet!</p>
{{ end }} {{ end }}

View File

@ -0,0 +1,11 @@
{{define "title"}}Site Entry #{{.SiteEntry.Id}}{{end}}
{{define "main"}}
<div class='siteentry'>
<div class='metadata'>
<strong>{{.SiteEntry.Name}}</strong>
<span><a href="{{.SiteEntry.Url}}">{{.SiteEntry.Url}}</a></span>
<time>Joined: {{.SiteEntry.DateAdded}}</time>
<p>Webmaster: <a href="/webmasters/view?id={{.Webmaster.Id}}">{{.Webmaster.Name}}</a></p>
</div>
</div>
{{end}}

View File

@ -1,13 +0,0 @@
{{define "title"}}Site Entry #{{.SiteEntry.Id}}{{end}}
{{define "main"}}
<div class='snippet'>
<div class='metadata'>
<strong>{{.SiteEntry.Name}}</strong>
<span>#{{.SiteEntry.Id}}</span>
</div>
<div class='metadata'>
<time>Created: {{.SiteEntry.DateAdded}}</time>
<p>Webmaster: {{.Webmaster.Name}}</p>
</div>
</div>
{{end}}

View File

@ -0,0 +1,6 @@
{{define "title"}}Webmaster {{.Webmaster.Name}}{{end}}
{{define "main"}}
<div class='webmaster'>
<p>{{.Webmaster.Name}}</p>
</div>
{{end}}

53
ui/static/css/main.css Normal file
View File

@ -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 {
}