FEATURE: add option to disable ads in restricted categories

Use the new setting "no ads for restricted categories".
This commit is contained in:
Neil Lalonde 2019-07-22 11:43:39 -04:00
parent 2ceb99e151
commit 2ad24e4a60
3 changed files with 16 additions and 3 deletions

View File

@ -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)
);
},

View File

@ -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."

View File

@ -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: ""