diff --git a/app/assets/javascripts/discourse/app/controllers/create-account.js b/app/assets/javascripts/discourse/app/controllers/create-account.js index b364d8d2ebd..0d75cc8495c 100644 --- a/app/assets/javascripts/discourse/app/controllers/create-account.js +++ b/app/assets/javascripts/discourse/app/controllers/create-account.js @@ -18,7 +18,6 @@ import { ajax } from "discourse/lib/ajax"; import { emailValid } from "discourse/lib/utilities"; import { findAll } from "discourse/models/login-method"; import discourseDebounce from "discourse-common/lib/debounce"; -import getURL from "discourse-common/lib/get-url"; import { isEmpty } from "@ember/utils"; import { notEmpty } from "@ember/object/computed"; import { setting } from "discourse/lib/computed"; @@ -129,11 +128,12 @@ export default Controller.extend( @discourseComputed disclaimerHtml() { - return I18n.t("create_account.disclaimer", { - tos_link: this.siteSettings.tos_url || getURL("/tos"), - privacy_link: - this.siteSettings.privacy_policy_url || getURL("/privacy"), - }); + if (this.site.tos_url && this.site.privacy_policy_url) { + return I18n.t("create_account.disclaimer", { + tos_link: this.site.tos_url, + privacy_link: this.site.privacy_policy_url, + }); + } }, // Check the email address diff --git a/app/assets/javascripts/discourse/app/controllers/invites-show.js b/app/assets/javascripts/discourse/app/controllers/invites-show.js index 2d99c580f8b..60ff407c76f 100644 --- a/app/assets/javascripts/discourse/app/controllers/invites-show.js +++ b/app/assets/javascripts/discourse/app/controllers/invites-show.js @@ -271,11 +271,12 @@ export default Controller.extend( @discourseComputed disclaimerHtml() { - return I18n.t("create_account.disclaimer", { - tos_link: this.siteSettings.tos_url || getUrl("/tos"), - privacy_link: - this.siteSettings.privacy_policy_url || getUrl("/privacy"), - }); + if (this.site.tos_url && this.site.privacy_policy_url) { + return I18n.t("create_account.disclaimer", { + tos_link: this.site.tos_url, + privacy_link: this.site.privacy_policy_url, + }); + } }, @discourseComputed("authOptions.associate_url", "authOptions.auth_provider") diff --git a/app/assets/javascripts/discourse/app/templates/about.hbs b/app/assets/javascripts/discourse/app/templates/about.hbs index 90254d34939..f3b54c9d648 100644 --- a/app/assets/javascripts/discourse/app/templates/about.hbs +++ b/app/assets/javascripts/discourse/app/templates/about.hbs @@ -18,12 +18,12 @@ "faq" }} {{/if}} - {{#if (gt this.siteSettings.tos_topic_id 0)}} + {{#if this.site.tos_url}} {{/if}} - {{#if (gt this.siteSettings.privacy_topic_id 0)}} + {{#if this.site.privacy_policy_url}} diff --git a/app/serializers/site_serializer.rb b/app/serializers/site_serializer.rb index 242b0ac24bb..b874cfb5d75 100644 --- a/app/serializers/site_serializer.rb +++ b/app/serializers/site_serializer.rb @@ -41,6 +41,8 @@ class SiteSerializer < ApplicationSerializer :anonymous_sidebar_sections, :whispers_allowed_groups_names, :denied_emojis, + :tos_url, + :privacy_policy_url, ) has_many :archetypes, embed: :objects, serializer: ArchetypeSerializer @@ -285,6 +287,30 @@ class SiteSerializer < ApplicationSerializer denied_emojis.present? end + def tos_url + if SiteSetting.tos_url.present? + SiteSetting.tos_url + elsif SiteSetting.tos_topic_id > 0 && Topic.exists?(id: SiteSetting.tos_topic_id) + "#{Discourse.base_path}/tos" + end + end + + def include_tos_url? + tos_url.present? + end + + def privacy_policy_url + if SiteSetting.privacy_policy_url.present? + SiteSetting.privacy_policy_url + elsif SiteSetting.privacy_topic_id > 0 && Topic.exists?(id: SiteSetting.privacy_topic_id) + "#{Discourse.base_path}/privacy" + end + end + + def include_privacy_policy_url? + privacy_policy_url.present? + end + private def ordered_flags(flags) diff --git a/app/views/layouts/_noscript_footer.html.erb b/app/views/layouts/_noscript_footer.html.erb index 76770aaa049..74919f43b79 100644 --- a/app/views/layouts/_noscript_footer.html.erb +++ b/app/views/layouts/_noscript_footer.html.erb @@ -16,16 +16,20 @@ -
  • - - - -
  • -
  • - - - -
  • + <% if path = tos_path.presence %> +
  • + + + +
  • + <% end %> + <% if path = privacy_path.presence %> +
  • + + + +
  • + <% end %> diff --git a/app/views/static/show.html.erb b/app/views/static/show.html.erb index a0ec792c408..cdd829664fc 100644 --- a/app/views/static/show.html.erb +++ b/app/views/static/show.html.erb @@ -10,11 +10,11 @@ <% end %> <% end %> - <% if SiteSetting.tos_topic_id > 0 %> - + <% if path = tos_path.presence %> + <% end %> - <% if SiteSetting.privacy_topic_id > 0 %> - + <% if path = privacy_path.presence %> + <% end %> diff --git a/config/site_settings.yml b/config/site_settings.yml index 4d8969986dc..98ff694b03c 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -2477,14 +2477,12 @@ uncategorized: tos_topic_id: default: -1 hidden: true - client: true guidelines_topic_id: default: -1 hidden: true privacy_topic_id: default: -1 hidden: true - client: true welcome_topic_id: default: -1 hidden: true diff --git a/lib/configurable_urls.rb b/lib/configurable_urls.rb index c196b74b12f..c92e3fefbe6 100644 --- a/lib/configurable_urls.rb +++ b/lib/configurable_urls.rb @@ -6,14 +6,18 @@ module ConfigurableUrls end def tos_path - SiteSetting.tos_url.blank? ? "#{Discourse.base_path}/tos" : SiteSetting.tos_url + if SiteSetting.tos_url.present? + SiteSetting.tos_url + elsif SiteSetting.tos_topic_id > 0 && Topic.exists?(id: SiteSetting.tos_topic_id) + "#{Discourse.base_path}/tos" + end end def privacy_path - if SiteSetting.privacy_policy_url.blank? - "#{Discourse.base_path}/privacy" - else + if SiteSetting.privacy_policy_url.present? SiteSetting.privacy_policy_url + elsif SiteSetting.privacy_topic_id > 0 && Topic.exists?(id: SiteSetting.privacy_topic_id) + "#{Discourse.base_path}/privacy" end end end