From 2db6c33a410202eb441352dba53632db9540fdc9 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Mon, 2 Mar 2020 16:34:44 -0600 Subject: [PATCH] Consolidate /signup page link logic This moves logic for determining whether or not to show a "Sign up" page on /signup (i.e. because the `/` route shows another, non-signup page) into the AppCfg.SignupPath() method. It also changes various signup links to use this value. --- config/config.go | 10 ++++++++++ pages/login.tmpl | 2 +- templates/base.tmpl | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index 78892bf..a616401 100644 --- a/config/config.go +++ b/config/config.go @@ -183,6 +183,16 @@ func (ac *AppCfg) LandingPath() string { return ac.Landing } +func (ac AppCfg) SignupPath() string { + if !ac.OpenRegistration { + return "" + } + if ac.Chorus || ac.Private || (ac.Landing != "" && ac.Landing != "/") { + return "/signup" + } + return "/" +} + // Load reads the given configuration file, then parses and returns it as a Config. func Load(fname string) (*Config, error) { if fname == "" { diff --git a/pages/login.tmpl b/pages/login.tmpl index 345b171..79875c6 100644 --- a/pages/login.tmpl +++ b/pages/login.tmpl @@ -65,7 +65,7 @@ hr.short { - {{if and (not .SingleUser) .OpenRegistration}}

{{if .Message}}{{.Message}}{{else}}No account yet? Sign up to start a blog.{{end}}

{{end}} + {{if and (not .SingleUser) .OpenRegistration}}

{{if .Message}}{{.Message}}{{else}}No account yet? Sign up to start a blog.{{end}}

{{end}}