diff --git a/assets/javascripts/discourse/components/ad-component.js.es6 b/assets/javascripts/discourse/components/ad-component.js.es6 index f527b44..403a39d 100644 --- a/assets/javascripts/discourse/components/ad-component.js.es6 +++ b/assets/javascripts/discourse/components/ad-component.js.es6 @@ -13,6 +13,21 @@ export default Ember.Component.extend({ "router.currentRoute.parent.attributes.category.slug" ), + @computed( + "router.currentRoute.parent.attributes.tags", + "router.currentRoute.attributes.__type", + "router.currentRoute.attributes.id" + ) + currentTags(tagsArray, type, tag) { + if (tagsArray) { + return tagsArray; + } + + if (type == "tag" && tag) { + return [tag]; + } + }, + @computed("currentUser.groups") showToGroups(groups) { const currentUser = Discourse.User.current(); @@ -34,14 +49,21 @@ export default Ember.Component.extend({ return !groupNames.any(g => noAdsGroupNames.includes(g)); }, - @computed("currentCategoryId") - showOnCurrentPage(categoryId) { + @computed("currentCategoryId", "currentTags") + showOnCurrentPage(categoryId, currentTags) { return ( - !categoryId || - !this.siteSettings.no_ads_for_categories || - !this.siteSettings.no_ads_for_categories - .split("|") - .includes(categoryId.toString()) + (!categoryId || + !this.siteSettings.no_ads_for_categories || + !this.siteSettings.no_ads_for_categories + .split("|") + .includes(categoryId.toString())) && + (!currentTags || + !this.siteSettings.no_ads_for_tags || + Ember.isEmpty( + this.siteSettings.no_ads_for_tags + .split("|") + .filter(tag => currentTags.includes(tag)) + )) ); }, diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 6abdd51..9e0fe3f 100755 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -2,6 +2,7 @@ en: site_settings: 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." house_ads_after_nth_post: 'If "Between posts" house ads are defined, show an ad after every N posts, where N is this value.' house_ads_frequency: "If other ad networks are configured to show in an ad slot, how often should house ads be shown, as a percentage." ads_txt: "Contents of your ads.txt file. More details available at this Google AdSense help page." diff --git a/config/settings.yml b/config/settings.yml index 9aec408..3a2a52c 100755 --- a/config/settings.yml +++ b/config/settings.yml @@ -7,6 +7,10 @@ ad_plugin: client: true default: "" type: category_list + no_ads_for_tags: + client: true + default: "" + type: list house_ads_after_nth_post: client: true default: 20