aboutsummaryrefslogtreecommitdiff
path: root/internal/web/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/web/server.go')
-rw-r--r--internal/web/server.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/internal/web/server.go b/internal/web/server.go
index 6e76d3f..92cb758 100644
--- a/internal/web/server.go
+++ b/internal/web/server.go
@@ -74,6 +74,7 @@ func NewServer(cfg config.Config) http.Handler {
mux.HandleFunc("GET /calendar.ics", func(w http.ResponseWriter, r *http.Request) { calendarICSHandler(s.get())(w, r) })
mux.HandleFunc("GET /reader", func(w http.ResponseWriter, r *http.Request) { readerHandler(s.get(), s.table())(w, r) })
mux.HandleFunc("GET /theme.css", func(w http.ResponseWriter, r *http.Request) { themeCSSHandler(s.get())(w, r) })
+ mux.HandleFunc("GET /source", sourceHandler)
mux.HandleFunc("GET /settings", settingsGet(s))
mux.HandleFunc("POST /settings", settingsPost(s))
mux.HandleFunc("POST /reader/bookmark", addBookmark(s))
@@ -691,6 +692,32 @@ func themeCSSHandler(cfg config.Config) http.HandlerFunc {
}
}
+// sourceHandler serves the AGPL-3.0 §13 source offer: where to obtain the
+// code this server is running. Every page footer links here, so a user
+// interacting with lectio-web over a network is never more than one click
+// from the corresponding source.
+//
+// Deliberately dependency-free (no template, no config read): it must answer
+// even when config is broken or a template failed to parse, because a §13
+// offer that only works on healthy days is not an offer. Plain text keeps it
+// readable by both a browser and curl.
+func sourceHandler(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Content-Type", "text/plain; charset=utf-8")
+ w.Header().Set("X-Content-Type-Options", "nosniff")
+ fmt.Fprintf(w, `lectio %s
+Licence: %s (GNU Affero General Public License, version 3 or later)
+Source: %s
+
+lectio is free software. You may use, study, share and modify it under the
+terms of the AGPL. The full licence text ships with the source as LICENSE.
+
+Because this is the Affero GPL, section 13 applies to this server: if the
+code running here has been MODIFIED, whoever operates it must offer you the
+modified source. If this address does not lead to the version you are
+talking to, that is the operator's obligation to fix, not lectio's.
+`, config.Version, config.License, config.SourceURL)
+}
+
// settingsData drives templates/settings.html.
type settingsData struct {
Cfg config.Config