diff --git a/handlers.go b/handlers.go index 6477f60..467bd79 100644 --- a/handlers.go +++ b/handlers.go @@ -29,6 +29,11 @@ func (a *App) pageIndex(w http.ResponseWriter, r *http.Request, vars handlerVars }) } +func (a *App) pageStyle(w http.ResponseWriter, r *http.Request, vars handlerVars) error { + w.Header().Set("Content-Type", "text/css") + return a.templates["style"].Execute(w, nil) +} + func (a *App) pageNews(w http.ResponseWriter, r *http.Request, vars handlerVars) error { return a.templates["news"].Execute(w, map[string]interface{}{ "Reddit": a.news, diff --git a/main.go b/main.go index 5ad6135..1380755 100644 --- a/main.go +++ b/main.go @@ -61,6 +61,7 @@ func New(c Conf) (*App, error) { r := mux.NewRouter() r.Handle("/", handler(a.pageIndex)) + r.Handle("/static/style.css", handler(a.pageStyle)) r.Handle("/news", handler(a.pageNews)) r.Handle("/server/{id}", handler(a.pageServer)) r.Handle("/server/{id}/daily", handler(a.pageDailyChart)) diff --git a/templates.go b/templates.go index 4fbc7e1..7f9a993 100644 --- a/templates.go +++ b/templates.go @@ -34,76 +34,10 @@ const tmplBase string = ` + {{block "title" .}}NO TITLE{{end}} | ss13.se -
@@ -137,6 +71,73 @@ const tmplBase string = ` ` var tmplList = map[string]string{ + "style": ` +* { + padding: 0px; + margin: 0px; +} +body { + margin: 0px auto; + max-width: 1024px; + font-size: 18px; + padding: 0 10px; + line-height: 1.6; + color: #444; + background-color: #fff; +} +h1, h2 { + text-align: center; +} +a, a:hover, a:visited { + color: #444; + text-decoration: none; +} +a:hover { + color: #000; +} +img { + display: block; + margin: auto; +} +header { + margin-bottom: 40px; + padding: 10px 20px; + color: #fff; + background-color: #444; + border-bottom-left-radius: 5px; + border-bottom-right-radius: 5px; +} +header a, header a:hover, header a:visited { + color: #fff; + text-decoration: none; + display: inline; + padding-right: 40px; +} +footer { + margin-top: 40px; + padding: 10px; + text-align: center; +} +.button a { + background-color: #444; + color: #fff; + border-radius: 5px; + padding: 5px 10px; + text-decoration: none; +} +.button a:hover { + background-color: #888; +} +.left { + float: left; +} +.right { + float: right; +} +.hide td, .hide a { + color: #bbb; +} +`, "index": `{{define "title"}}Index{{end}} {{define "body"}}

Servers