aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorwinter2025-01-20 20:10:54 +0000
committerwinter2025-01-20 20:10:54 +0000
commit1b60d5ca77a387122bcf900c2972edca63403155 (patch)
tree0c7357d42dcee447c55ce205c055e4482e766d25
parent6830e97c22f7e72c08567d2497c0319ab73e6922 (diff)
settings tweaks and "about instance" page
-rw-r--r--Digitigrade/GlobalSettings.php11
-rw-r--r--locale/en_GB.json6
-rw-r--r--routes/about.php7
-rw-r--r--settings.global.ini13
-rw-r--r--static/misc.css36
-rw-r--r--static/skeleton.css3
-rw-r--r--templates/about_page.php24
-rw-r--r--templates/global_settings_page.php20
-rw-r--r--templates/left_side_navigation.php11
-rw-r--r--templates/settings_field.php9
10 files changed, 132 insertions, 8 deletions
diff --git a/Digitigrade/GlobalSettings.php b/Digitigrade/GlobalSettings.php
index 52c6582..79f25d3 100644
--- a/Digitigrade/GlobalSettings.php
+++ b/Digitigrade/GlobalSettings.php
@@ -104,6 +104,17 @@ class GlobalSettings extends Singleton {
}
/**
+ * Gets a list of all first-level prefixes.
+ * @return string[]
+ */
+ public function getAllPrefixes(): array {
+ return array_unique(array_map(
+ fn($x) => explode('.', $x, 2)[0],
+ array_keys($this->getAll())
+ ));
+ }
+
+ /**
* Gets information (name, description, default value) for a given setting.
* @param string $key which setting to look up
* @return ?array{item: string, value: string} associative array of info,
diff --git a/locale/en_GB.json b/locale/en_GB.json
index cb4df6a..91154b6 100644
--- a/locale/en_GB.json
+++ b/locale/en_GB.json
@@ -70,7 +70,11 @@
"followRequests.accepted": "Accepted!",
"followRequests.reject.action": "Reject",
"followRequests.rejected": "Rejected!",
- "globalSettings.pageTitle": "Global settings in category '%s'",
+ "globalSettings.pageTitle.instance": "Instance settings",
+ "globalSettings.pageTitle.about": "About this instance",
+ "globalSettings.categories": "Categories: ",
+ "about.pageTitle": "About this instance",
+ "about.terms.heading": "Rules and terms of use",
"form.edit": "Edit",
"form.saveChanges": "Save",
"form.discardChanges": "Cancel",
diff --git a/routes/about.php b/routes/about.php
new file mode 100644
index 0000000..3d51f70
--- /dev/null
+++ b/routes/about.php
@@ -0,0 +1,7 @@
+<?php
+
+use Digitigrade\Router;
+
+Router::getInstance()->mount('/about', function (array $args) {
+ render_template('about_page');
+}); \ No newline at end of file
diff --git a/settings.global.ini b/settings.global.ini
index dbad00e..7d4b392 100644
--- a/settings.global.ini
+++ b/settings.global.ini
@@ -10,9 +10,22 @@ default = "Digitigrade"
name = "Instance description"
description = "Briefly describe your instance's purpose or tagline"
default = "A Digitigrade instance"
+type = "longtext"
[instance.openRegistrations]
name = "Open registrations"
description = "Allow new users to sign up?"
default = "false"
type = "boolean"
+
+[about.description]
+name = "Description"
+description = "Describe your instance's purpose in more detail. You can use HTML formatting"
+default = ""
+type = "longtext"
+
+[about.terms]
+name = "Terms of use"
+description = "Policies and rules for users of this instance. You can use HTML formatting"
+default = ""
+type = "longtext"
diff --git a/static/misc.css b/static/misc.css
index 9bf9490..8902e95 100644
--- a/static/misc.css
+++ b/static/misc.css
@@ -80,6 +80,35 @@ span.unreadIndicator {
}
}
+.settingsCategories {
+ display: grid;
+ align-items: baseline;
+ margin: var(--spacing-double);
+ gap: var(--spacing-double);
+ grid-auto-flow: column;
+ justify-content: start;
+ ul {
+ display: block;
+ margin: 0;
+ margin-bottom: var(--spacing-double);
+ padding: 0;
+ list-style: none;
+ li {
+ display: inline-block;
+ a {
+ background: var(--clr-secondary);
+ color: var(--clr-foreground-on-secondary);
+ padding: var(--spacing-single) var(--spacing-double);
+ margin: var(--spacing-half);
+ width: max-content;
+ border-radius: var(--border-radius);
+ color: inherit;
+ text-decoration: none;
+ }
+ }
+ }
+}
+
.htmx-indicator {
visibility: hidden;
&.htmx-request {
@@ -91,6 +120,13 @@ pre {
font-family: inherit;
font-size: inherit;
text-wrap: wrap;
+ &.panel {
+ background: var(--clr-panel-background);
+ padding: var(--spacing-double);
+ margin: var(--spacing-double);
+ border: var(--border);
+ border-radius: var(--border-radius);
+ }
}
.temporaryIndicator {
diff --git a/static/skeleton.css b/static/skeleton.css
index 2d7b216..aeea3b2 100644
--- a/static/skeleton.css
+++ b/static/skeleton.css
@@ -159,7 +159,8 @@ main {
text-align: end;
}
-h1 {
+h1,
+h2 {
margin: var(--spacing-quadruple) var(--spacing-double);
padding: 0;
}
diff --git a/templates/about_page.php b/templates/about_page.php
new file mode 100644
index 0000000..fdfaaa3
--- /dev/null
+++ b/templates/about_page.php
@@ -0,0 +1,24 @@
+<?php
+use Digitigrade\GlobalSettings;
+
+
+call_template('skeleton', ['pageTitle' => __('about.pageTitle')], function () {
+ $s = GlobalSettings::getInstance();
+ $desc = $s->get('about.description') ?? '';
+ $terms = $s->get('about.terms') ?? '';
+ ?>
+
+ <?php if ($desc == ''): ?>
+ <?php call_template('placeholder_text'); ?>
+ <?php else: ?>
+ <pre class="panel"><?= $desc ?></pre>
+ <?php endif; ?>
+
+ <h2><?= __('about.terms.heading') ?></h2>
+ <?php if ($terms == ''): ?>
+ <?php call_template('placeholder_text'); ?>
+ <?php else: ?>
+ <pre class="panel"><?= $terms ?></pre>
+ <?php endif; ?>
+
+<?php }); \ No newline at end of file
diff --git a/templates/global_settings_page.php b/templates/global_settings_page.php
index fcaf7ab..06c1470 100644
--- a/templates/global_settings_page.php
+++ b/templates/global_settings_page.php
@@ -1,6 +1,22 @@
-<?php call_template('skeleton', [
- 'pageTitle' => sprintf(__('globalSettings.pageTitle'), $prefix)
+<?php
+use Digitigrade\GlobalSettings;
+
+call_template('skeleton', [
+ 'pageTitle' => sprintf(__("globalSettings.pageTitle.$prefix"), $prefix)
], function () {
global $prefix;
+ $s = GlobalSettings::getInstance();
+ ?>
+ <div class="settingsCategories">
+ <span><?= __('globalSettings.categories') ?></span>
+ <ul>
+ <?php foreach ($s->getAllPrefixes() as $p): ?>
+ <?php if ($p == 'settings')
+ continue; ?>
+ <li><a href="/admin/settings/<?= $p ?>"><?= $p ?></a></li>
+ <?php endforeach; ?>
+ </ul>
+ </div>
+ <?php
call_template('settings_editor', ['prefix' => $prefix]);
}); \ No newline at end of file
diff --git a/templates/left_side_navigation.php b/templates/left_side_navigation.php
index 983aa07..f03ee23 100644
--- a/templates/left_side_navigation.php
+++ b/templates/left_side_navigation.php
@@ -15,12 +15,19 @@ if ($user != null) {
if ($user->isAdmin) {
$links[] = ['href' => '/admin/settings/instance', 'icon' => 'settings', 'label' => __('navigation.instanceSettings')];
}
+}
+$links[] = [
+ 'href' => '/about',
+ 'icon' => 'info',
+ 'label' => __('about.pageTitle')
+];
+if ($user != null) {
$links[] = [
'href' => '/logout',
'icon' => 'logout',
'label' => __('navigation.logout'),
'confirmation' => __('navigation.logout.confirmation')
];
-
- call_template('side_navigation', ['links' => $links]);
}
+
+call_template('side_navigation', ['links' => $links]);
diff --git a/templates/settings_field.php b/templates/settings_field.php
index c0f0f7d..1ebbfb3 100644
--- a/templates/settings_field.php
+++ b/templates/settings_field.php
@@ -1,7 +1,8 @@
<?php
$id = "setting-$key";
-$inputType = 'text';
-if (($type ?? null) == 'boolean') {
+$settingType = $type ?? 'text';
+$inputType = $settingType;
+if ($settingType == 'boolean') {
$inputType = 'select';
$options = ['true', 'false'];
}
@@ -23,6 +24,10 @@ $fieldName = str_replace('.', '<DOT>', $key);
<?php endforeach; ?>
</select>
+ <?php elseif ($inputType == 'longtext'): ?>
+
+ <textarea id="<?= $id ?>" name="<?= $fieldName ?>" autocomplete="off"><?= $value ?></textarea>
+
<?php else: ?>
<input id="<?= $id ?>" name="<?= $fieldName ?>" value="<?= $value ?>" type="<?= $inputType ?>" autocomplete="off">