Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: optionally show "Powered by Discourse" link to discourse.org (#26162)

Kris9376a2e755dd
diff --git a/app/assets/javascripts/discourse/app/components/powered-by-discourse.gjs b/app/assets/javascripts/discourse/app/components/powered-by-discourse.gjs
new file mode 100644
index 00000000000..ee20e6151f7
--- /dev/null
+++ b/app/assets/javascripts/discourse/app/components/powered-by-discourse.gjs
@@ -0,0 +1,15 @@
+import icon from "discourse-common/helpers/d-icon";
+import i18n from "discourse-common/helpers/i18n";
+
+const PoweredByDiscourse = <template>
+ <a class="powered-by-discourse" href="https://discourse.org">
+ <span class="powered-by-discourse__content">
+ <span class="powered-by-discourse__logo">
+ {{icon "fab-discourse"}}
+ </span>
+ <span>{{i18n "powered_by_discourse"}}</span>
+ </span>
+ </a>
+</template>;
+
+export default PoweredByDiscourse;
diff --git a/app/assets/javascripts/discourse/app/controllers/application.js b/app/assets/javascripts/discourse/app/controllers/application.js
index 5d35d7776e6..4f94116e354 100644
--- a/app/assets/javascripts/discourse/app/controllers/application.js
+++ b/app/assets/javascripts/discourse/app/controllers/application.js
@@ -59,6 +59,11 @@ export default Controller.extend({
return this.capabilities.isAppWebview || this.capabilities.isiOSPWA;
},
+ @discourseComputed
+ showPoweredBy() {
+ return this.showFooter && this.siteSettings.enable_powered_by_discourse;
+ },
+
_mainOutletAnimate() {
document.body.classList.remove("sidebar-animate");
},
diff --git a/app/assets/javascripts/discourse/app/templates/application.hbs b/app/assets/javascripts/discourse/app/templates/application.hbs
index 765aba5d480..222cee64d60 100644
--- a/app/assets/javascripts/discourse/app/templates/application.hbs
+++ b/app/assets/javascripts/discourse/app/templates/application.hbs
@@ -87,6 +87,10 @@
</div>
<PluginOutlet @name="after-main-outlet" />
+
+ {{#if this.showPoweredBy}}
+ <PoweredByDiscourse />
+ {{/if}}
</div>
<PluginOutlet
diff --git a/app/assets/stylesheets/common/components/_index.scss b/app/assets/stylesheets/common/components/_index.scss
index c59c6645d37..b151bc5cfbd 100644
--- a/app/assets/stylesheets/common/components/_index.scss
+++ b/app/assets/stylesheets/common/components/_index.scss
@@ -28,6 +28,7 @@
@import "navs";
@import "offline-indicator";
@import "pick-files-button";
+@import "powered-by-discourse";
@import "relative-time-picker";
@import "add-pm-participants";
@import "download-calendar";
diff --git a/app/assets/stylesheets/common/components/powered-by-discourse.scss b/app/assets/stylesheets/common/components/powered-by-discourse.scss
new file mode 100644
index 00000000000..6eb68e9ea93
--- /dev/null
+++ b/app/assets/stylesheets/common/components/powered-by-discourse.scss
@@ -0,0 +1,73 @@
+.powered-by-discourse {
+ .admin-area &,
+ .has-full-page-chat &,
+ .static-login &,
+ .invite-page & {
+ display: none !important;
+ }
+ grid-area: below-content;
+ justify-self: start;
+ font-size: var(--font-down-1);
+ letter-spacing: 0.2px; // extra spacing makes small text easier to read
+ padding: 2px; // animated hover "border" width
+ background: var(--secondary);
+ border-radius: 0.75em;
+ transition: all 0.25s ease-in-out;
+ margin-bottom: 0.45em;
+ color: var(--primary-medium);
+
+ &:visited {
+ color: var(--primary-medium);
+ }
+
+ &__content {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.5em;
+ color: currentColor;
+ background: var(--secondary);
+ border-radius: 0.62em;
+ padding: 0.25em 0.65em 0.25em 0.5em;
+ }
+
+ .d-icon {
+ position: relative;
+ top: 0.05em; // vertical alignment
+ }
+
+ .discourse-no-touch & {
+ &:hover {
+ color: var(--primary-high);
+ @media (prefers-reduced-motion: no-preference) {
+ // secondary repeat is an intentional buffer
+ background: linear-gradient(
+ 45deg,
+ var(--secondary),
+ var(--secondary),
+ var(--secondary),
+ var(--secondary),
+ var(--secondary),
+ #d0232b,
+ #f15d22,
+ #fff9ae,
+ #00a94f,
+ #00aeef
+ );
+ background-size: 300%;
+ animation: d-rainbow-shimmer 0.5s;
+ animation-fill-mode: forwards;
+ animation-timing-function: ease-in-out;
+ animation-delay: 0.15s; // avoid animating on passing hover
+ }
+ }
+
+ @keyframes d-rainbow-shimmer {
+ 0% {
+ background-position: 0% 50%;
+ }
+ 100% {
+ background-position: 100% 50%;
+ }
+ }
+ }
+}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index af8d7de540a..8c9c253d680 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -4802,6 +4802,7 @@ en:
copy: "Copy..."
paste: "Paste..."
save: "Save as..."
+ powered_by_discourse: "Powered by Discourse"
# This section is exported to the javascript for i18n in the admin section
admin_js:
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 415ec416a0e..434dbcd9d7a 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -2332,6 +2332,8 @@ en:
share_anonymized_statistics: "Enable sharing of anonymized usage statistics with CDCK, Inc. (“Discourse”). When this setting is enabled, data concerning the usage of the site is collected and shared in anonymized form, ensuring no personal information is disclosed."
+ enable_powered_by_discourse: "Show “Powered by Discourse” link to discourse.org at the bottom of most pages."
+
auto_handle_queued_age: "Automatically handle records that are waiting to be reviewed after this many days. Flags will be ignored. Queued posts and users will be rejected. Set to 0 to disable this feature."
penalty_step_hours: "Default penalties for silencing or suspending users in hours. First offense defaults to the first value, second offense defaults to the second value, etc."
penalty_include_post_message: "Automatically include offending post message in email message template when silencing or suspending a user"
diff --git a/config/site_settings.yml b/config/site_settings.yml
index b5c4849063c..0b91bd188c4 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -2818,6 +2818,10 @@ uncategorized:
share_anonymized_statistics: true
+ enable_powered_by_discourse:
+ default: false
+ client: true
+
auto_handle_queued_age:
default: 60
min: 0
diff --git a/spec/system/powered_by_discourse_spec.rb b/spec/system/powered_by_discourse_spec.rb
new file mode 100644
index 00000000000..3ba09f31317
--- /dev/null
+++ b/spec/system/powered_by_discourse_spec.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+describe "Powered by Discourse", type: :system do
+ it "appears when enabled" do
+ SiteSetting.enable_powered_by_discourse = true
+
+ visit "/"
+ expect(page).to have_css(".powered-by-discourse")
+ end
+
+ it "does not appear on admin routes when enabled" do
+ SiteSetting.enable_powered_by_discourse = true
+
+ visit "/admin"
+ expect(page).not_to have_css(".powered-by-discourse")
+ end
+
+ it "does not appear on login required route when enabled" do
+ SiteSetting.enable_powered_by_discourse = true
+ SiteSetting.login_required = true
+
+ visit "/"
+ expect(page).not_to have_css(".powered-by-discourse")
+ end
+
+ it "does not appear when disabled" do
+ SiteSetting.enable_powered_by_discourse = false
+
+ visit "/"
+ expect(page).not_to have_css(".powered-by-discourse")
+ end
+end