diff --git a/cmd/handlers.go b/cmd/handlers.go index 4b6328c..ed93e68 100644 --- a/cmd/handlers.go +++ b/cmd/handlers.go @@ -172,7 +172,10 @@ func initHTTPHandlers(e *echo.Echo, app *App) { // Public API endpoints. e.GET("/api/public/lists", handleGetPublicLists) e.POST("/api/public/subscription", handlePublicSubscription) - e.GET("/api/public/archive", handleGetCampaignArchives) + + if app.constants.EnablePublicArchive { + e.GET("/api/public/archive", handleGetCampaignArchives) + } // /public/static/* file server is registered in initHTTPServer(). // Public subscriber facing views. @@ -195,9 +198,11 @@ func initHTTPHandlers(e *echo.Echo, app *App) { e.GET("/campaign/:campUUID/:subUUID/px.png", noIndex(validateUUID(handleRegisterCampaignView, "campUUID", "subUUID"))) - e.GET("/archive", handleCampaignArchivesPage) - e.GET("/archive.xml", handleGetCampaignArchivesFeed) - e.GET("/archive/:uuid", handleCampaignArchivePage) + if app.constants.EnablePublicArchive { + e.GET("/archive", handleCampaignArchivesPage) + e.GET("/archive.xml", handleGetCampaignArchivesFeed) + e.GET("/archive/:uuid", handleCampaignArchivePage) + } e.GET("/public/custom.css", serveCustomApperance("public.custom_css")) e.GET("/public/custom.js", serveCustomApperance("public.custom_js")) diff --git a/cmd/init.go b/cmd/init.go index c5011ea..8d38a28 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -56,6 +56,7 @@ type constants struct { FromEmail string `koanf:"from_email"` NotifyEmails []string `koanf:"notify_emails"` EnablePublicSubPage bool `koanf:"enable_public_subscription_page"` + EnablePublicArchive bool `koanf:"enable_public_archive"` SendOptinConfirmation bool `koanf:"send_optin_confirmation"` Lang string `koanf:"lang"` DBBatchSize int `koanf:"batch_size"` @@ -699,6 +700,7 @@ func initHTTPServer(app *App) *echo.Echo { LogoURL: app.constants.LogoURL, FaviconURL: app.constants.FaviconURL, EnablePublicSubPage: app.constants.EnablePublicSubPage, + EnablePublicArchive: app.constants.EnablePublicArchive, } // Initialize the static file server. diff --git a/cmd/public.go b/cmd/public.go index 89d5c99..3931a7b 100644 --- a/cmd/public.go +++ b/cmd/public.go @@ -31,6 +31,7 @@ type tplRenderer struct { LogoURL string FaviconURL string EnablePublicSubPage bool + EnablePublicArchive bool } // tplData is the data container that is injected @@ -41,6 +42,7 @@ type tplData struct { LogoURL string FaviconURL string EnablePublicSubPage bool + EnablePublicArchive bool Data interface{} L *i18n.I18n } @@ -92,6 +94,7 @@ func (t *tplRenderer) Render(w io.Writer, name string, data interface{}, c echo. LogoURL: t.LogoURL, FaviconURL: t.FaviconURL, EnablePublicSubPage: t.EnablePublicSubPage, + EnablePublicArchive: t.EnablePublicArchive, Data: data, L: c.Get("app").(*App).i18n, }) diff --git a/frontend/src/views/settings/general.vue b/frontend/src/views/settings/general.vue index d8d8fdb..839b100 100644 --- a/frontend/src/views/settings/general.vue +++ b/frontend/src/views/settings/general.vue @@ -44,14 +44,21 @@
-
+
-
+
+ + + +
+
{{ L.T "public.sub" }} {{ end }} - {{ if .EnablePublicSubPage }} + {{ if .EnablePublicArchive }} {{ L.T "public.archiveTitle" }} {{ end }}
diff --git a/static/public/templates/index.html b/static/public/templates/index.html index fe13f5c..69bf4c4 100644 --- a/static/public/templates/index.html +++ b/static/public/templates/index.html @@ -7,7 +7,10 @@ - + {{ if .EnablePublicArchive }} + + {{ end }} diff --git a/static/public/templates/subscription-form.html b/static/public/templates/subscription-form.html index dc54ff1..c2a629a 100644 --- a/static/public/templates/subscription-form.html +++ b/static/public/templates/subscription-form.html @@ -30,9 +30,12 @@

-

- {{ L.T "public.archiveTitle" }} -

+ + {{ if .EnablePublicArchive }} +

+ {{ L.T "public.archiveTitle" }} +

+ {{ end }}