From 2ad24e4a6095870aaebdc07695a68a56e2d6fc03 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Mon, 22 Jul 2019 11:43:39 -0400 Subject: [PATCH] FEATURE: add option to disable ads in restricted categories Use the new setting "no ads for restricted categories". --- .../discourse/components/ad-component.js.es6 | 15 ++++++++++++--- config/locales/server.en.yml | 1 + config/settings.yml | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/assets/javascripts/discourse/components/ad-component.js.es6 b/assets/javascripts/discourse/components/ad-component.js.es6 index 34b765b..3142295 100644 --- a/assets/javascripts/discourse/components/ad-component.js.es6 +++ b/assets/javascripts/discourse/components/ad-component.js.es6 @@ -18,6 +18,11 @@ export default Ember.Component.extend({ "router.currentRoute.parent.attributes.tags_disable_ads" ), + isRestrictedCategory: Ember.computed.or( + "router.currentRoute.attributes.category.read_restricted", + "router.currentRoute.parent.attributes.category.read_restricted" + ), + @computed( "router.currentRoute.attributes.__type", "router.currentRoute.attributes.id" @@ -66,13 +71,15 @@ export default Ember.Component.extend({ "currentCategoryId", "topicTagsDisableAds", "topicListTag", - "isPersonalMessage" + "isPersonalMessage", + "isRestrictedCategory" ) showOnCurrentPage( categoryId, topicTagsDisableAds, topicListTag, - isPersonalMessage + isPersonalMessage, + isRestrictedCategory ) { return ( !topicTagsDisableAds && @@ -84,7 +91,9 @@ export default Ember.Component.extend({ (!topicListTag || !this.siteSettings.no_ads_for_tags || !this.siteSettings.no_ads_for_tags.split("|").includes(topicListTag)) && - (!isPersonalMessage || !this.siteSettings.no_ads_for_personal_messages) + (!isPersonalMessage || !this.siteSettings.no_ads_for_personal_messages) && + (!isRestrictedCategory || + !this.siteSettings.no_ads_for_restricted_categories) ); }, diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 508c2cf..cc887bb 100755 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1,6 +1,7 @@ en: site_settings: no_ads_for_personal_messages: "Don't show ads when viewing personal messages" + no_ads_for_restricted_categories: "Don't show ads in categories that aren't visible to everyone." no_ads_for_groups: "Don't show ads to users in these groups." no_ads_for_categories: "Don't show ads on topic list and topic pages belonging to these categories." no_ads_for_tags: "Don't show ads on topic list and topic pages belonging to these tags." diff --git a/config/settings.yml b/config/settings.yml index 8075502..e722f1c 100755 --- a/config/settings.yml +++ b/config/settings.yml @@ -2,6 +2,9 @@ ad_plugin: no_ads_for_personal_messages: client: true default: true + no_ads_for_restricted_categories: + client: true + default: false no_ads_for_groups: client: true default: ""