~amolith/go-webring

c1a0465e4cc8353ef01e83050908863ffe328dac — Joe Roe 3 months ago 86c6fc3
Add static file server

Implements: https://todo.sr.ht/~amolith/public-tracker/23
3 files changed, 8 insertions(+), 2 deletions(-)

M README.md
M main.go
A static/.keep
M README.md => README.md +5 -2
@@ 80,13 80,16 @@ $ ./go-webring

To run your own webring, you'll first need a template homepage. This should be
any HTML file with the string "`{{ . }}`" placed wherever you want the table of
members inserted. This table is plain HTML so you can style it with CSS in the
template's `<head>` or in a separate `.css` file.
members inserted. This table is plain HTML so you can style it with CSS.

Pandoc produces very pleasing (in my opinion) standalone HTML pages; if you just
want something simple, I would recommend modifying the included `index.md` and
generating your homepage as in section above.

To serve other assets, such as styles in a separate `.css` file, images, etc.,
place them in the `static/` directory; a file at `static/favicon.ico` will be
accessible at `https://example.com/static/favicon.ico`.

Next, you'll need a text file containing a list of members. On each line should
be the member's unique identifer (such as their username) followed by a single
space followed by their site's URI omitting the scheme. For example, if a user

M main.go => main.go +3 -0
@@ 78,6 78,9 @@ func main() {
	mux.HandleFunc("/random", m.random)
	mux.HandleFunc("/"+*flagValidationLog, m.validationLog)

	fileHandler := http.StripPrefix("/static/", http.FileServer(http.Dir("static")))
	mux.Handle("/static/", fileHandler)

	if err := httpServer.ListenAndServe(); err == http.ErrServerClosed {
		log.Println("Web server closed")
	} else {

A static/.keep => static/.keep +0 -0