From 5f4dbd6ddcc34e37afbef02269090e541baeff6f Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 1 May 2013 11:48:42 -0400 Subject: [PATCH] Use tos_url site setting in flag modal if it's set --- app/helpers/application_helper.rb | 10 ++-------- app/serializers/post_action_type_serializer.rb | 10 +++++++--- config/locales/server.en.yml | 2 +- lib/configurable_urls.rb | 11 +++++++++++ 4 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 lib/configurable_urls.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 413328f0220..6da3fdda8c1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3,10 +3,12 @@ require 'canonical_url' require_dependency 'guardian' require_dependency 'unread' require_dependency 'age_words' +require_dependency 'configurable_urls' module ApplicationHelper include CurrentUser include CanonicalURL::Helpers + include ConfigurableUrls def with_format(format, &block) old_formats = formats @@ -62,14 +64,6 @@ module ApplicationHelper return "#{Discourse::base_uri}/faq" end - def tos_path - SiteSetting.tos_url.blank? ? "#{Discourse::base_uri}/tos" : SiteSetting.tos_url - end - - def privacy_path - SiteSetting.privacy_policy_url.blank? ? "#{Discourse::base_uri}/privacy" : SiteSetting.privacy_policy_url - end - def login_path return "#{Discourse::base_uri}/login" end diff --git a/app/serializers/post_action_type_serializer.rb b/app/serializers/post_action_type_serializer.rb index f0dfb080838..763bc3886b4 100644 --- a/app/serializers/post_action_type_serializer.rb +++ b/app/serializers/post_action_type_serializer.rb @@ -1,7 +1,11 @@ +require_dependency 'configurable_urls' + class PostActionTypeSerializer < ApplicationSerializer attributes :name_key, :name, :description, :long_form, :is_flag, :icon, :id, :is_custom_flag + include ConfigurableUrls + def is_custom_flag object.id == PostActionType.types[:notify_user] || object.id == PostActionType.types[:notify_moderators] @@ -16,13 +20,13 @@ class PostActionTypeSerializer < ApplicationSerializer end def description - i18n('description') + i18n('description', {tos_url: tos_path}) end protected - def i18n(field) - I18n.t("post_action_types.#{object.name_key}.#{field}") + def i18n(field, vars={}) + I18n.t("post_action_types.#{object.name_key}.#{field}", vars) end end diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 0d6781bb62a..4401f96df2d 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -236,7 +236,7 @@ en: email_body: "%{link}\n\n%{message}" notify_moderators: title: 'Notify moderators' - description: 'This post requires general moderator attention based on the FAQ, TOS, or for another reason not listed above.' + description: 'This post requires general moderator attention based on the FAQ, TOS, or for another reason not listed above.' long_form: 'notified moderators' email_title: 'A post in "%{title}" requires moderator attention' email_body: "%{link}\n\n%{message}" diff --git a/lib/configurable_urls.rb b/lib/configurable_urls.rb new file mode 100644 index 00000000000..fe3f7e2227f --- /dev/null +++ b/lib/configurable_urls.rb @@ -0,0 +1,11 @@ +module ConfigurableUrls + + def tos_path + SiteSetting.tos_url.blank? ? "#{Discourse::base_uri}/tos" : SiteSetting.tos_url + end + + def privacy_path + SiteSetting.privacy_policy_url.blank? ? "#{Discourse::base_uri}/privacy" : SiteSetting.privacy_policy_url + end + +end \ No newline at end of file