summaryrefslogtreecommitdiff
path: root/internal/web/customcss.go
diff options
context:
space:
mode:
authorLibravatar Victor Dyotte <vdyotte@gmail.com>2024-12-02 06:24:48 -0500
committerLibravatar GitHub <noreply@github.com>2024-12-02 12:24:48 +0100
commit9609c4550d0cf6010ab88357fb5636e42ad22ba7 (patch)
tree2c339976192013aa79d164de90104ba3ca990a84 /internal/web/customcss.go
parent[feature/themes] Add auto-switching themes for blurple/brutalist/solarized (#... (diff)
downloadgotosocial-9609c4550d0cf6010ab88357fb5636e42ad22ba7.tar.xz
[feature] Add global instance CSS customization setting (#3352)
Allow instance admins to add custom CSS that will affect every page of their instance. This is done with a new CustomCSS instance setting that works pretty much exactly like the Users CustomCSS property. This custom CSS is then requested for every page load. User styles/themes take precedence over this CSS. Co-authored-by: tobi <tobi.smethurst@protonmail.com>
Diffstat (limited to 'internal/web/customcss.go')
-rw-r--r--internal/web/customcss.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/internal/web/customcss.go b/internal/web/customcss.go
index b4072f2a7..36ae9de55 100644
--- a/internal/web/customcss.go
+++ b/internal/web/customcss.go
@@ -55,3 +55,22 @@ func (m *Module) customCSSGETHandler(c *gin.Context) {
c.Header(cacheControlHeader, cacheControlNoCache)
c.Data(http.StatusOK, textCSSUTF8, []byte(customCSS))
}
+
+func (m *Module) instanceCustomCSSGETHandler(c *gin.Context) {
+
+ if _, err := apiutil.NegotiateAccept(c, apiutil.TextCSS); err != nil {
+ apiutil.WebErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
+ return
+ }
+
+ instanceV1, errWithCode := m.processor.InstanceGetV1(c.Request.Context())
+ if errWithCode != nil {
+ apiutil.WebErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
+ return
+ }
+
+ instanceCustomCSS := instanceV1.CustomCSS
+
+ c.Header(cacheControlHeader, cacheControlNoCache)
+ c.Data(http.StatusOK, textCSSUTF8, []byte(instanceCustomCSS))
+}