From 2768ea9414e160f21f4a0408e1ab182606a0c52f Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Wed, 30 Sep 2020 15:18:21 -0400 Subject: [PATCH] Make Monetization optional Some WriteFreely instances are completely private, and thus have no need for public- oriented features like Web Monetization. Like federation, this gives admins control over whether or not the feature is enabled for users. Ref T773 --- account.go | 2 +- admin.go | 1 + collections.go | 2 +- config/config.go | 8 +++++--- templates/user/admin/app-settings.tmpl | 7 +++++++ templates/user/collection.tmpl | 4 +++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/account.go b/account.go index ae8e21c..3adb7f7 100644 --- a/account.go +++ b/account.go @@ -840,7 +840,7 @@ func viewEditCollection(app *App, u *User, w http.ResponseWriter, r *http.Reques } // Add collection properties - c.Monetization = app.db.GetCollectionAttribute(c.ID, "monetization_pointer") + c.MonetizationPointer = app.db.GetCollectionAttribute(c.ID, "monetization_pointer") silenced, err := app.db.IsUserSilenced(u.ID) if err != nil { diff --git a/admin.go b/admin.go index 457b384..a0d10eb 100644 --- a/admin.go +++ b/admin.go @@ -529,6 +529,7 @@ func handleAdminUpdateConfig(apper Apper, u *User, w http.ResponseWriter, r *htt } apper.App().cfg.App.Federation = r.FormValue("federation") == "on" apper.App().cfg.App.PublicStats = r.FormValue("public_stats") == "on" + apper.App().cfg.App.Monetization = r.FormValue("monetization") == "on" apper.App().cfg.App.Private = r.FormValue("private") == "on" apper.App().cfg.App.LocalTimeline = r.FormValue("local_timeline") == "on" if apper.App().cfg.App.LocalTimeline && apper.App().timeline == nil { diff --git a/collections.go b/collections.go index ad9cd87..f2958fd 100644 --- a/collections.go +++ b/collections.go @@ -56,7 +56,7 @@ type ( PublicOwner bool `datastore:"public_owner" json:"-"` URL string `json:"url,omitempty"` - Monetization string `json:"monetization_pointer,omitempty"` + MonetizationPointer string `json:"monetization_pointer,omitempty"` db *datastore hostName string diff --git a/config/config.go b/config/config.go index 9ff13f8..39e461b 100644 --- a/config/config.go +++ b/config/config.go @@ -1,5 +1,5 @@ /* - * Copyright © 2018-2019 A Bunch Tell LLC. + * Copyright © 2018-2020 A Bunch Tell LLC. * * This file is part of WriteFreely. * @@ -136,9 +136,11 @@ type ( MinUsernameLen int `ini:"min_username_len"` MaxBlogs int `ini:"max_blogs"` + // Options for public instances // Federation - Federation bool `ini:"federation"` - PublicStats bool `ini:"public_stats"` + Federation bool `ini:"federation"` + PublicStats bool `ini:"public_stats"` + Monetization bool `ini:"monetization"` // Access Private bool `ini:"private"` diff --git a/templates/user/admin/app-settings.tmpl b/templates/user/admin/app-settings.tmpl index 4bd87da..9142dcc 100644 --- a/templates/user/admin/app-settings.tmpl +++ b/templates/user/admin/app-settings.tmpl @@ -136,6 +136,13 @@ select {
+
+
+
+
+ {{if .Monetization}}

Web Monetization

Web Monetization enables you to receive micropayments from readers that have a Coil membership. Add your payment pointer to enable Web Monetization on your blog.

- +
+ {{end}}