aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorwinter2025-05-03 16:34:03 +0100
committerwinter2025-05-03 16:34:03 +0100
commit2f3377290a9478aff1c43558167fe8566787bc3a (patch)
tree2d61d2d97fea8352d1aadbd8d97ff1f7186ccde6
parent0310ab4e341365071d62e5449b31614022034b60 (diff)
add customisation setting for instance-wide css
-rw-r--r--locale/en_GB.json3
-rw-r--r--locale/en_US.json3
-rw-r--r--routes/customisation.php9
-rw-r--r--settings.global.ini4
-rw-r--r--static/form.css3
-rw-r--r--static/misc.css1
-rw-r--r--templates/head_tags.php1
-rw-r--r--templates/settings_field.php4
8 files changed, 27 insertions, 1 deletions
diff --git a/locale/en_GB.json b/locale/en_GB.json
index 59e6599..7c7b61f 100644
--- a/locale/en_GB.json
+++ b/locale/en_GB.json
@@ -189,6 +189,7 @@
"admin.plugins.download.action": "Download",
"globalSettings.category.instance": "Instance settings",
"globalSettings.category.about": "About this instance",
+ "globalSettings.category.customisation": "Customisation",
"globalSettings.categories": "Categories: ",
"globalSettings.s.instance.name.name": "Instance name",
"globalSettings.s.instance.name.description": "Shown in the page header and instance information",
@@ -200,6 +201,8 @@
"globalSettings.s.about.description.description": "Describe your instance's purpose in more detail. You can use HTML formatting",
"globalSettings.s.about.terms.name": "Terms of use",
"globalSettings.s.about.terms.description": "Policies and rules for users of this instance. You can use HTML formatting",
+ "globalSettings.s.customisation.instanceCss.name": "Custom CSS",
+ "globalSettings.s.customisation.instanceCss.description": "Applied to all pages for all users on this instance",
"about.pageTitle": "About this instance",
"about.terms.heading": "Rules and terms of use",
"form.edit": "Edit",
diff --git a/locale/en_US.json b/locale/en_US.json
index 0c1c01b..7a9492d 100644
--- a/locale/en_US.json
+++ b/locale/en_US.json
@@ -1,3 +1,4 @@
{
- "FALLBACK": "en_GB"
+ "FALLBACK": "en_GB",
+ "globalSettings.category.customisation": "Customization"
}
diff --git a/routes/customisation.php b/routes/customisation.php
new file mode 100644
index 0000000..536684f
--- /dev/null
+++ b/routes/customisation.php
@@ -0,0 +1,9 @@
+<?php
+
+use Digitigrade\GlobalSettings;
+use Digitigrade\Router;
+
+Router::getInstance()->mount('/instance-style.css', function () {
+ header('Content-Type: text/css');
+ echo GlobalSettings::getInstance()->get('customisation.instanceCss') ?? '';
+}); \ No newline at end of file
diff --git a/settings.global.ini b/settings.global.ini
index 9a0269c..baa4b53 100644
--- a/settings.global.ini
+++ b/settings.global.ini
@@ -19,3 +19,7 @@ type = "longtext"
[about.terms]
default = ""
type = "longtext"
+
+[customisation.instanceCss]
+default = ""
+type = "code"
diff --git a/static/form.css b/static/form.css
index fea9697..5b8f246 100644
--- a/static/form.css
+++ b/static/form.css
@@ -54,6 +54,9 @@ form:not(.nopanel) {
resize: vertical;
height: 5lh;
}
+ textarea.codeEdit {
+ font-family: monospace;
+ }
button:not(.inline) {
width: 100%;
}
diff --git a/static/misc.css b/static/misc.css
index f2d0555..8b619b9 100644
--- a/static/misc.css
+++ b/static/misc.css
@@ -110,6 +110,7 @@ span.unreadIndicator {
li {
display: inline-block;
a {
+ display: block;
background: var(--clr-secondary);
color: var(--clr-foreground-on-secondary);
padding: var(--spacing-single) var(--spacing-double);
diff --git a/templates/head_tags.php b/templates/head_tags.php
index 395b707..9f9cb1c 100644
--- a/templates/head_tags.php
+++ b/templates/head_tags.php
@@ -1,4 +1,5 @@
<link rel="stylesheet" href="/static/style.css">
+<link rel="stylesheet" href="/instance-style.css">
<link rel="stylesheet" href="https://fonts.bunny.net/css?family=nunito-sans:400,400i,800,800i">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#3b005e">
diff --git a/templates/settings_field.php b/templates/settings_field.php
index f9de886..b58892d 100644
--- a/templates/settings_field.php
+++ b/templates/settings_field.php
@@ -34,6 +34,10 @@ $fieldName ??= str_replace('.', '<DOT>', $key);
<textarea id="<?= $id ?>" name="<?= $fieldName ?>" autocomplete="off"><?= $value ?></textarea>
+ <?php elseif ($inputType == 'code'): ?>
+
+ <textarea id="<?= $id ?>" name="<?= $fieldName ?>" autocomplete="off" class="codeEdit"><?= $value ?></textarea>
+
<?php else: ?>
<input id="<?= $id ?>" name="<?= $fieldName ?>" value="<?= $value ?>" type="<?= $inputType ?>" autocomplete="off">