From f78002f915eeaaf455873106b289c96b8c4afb5d Mon Sep 17 00:00:00 2001 From: CDN Date: Wed, 18 Dec 2024 17:47:17 +0800 Subject: [PATCH] [bugfix] Load instance-wide custom css in page stylesheets template (#3601) * [bugfix] Load instance-wide custom css in page stylesheets template * [chore] remove redunt import --- internal/web/about.go | 2 +- internal/web/confirmemail.go | 5 ++--- internal/web/domain-blocklist.go | 2 +- internal/web/index.go | 2 +- internal/web/profile.go | 1 - internal/web/settings-panel.go | 1 - internal/web/signup.go | 7 +++---- internal/web/tag.go | 2 +- internal/web/thread.go | 1 - web/template/page_stylesheets.tmpl | 6 ++++++ 10 files changed, 15 insertions(+), 14 deletions(-) diff --git a/internal/web/about.go b/internal/web/about.go index 843dda652..2bc558962 100644 --- a/internal/web/about.go +++ b/internal/web/about.go @@ -54,7 +54,7 @@ func (m *Module) aboutGETHandler(c *gin.Context) { Template: "about.tmpl", Instance: instance, OGMeta: apiutil.OGBase(instance), - Stylesheets: []string{cssAbout, instanceCustomCSSPath}, + Stylesheets: []string{cssAbout}, Extra: map[string]any{ "showStrap": true, "blocklistExposed": config.GetInstanceExposeSuspendedWeb(), diff --git a/internal/web/confirmemail.go b/internal/web/confirmemail.go index 21028c6c4..e512761f4 100644 --- a/internal/web/confirmemail.go +++ b/internal/web/confirmemail.go @@ -127,9 +127,8 @@ func (m *Module) confirmEmailPOSTHandler(c *gin.Context) { // Serve page informing user that their // email address is now confirmed. page := apiutil.WebPage{ - Template: "confirmed_email.tmpl", - Instance: instance, - Stylesheets: []string{instanceCustomCSSPath}, + Template: "confirmed_email.tmpl", + Instance: instance, Extra: map[string]any{ "email": user.Email, "username": user.Account.Username, diff --git a/internal/web/domain-blocklist.go b/internal/web/domain-blocklist.go index 7b6710049..5d631e0f7 100644 --- a/internal/web/domain-blocklist.go +++ b/internal/web/domain-blocklist.go @@ -67,7 +67,7 @@ func (m *Module) domainBlockListGETHandler(c *gin.Context) { Template: "domain-blocklist.tmpl", Instance: instance, OGMeta: apiutil.OGBase(instance), - Stylesheets: []string{cssFA, instanceCustomCSSPath}, + Stylesheets: []string{cssFA}, Javascript: []string{jsFrontend}, Extra: map[string]any{"blocklist": domainBlocks}, } diff --git a/internal/web/index.go b/internal/web/index.go index dd9d80561..25960cf7f 100644 --- a/internal/web/index.go +++ b/internal/web/index.go @@ -59,7 +59,7 @@ func (m *Module) indexHandler(c *gin.Context) { Template: "index.tmpl", Instance: instance, OGMeta: apiutil.OGBase(instance), - Stylesheets: []string{cssAbout, cssIndex, instanceCustomCSSPath}, + Stylesheets: []string{cssAbout, cssIndex}, Extra: map[string]any{"showStrap": true}, } diff --git a/internal/web/profile.go b/internal/web/profile.go index 741dc2a83..a6d96a9ea 100644 --- a/internal/web/profile.go +++ b/internal/web/profile.go @@ -142,7 +142,6 @@ func (m *Module) profileGETHandler(c *gin.Context) { cssStatus, cssThread, cssProfile, - instanceCustomCSSPath, }..., ) diff --git a/internal/web/settings-panel.go b/internal/web/settings-panel.go index 41cd8666e..ec8166e95 100644 --- a/internal/web/settings-panel.go +++ b/internal/web/settings-panel.go @@ -53,7 +53,6 @@ func (m *Module) SettingsPanelHandler(c *gin.Context) { cssProfile, // Used for rendering stub/fake profiles. cssStatus, // Used for rendering stub/fake statuses. cssSettings, - instanceCustomCSSPath, }, Javascript: []string{jsSettings}, } diff --git a/internal/web/signup.go b/internal/web/signup.go index 64b9f4e2d..a943f3680 100644 --- a/internal/web/signup.go +++ b/internal/web/signup.go @@ -126,10 +126,9 @@ func (m *Module) signupPOSTHandler(c *gin.Context) { // Serve a page informing the // user that they've signed up. page := apiutil.WebPage{ - Template: "signed-up.tmpl", - Instance: instance, - Stylesheets: []string{instanceCustomCSSPath}, - OGMeta: apiutil.OGBase(instance), + Template: "signed-up.tmpl", + Instance: instance, + OGMeta: apiutil.OGBase(instance), Extra: map[string]any{ "email": user.UnconfirmedEmail, "username": user.Account.Username, diff --git a/internal/web/tag.go b/internal/web/tag.go index 423000f99..5c3cd31a6 100644 --- a/internal/web/tag.go +++ b/internal/web/tag.go @@ -59,7 +59,7 @@ func (m *Module) tagGETHandler(c *gin.Context) { Template: "tag.tmpl", Instance: instance, OGMeta: apiutil.OGBase(instance), - Stylesheets: []string{cssFA, cssThread, cssTag, instanceCustomCSSPath}, + Stylesheets: []string{cssFA, cssThread, cssTag}, Extra: map[string]any{"tagName": tagName}, } diff --git a/internal/web/thread.go b/internal/web/thread.go index 557e00381..60f7ac4d2 100644 --- a/internal/web/thread.go +++ b/internal/web/thread.go @@ -124,7 +124,6 @@ func (m *Module) threadGETHandler(c *gin.Context) { cssFA, cssStatus, cssThread, - instanceCustomCSSPath, }..., ) diff --git a/web/template/page_stylesheets.tmpl b/web/template/page_stylesheets.tmpl index 9234607f8..9ccc65c13 100644 --- a/web/template/page_stylesheets.tmpl +++ b/web/template/page_stylesheets.tmpl @@ -32,10 +32,16 @@ {{- range .stylesheets }} {{- end }} +{{- if .instance.CustomCSS }} + +{{- end }} {{- range .stylesheets }} {{- end }} +{{- if .instance.CustomCSS }} + +{{- end }} {{- end }} \ No newline at end of file