small pixel drawing of a pufferfish vore

new style hbu
Jes Olson j3s@c3f.net
Mon, 20 Mar 2023 21:34:11 -0700
commit

28d1c80865e6767cb85d230cd4382b0bb03ee643

parent

1239e062beae5671b7bfb5d26f6e34497b3c01a6

3 files changed, 36 insertions(+), 8 deletions(-)

jump to
M files/style.cssfiles/style.css

@@ -1,6 +1,6 @@

html { font-family: monospace; - max-width: 500px; + max-width: 600px; margin: 10px auto; /* make sure the scrollbar is always shown so the width doesnt change between pages */

@@ -32,10 +32,12 @@ padding-right: 20px;

} ul li { - padding: 8px 0; - border-bottom: 1px dotted #888; - padding: 0.3rem; - font-size: 1.05rem; + padding: 0.4rem; + font-size: 1rem; +} + +ul li:before { + content: '=>'; } nav a {

@@ -53,3 +55,8 @@ .right-text {

float: right; display: inline-block; } + +.puny { + color: grey; + font-size: 0.9rem; +}
M files/user.tmpl.htmlfiles/user.tmpl.html

@@ -12,8 +12,14 @@ <ul>

{{ range .Data.Items }} <a href="{{ .Link }}"> <li> - <span class=left-text>{{ .Title }}</span> - <span class=right-text><small>{{ .Date.Format "2006-01-02" }}</small></span> + {{ .Title }} + <span class=puny> + {{ .Link | printDomain }} + </span> + <br> + <span class=puny> + {{ .Date.Format "2006-01-02" }} + </span> </li> </a> {{ end }}
M site.gosite.go

@@ -262,8 +262,12 @@ // renderPage renders the given page and passes data to the

// template execution engine. it's normally the last thing a // handler should do tbh. func (s *Site) renderPage(w http.ResponseWriter, r *http.Request, page string, data any) { + funcMap := template.FuncMap{ + "printDomain": s.printDomain, + } + tmplFiles := filepath.Join("files", "*.tmpl.html") - tmpl := template.Must(template.ParseGlob(tmplFiles)) + tmpl := template.Must(template.New("whatever").Funcs(funcMap).ParseGlob(tmplFiles)) // we read the stylesheet in order to render it inline cssFile := filepath.Join("files", "style.css")

@@ -296,6 +300,17 @@ if err != nil {

s.renderErr(w, err.Error(), http.StatusInternalServerError) return } +} + +// printDomain does a best-effort uri parse and +// prints the base domain, otherwise returning the +// unmodified string +func (s *Site) printDomain(rawURL string) string { + parsedURL, err := url.Parse(rawURL) + if err != nil { + return "" + } + return parsedURL.Hostname() } // renderErr sets the correct http status in the header,