commit c37c785b3570259cde7bdaa2a5133aae4cb0c21b from: Matt Streatfield date: Sat Apr 12 04:45:41 2025 UTC Initial search view commit - d95718e9ce49029c8c2d565030da7ba34db4a192 commit + c37c785b3570259cde7bdaa2a5133aae4cb0c21b blob - 9e913e0b55bce0d3a0585f55b2612729ea437a70 blob + d3ffaca7b965399a05cccfa1cff212384af995e4 --- README.md +++ README.md @@ -1 +1,7 @@ ## RSS + +Search RSS feeds and collate a feed. + +### Build + +Run `go run cmd/rss/rss.go` or build `go build cmd/rss/rss.go` blob - f7b60bdeb99641f615e9dca036f3b2bd4f7fd501 blob + 16dbc589ba4bcf57b0efde168a339eafa8f4f8fc --- cmd/rss/rss.go +++ cmd/rss/rss.go @@ -1,7 +1,34 @@ package main -import "fmt" +import ( + "fmt" + "html/template" + "log" + "net/http" +) +func render(w http.ResponseWriter, data any, pages ...string) { + files := append([]string{"internal/templates/base.tmpl"}, pages...) + tmpl := template.Must(template.ParseFiles(files...)) + tmpl.ExecuteTemplate(w, "base", data) +} + +func homeGET(w http.ResponseWriter, r *http.Request) { + render(w, nil, "internal/templates/home.tmpl") +} + +func homePOST(w http.ResponseWriter, r *http.Request) { + fmt.Fprintln(w, "Posted to home page") +} + func main() { - fmt.Println("Hello, world!") + mux := http.NewServeMux() + + mux.Handle("GET /static/", http.StripPrefix("/static/", http.FileServer(http.Dir("web")))) + mux.HandleFunc("GET /", homeGET) + mux.HandleFunc("POST /", homePOST) + + addr := ":8080" + log.Printf("Server running at %s", addr) + log.Fatal(http.ListenAndServe(addr, mux)) } blob - /dev/null blob + 821d5882fb720dbbab407fe88ebcc2974d748e6b (mode 644) --- /dev/null +++ internal/templates/base.tmpl @@ -0,0 +1,32 @@ +{{ define "base" }} + + + + + + + + + RSS + + + +
+ Login +
+
+ {{ block "content" . }}{{ end }} +
+ + + + +{{ end }} \ No newline at end of file blob - /dev/null blob + 7756989b5436336e82e8b6a83d26eaaa449a6393 (mode 644) --- /dev/null +++ internal/templates/home.tmpl @@ -0,0 +1,23 @@ +{{ define "title" }}Home{{ end }} + +{{ define "content" }} +
+ +
+{{ end }} \ No newline at end of file blob - /dev/null blob + 5d28b006bc0515bf54ae1cbe2a900c7ad8e8dbf0 (mode 644) --- /dev/null +++ web/favicon.svg @@ -0,0 +1 @@ + \ No newline at end of file blob - /dev/null blob + 438ab5ca5437aa9776fed711062553da4c7ba2fc (mode 644) --- /dev/null +++ web/style.css @@ -0,0 +1,86 @@ +:root { + --white: #c8c8c8; + --peach: #fbbbad; + --pink: #ee8695; + --blue: #468fb9; + --dark-blue: #333f58; + --black: #292831; +} + +* { + box-sizing: border-box; +} + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; + background-color: var(--black); + color: var(--white); + font-size: 1.2em; + margin: 0; + padding: 0; + min-height: 100vh; + display: flex; + flex-direction: column; +} + +a { + text-decoration: none; + cursor: pointer; + color: var(--peach); +} + +a:hover { + text-decoration: underline; +} + +header { + margin: 2rem; + display: flex; + justify-content: end; +} + +main { + flex: 1; + padding: 1rem; +} + +footer { + text-align: center; + margin-top: auto; + margin: 2rem; +} + +.search-box { + background-color: #212024; + border-radius: 100px; + padding: 0.5rem 0.65rem; + box-shadow: rgba(50, 50, 93, 0.25) 0px 2px 5px -1px, rgba(0, 0, 0, 0.3) 0px 1px 3px -1px; + display: flex; + align-items: center; + max-width: 640px; + margin: 20vh auto; + transition: margin 300ms; + + &.results { + margin: 0 auto; + } + + input { + all: unset; + width: 100%; + color: var(--white); + margin: 0 0.25rem; + } + + button { + all: unset; + cursor: pointer; + color: var(--blue); + line-height: 0; + padding: 0.6rem; + } + + button:focus, button:hover { + color: white; + } +} \ No newline at end of file