From 9a67ef921100d16294b30b7d111206789c8e1feb Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Tue, 17 May 2022 14:13:56 -0600 Subject: [PATCH] Add follow.html to v2 --- srv/src/api/api.go | 1 + srv/src/api/render.go | 14 ++++ srv/src/api/tpl/follow.html | 152 ++++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 srv/src/api/tpl/follow.html diff --git a/srv/src/api/api.go b/srv/src/api/api.go index 7323d29..0184ef1 100644 --- a/srv/src/api/api.go +++ b/srv/src/api/api.go @@ -194,6 +194,7 @@ func (a *api) handler() http.Handler { mux.Handle("/api/", http.StripPrefix("/api", apiHandler)) // TODO need to setCSRFMiddleware on all these rendering endpoints + mux.Handle("/v2/follow.html", a.renderDumbHandler("follow.html")) mux.Handle("/v2/posts/", a.renderPostHandler()) mux.Handle("/v2/", a.renderIndexHandler()) diff --git a/srv/src/api/render.go b/srv/src/api/render.go index 2b6b5a0..0f45211 100644 --- a/srv/src/api/render.go +++ b/srv/src/api/render.go @@ -178,3 +178,17 @@ func (a *api) renderPostHandler() http.Handler { } }) } + +func (a *api) renderDumbHandler(tplName string) http.Handler { + + tpl := a.mustParseTpl(tplName) + + return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + if err := tpl.Execute(rw, nil); err != nil { + apiutil.InternalServerError( + rw, r, fmt.Errorf("rendering %q: %w", tplName, err), + ) + return + } + }) +} diff --git a/srv/src/api/tpl/follow.html b/srv/src/api/tpl/follow.html new file mode 100644 index 0000000..8cf9dc6 --- /dev/null +++ b/srv/src/api/tpl/follow.html @@ -0,0 +1,152 @@ +{{ define "body" }} + + + +

+ Here's your options for receiving updates about new blog posts: +

+ +

Option 1: Email

+ +

+ Email is by far my preferred option for notifying followers of new posts. +

+ +

+ The entire email list system for this blog, from storing subscriber email + addresses to the email server which sends the notifications out, has been + designed from scratch and is completely self-hosted in my living room. +

+ +

+ I solemnly swear that: +

+ + + +

+ With all that said, if you'd like to receive an email everytime a new blog + post is published then input your email below and smash that subscribe button! + You will need to verify your email, so be sure to check your spam folder to + complete the process if you don't immediately see anything in your inbox. +

+ + + + + + + + + +

Option 2: RSS

+ +

+ RSS is the classic way to follow any blog. It comes from a time before + aggregators like reddit and twitter stole the show, when people felt capable + to manage their own content feeds. We should use it again. +

+ +

+ To follow over RSS give any RSS reader the following URL... +

+ +

+ {{ BlogURL "feed.xml" }} +

+ +

+ ...and posts from this blog will show up in your RSS feed as soon as they are + published. There are literally thousands of RSS readers out there. Here's some + recommendations: +

+ + + +{{ end }} + +{{ template "base.html" . }}