Skip to content

Commit

Permalink
FEATURE: add option to disable ads in restricted categories
Browse files Browse the repository at this point in the history
Use the new setting "no ads for restricted categories".
  • Loading branch information
nlalonde committed Jul 22, 2019
1 parent 2ceb99e commit 2ad24e4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
15 changes: 12 additions & 3 deletions assets/javascripts/discourse/components/ad-component.js.es6
Expand Up @@ -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"
Expand Down Expand Up @@ -66,13 +71,15 @@ export default Ember.Component.extend({
"currentCategoryId",
"topicTagsDisableAds",
"topicListTag",
"isPersonalMessage"
"isPersonalMessage",
"isRestrictedCategory"
)
showOnCurrentPage(
categoryId,
topicTagsDisableAds,
topicListTag,
isPersonalMessage
isPersonalMessage,
isRestrictedCategory
) {
return (
!topicTagsDisableAds &&
Expand All @@ -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)
);
},

Expand Down
1 change: 1 addition & 0 deletions 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."
Expand Down
3 changes: 3 additions & 0 deletions config/settings.yml
Expand Up @@ -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: ""
Expand Down

2 comments on commit 2ad24e4

@discoursereviewbot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Régis Hanol posted:

I think that's worthy of a test? Just to ensure we don't break that behavior in the future.

@discoursereviewbot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.