From 23fb178ec46c0a174ca02fde2dc7b77f4b927330 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Wed, 9 Nov 2022 22:24:34 +0530 Subject: [PATCH] Add subscription/archive links to public pages. --- cmd/init.go | 10 +++--- cmd/public.go | 31 ++++++++++--------- static/public/static/style.css | 6 +++- static/public/templates/archive.html | 6 ++++ static/public/templates/index.html | 4 ++- .../public/templates/subscription-form.html | 5 ++- 6 files changed, 41 insertions(+), 21 deletions(-) diff --git a/cmd/init.go b/cmd/init.go index 8bfad4b..a503c75 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -692,10 +692,12 @@ func initHTTPServer(app *App) *echo.Echo { lo.Fatalf("error parsing public templates: %v", err) } srv.Renderer = &tplRenderer{ - templates: tpl, - RootURL: app.constants.RootURL, - LogoURL: app.constants.LogoURL, - FaviconURL: app.constants.FaviconURL} + templates: tpl, + RootURL: app.constants.RootURL, + LogoURL: app.constants.LogoURL, + FaviconURL: app.constants.FaviconURL, + EnablePublicSubPage: app.constants.EnablePublicSubPage, + } // Initialize the static file server. fSrv := app.fs.FileServer() diff --git a/cmd/public.go b/cmd/public.go index 15c076d..ea764ed 100644 --- a/cmd/public.go +++ b/cmd/public.go @@ -25,20 +25,22 @@ const ( // tplRenderer wraps a template.tplRenderer for echo. type tplRenderer struct { - templates *template.Template - RootURL string - LogoURL string - FaviconURL string + templates *template.Template + RootURL string + LogoURL string + FaviconURL string + EnablePublicSubPage bool } // tplData is the data container that is injected // into public templates for accessing data. type tplData struct { - RootURL string - LogoURL string - FaviconURL string - Data interface{} - L *i18n.I18n + RootURL string + LogoURL string + FaviconURL string + EnablePublicSubPage bool + Data interface{} + L *i18n.I18n } type publicTpl struct { @@ -83,11 +85,12 @@ var ( // Render executes and renders a template for echo. func (t *tplRenderer) Render(w io.Writer, name string, data interface{}, c echo.Context) error { return t.templates.ExecuteTemplate(w, name, tplData{ - RootURL: t.RootURL, - LogoURL: t.LogoURL, - FaviconURL: t.FaviconURL, - Data: data, - L: c.Get("app").(*App).i18n, + RootURL: t.RootURL, + LogoURL: t.LogoURL, + FaviconURL: t.FaviconURL, + EnablePublicSubPage: t.EnablePublicSubPage, + Data: data, + L: c.Get("app").(*App).i18n, }) } diff --git a/static/public/static/style.css b/static/public/static/style.css index 7bf7330..372b10d 100644 --- a/static/public/static/style.css +++ b/static/public/static/style.css @@ -15,6 +15,7 @@ body { } a { color: #0055d4; + text-decoration-color: #abcbfb; } a:hover { color: #111; @@ -57,6 +58,9 @@ input[disabled] { .center { text-align: center; } +.right { + text-align: right; +} .button { background: #0055d4; padding: 15px 30px; @@ -145,7 +149,7 @@ input[disabled] { font-size: 0.875em; } .archive li { - margin-bottom: 10px; + margin-bottom: 15px; } .pagination { diff --git a/static/public/templates/archive.html b/static/public/templates/archive.html index 92556e2..0403ac0 100644 --- a/static/public/templates/archive.html +++ b/static/public/templates/archive.html @@ -16,6 +16,12 @@ {{ L.T "public.archiveEmpty" }} {{ end }} + {{ if .EnablePublicSubPage }} +

+ Subscribe +

+ {{ end }} + {{ if gt .Data.TotalPages 1 }} {{ end }} diff --git a/static/public/templates/index.html b/static/public/templates/index.html index d310d92..ce16106 100644 --- a/static/public/templates/index.html +++ b/static/public/templates/index.html @@ -20,11 +20,13 @@
{{ end }} diff --git a/static/public/templates/subscription-form.html b/static/public/templates/subscription-form.html index e45c223..dc54ff1 100644 --- a/static/public/templates/subscription-form.html +++ b/static/public/templates/subscription-form.html @@ -1,5 +1,5 @@ {{ define "subscription-form" }} -{{ template "header" .}} +{{ template "header" . }}

{{ L.T "public.subTitle" }}

@@ -30,6 +30,9 @@

+

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