[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
This commit is contained in:
CDN 2024-12-18 17:47:17 +08:00 committed by GitHub
parent eb77ceeed6
commit f78002f915
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 15 additions and 14 deletions

View file

@ -54,7 +54,7 @@ func (m *Module) aboutGETHandler(c *gin.Context) {
Template: "about.tmpl", Template: "about.tmpl",
Instance: instance, Instance: instance,
OGMeta: apiutil.OGBase(instance), OGMeta: apiutil.OGBase(instance),
Stylesheets: []string{cssAbout, instanceCustomCSSPath}, Stylesheets: []string{cssAbout},
Extra: map[string]any{ Extra: map[string]any{
"showStrap": true, "showStrap": true,
"blocklistExposed": config.GetInstanceExposeSuspendedWeb(), "blocklistExposed": config.GetInstanceExposeSuspendedWeb(),

View file

@ -129,7 +129,6 @@ func (m *Module) confirmEmailPOSTHandler(c *gin.Context) {
page := apiutil.WebPage{ page := apiutil.WebPage{
Template: "confirmed_email.tmpl", Template: "confirmed_email.tmpl",
Instance: instance, Instance: instance,
Stylesheets: []string{instanceCustomCSSPath},
Extra: map[string]any{ Extra: map[string]any{
"email": user.Email, "email": user.Email,
"username": user.Account.Username, "username": user.Account.Username,

View file

@ -67,7 +67,7 @@ func (m *Module) domainBlockListGETHandler(c *gin.Context) {
Template: "domain-blocklist.tmpl", Template: "domain-blocklist.tmpl",
Instance: instance, Instance: instance,
OGMeta: apiutil.OGBase(instance), OGMeta: apiutil.OGBase(instance),
Stylesheets: []string{cssFA, instanceCustomCSSPath}, Stylesheets: []string{cssFA},
Javascript: []string{jsFrontend}, Javascript: []string{jsFrontend},
Extra: map[string]any{"blocklist": domainBlocks}, Extra: map[string]any{"blocklist": domainBlocks},
} }

View file

@ -59,7 +59,7 @@ func (m *Module) indexHandler(c *gin.Context) {
Template: "index.tmpl", Template: "index.tmpl",
Instance: instance, Instance: instance,
OGMeta: apiutil.OGBase(instance), OGMeta: apiutil.OGBase(instance),
Stylesheets: []string{cssAbout, cssIndex, instanceCustomCSSPath}, Stylesheets: []string{cssAbout, cssIndex},
Extra: map[string]any{"showStrap": true}, Extra: map[string]any{"showStrap": true},
} }

View file

@ -142,7 +142,6 @@ func (m *Module) profileGETHandler(c *gin.Context) {
cssStatus, cssStatus,
cssThread, cssThread,
cssProfile, cssProfile,
instanceCustomCSSPath,
}..., }...,
) )

View file

@ -53,7 +53,6 @@ func (m *Module) SettingsPanelHandler(c *gin.Context) {
cssProfile, // Used for rendering stub/fake profiles. cssProfile, // Used for rendering stub/fake profiles.
cssStatus, // Used for rendering stub/fake statuses. cssStatus, // Used for rendering stub/fake statuses.
cssSettings, cssSettings,
instanceCustomCSSPath,
}, },
Javascript: []string{jsSettings}, Javascript: []string{jsSettings},
} }

View file

@ -128,7 +128,6 @@ func (m *Module) signupPOSTHandler(c *gin.Context) {
page := apiutil.WebPage{ page := apiutil.WebPage{
Template: "signed-up.tmpl", Template: "signed-up.tmpl",
Instance: instance, Instance: instance,
Stylesheets: []string{instanceCustomCSSPath},
OGMeta: apiutil.OGBase(instance), OGMeta: apiutil.OGBase(instance),
Extra: map[string]any{ Extra: map[string]any{
"email": user.UnconfirmedEmail, "email": user.UnconfirmedEmail,

View file

@ -59,7 +59,7 @@ func (m *Module) tagGETHandler(c *gin.Context) {
Template: "tag.tmpl", Template: "tag.tmpl",
Instance: instance, Instance: instance,
OGMeta: apiutil.OGBase(instance), OGMeta: apiutil.OGBase(instance),
Stylesheets: []string{cssFA, cssThread, cssTag, instanceCustomCSSPath}, Stylesheets: []string{cssFA, cssThread, cssTag},
Extra: map[string]any{"tagName": tagName}, Extra: map[string]any{"tagName": tagName},
} }

View file

@ -124,7 +124,6 @@ func (m *Module) threadGETHandler(c *gin.Context) {
cssFA, cssFA,
cssStatus, cssStatus,
cssThread, cssThread,
instanceCustomCSSPath,
}..., }...,
) )

View file

@ -32,10 +32,16 @@
{{- range .stylesheets }} {{- range .stylesheets }}
<link rel="preload" href="{{- . -}}" as="style"> <link rel="preload" href="{{- . -}}" as="style">
{{- end }} {{- end }}
{{- if .instance.CustomCSS }}
<link rel="preload" href="/custom.css" as="style">
{{- end }}
<link rel="stylesheet" href="/assets/dist/_colors.css"> <link rel="stylesheet" href="/assets/dist/_colors.css">
<link rel="stylesheet" href="/assets/dist/base.css"> <link rel="stylesheet" href="/assets/dist/base.css">
<link rel="stylesheet" href="/assets/dist/page.css"> <link rel="stylesheet" href="/assets/dist/page.css">
{{- range .stylesheets }} {{- range .stylesheets }}
<link rel="stylesheet" href="{{- . -}}"> <link rel="stylesheet" href="{{- . -}}">
{{- end }} {{- end }}
{{- if .instance.CustomCSS }}
<link rel="stylesheet" href="/custom.css">
{{- end }}
{{- end }} {{- end }}