diff --git a/assets/js/custom.js b/assets/js/custom.js index b174611..58db353 100644 --- a/assets/js/custom.js +++ b/assets/js/custom.js @@ -1 +1,22 @@ // Put your custom JS code here + +// self-hosting view. +const getSelfhost = () => { + return localStorage.getItem('selfhost') || 'no'; +}; + +const setSelfhost = (selfhost) => { + localStorage.setItem('selfhost', selfhost); + document.documentElement.setAttribute('data-selfhost', selfhost); +}; + +setSelfhost(getSelfhost()); + +window.addEventListener('DOMContentLoaded', () => { + document.querySelectorAll('[data-selfhost-value]').forEach((element) => { + element.addEventListener('click', (event) => { + const selfhost = element.getAttribute('data-selfhost-value'); + setSelfhost(selfhost); + }); + } +)}); diff --git a/assets/scss/common/_custom.scss b/assets/scss/common/_custom.scss index d5ae54d..cfee50e 100644 --- a/assets/scss/common/_custom.scss +++ b/assets/scss/common/_custom.scss @@ -147,6 +147,32 @@ pre.shiki { opacity: var(--ec-frm-inlBtnBgActOpa); } +// show active server if self-hosting view enabled +html[data-selfhost="yes"] { + .icon-tabler-server { + display: block; + } + + .icon-tabler-server-off { + display: none; + } +} + +// hide active server if self-hosting view disabled +html[data-selfhost="no"] { + .icon-tabler-server { + display: none; + } + + .icon-tabler-server-off { + display: block; + } + + .selfhosting { + display: none; + } +} + @media (hover: hover) { .highlight .copy button { opacity: 0; diff --git a/config/postcss.config.js b/config/postcss.config.js index 1bbd8ec..3b1e981 100644 --- a/config/postcss.config.js +++ b/config/postcss.config.js @@ -26,6 +26,7 @@ module.exports = { 'data-global-alert', 'data-pane', // tabs.js 'data-popper-placement', + 'data-selfhost', 'data-sizes', 'data-toggle-tab', // tabs.js 'id', diff --git a/content/docs/moderation/logging.md b/content/docs/moderation/logging.md index a5d2176..7496f67 100644 --- a/content/docs/moderation/logging.md +++ b/content/docs/moderation/logging.md @@ -28,7 +28,7 @@ contains an embed, it is serialized and saved in JSON format. Message logs on the official YAGPDB instance will be automatically deleted after 30 days of their creation. -If you're self-hosting, see [Message Log Purge](#message-log-purge-self-hosting-only) for more information. +If you're self-hosting, see [Message Log Purge](#message-log-purge) for more information. {{< /callout >}} @@ -114,8 +114,12 @@ channels. Users with write access to the control panel may delete individual logs or delete all logs on the server using the control panel. -## Message Log Purge [Self-hosting only] +{{< selfhosting >}} + +## Message Log Purge If you are self-hosting your own instance of YAGPDB, you can set `enable_message_log_purge=true` to automatically purge message logs older than 30 days. This option is enabled on the official instance of YAGPDB hosted by Botlabs but is disabled by default on a fresh self-host. + +{{< /selfhosting >}} diff --git a/content/docs/moderation/verification.md b/content/docs/moderation/verification.md index b4c2824..08814c8 100644 --- a/content/docs/moderation/verification.md +++ b/content/docs/moderation/verification.md @@ -97,6 +97,8 @@ If a new user who verifies is detected as an alt but none of their associated ac send a log to the verification log channel if specified, identifying the new user as an alt and listing other users who verified at the same IP address. +{{< selfhosting >}} + ### Disable Alt Detection Globally For self hosters, the environment variable to enable this feature is `verification.track_ips`. It is `true` by default. @@ -112,3 +114,5 @@ Do not proceed unless you are hosting your own version of the YAGPDB codebase. Verification requires the `google.recaptcha_secret` and `google.recaptcha_site_key` env variables to be configured and valid. To get a reCAPTCHA secret and site key, [register a site on reCAPTCHA](https://www.google.com/recaptcha/admin/create) and copy the generated secret and key. + +{{< /selfhosting >}} diff --git a/content/docs/welcome/premium.md b/content/docs/welcome/premium.md index 957d9fc..06bf8c2 100644 --- a/content/docs/welcome/premium.md +++ b/content/docs/welcome/premium.md @@ -127,6 +127,8 @@ You can assign your premium slots to any server with YAGPDB in it and no existin ![Redeemed Premium Slots](slots_premium.png) +{{< selfhosting >}} + ## Self Hosting YAGPDB Do not proceed unless you are hosting your own version of the YAGPDB codebase. @@ -153,3 +155,5 @@ recommended you familiarize yourself with the codebase before making changes. Fi defined and alter their values as you wish. ![Example of limit definitions in Advanced Automoderator](limits_example.png) + +{{< /selfhosting >}} diff --git a/layouts/partials/header/header.html b/layouts/partials/header/header.html index 6847d2b..ae88e56 100644 --- a/layouts/partials/header/header.html +++ b/layouts/partials/header/header.html @@ -272,6 +272,24 @@
{{ .Site.Params.T {{ end -}} + + {{ if site.Params.doks.navBarButton -}} diff --git a/layouts/shortcodes/selfhosting.html b/layouts/shortcodes/selfhosting.html new file mode 100644 index 0000000..c8b8161 --- /dev/null +++ b/layouts/shortcodes/selfhosting.html @@ -0,0 +1,4 @@ +{{/* wraps the inner content in a div with a class of "selfhosting", such that it can be conditionally hidden by some JS code. */}} +
+ {{ .Inner | $.Page.RenderString }} +