diff --git a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 index acb92f5..a4f5f5f 100755 --- a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 +++ b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 @@ -3,6 +3,7 @@ import loadScript from 'discourse/lib/load-script'; var const_width = ''; var const_height = ''; +var currentUser = Discourse.User.current(); var _loaded = false, _promise = null; @@ -91,7 +92,7 @@ function loadGoogle(settings) { } googletag.cmd.push(function() { - if (settings.dfp_topic_list_top_code && !settings.dfp_show_topic_list_top && settings.topic_list_top_ad_sizes) { + if (settings.dfp_topic_list_top_code && !settings.dfp_show_topic_list_top && settings.topic_list_top_ad_sizes && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.dfp_through_trust_level))) { const_width = parseInt(splitWidthInt(settings.topic_list_top_ad_sizes)); const_height = parseInt(splitHeightInt(settings.topic_list_top_ad_sizes)); if (Discourse.Mobile.mobileView) { @@ -99,11 +100,12 @@ function loadGoogle(settings) { } else { googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + settings.dfp_topic_list_top_code, [parseInt(splitWidthInt(settings.topic_list_top_ad_sizes)), parseInt(splitHeightInt(settings.topic_list_top_ad_sizes))], 'div-gpt-ad-topic-list-top') - custom_targeting((keyParse(Discourse.SiteSettings.dfp_target_topic_list_top_key_code)), (keyParse(Discourse.SiteSettings.dfp_target_topic_list_top_value_code))) - googletag.addService(googletag.pubads()); + .setTargeting('gender', ['female']) + //custom_targeting((keyParse(Discourse.SiteSettings.dfp_target_topic_list_top_key_code)), (keyParse(Discourse.SiteSettings.dfp_target_topic_list_top_value_code))) + .addService(googletag.pubads()); } } - if (settings.dfp_topic_above_post_stream_code && !settings.dfp_show_topic_above_post_stream && settings.topic_above_post_stream_ad_sizes) { + if (settings.dfp_topic_above_post_stream_code && !settings.dfp_show_topic_above_post_stream && settings.topic_above_post_stream_ad_sizes && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.dfp_through_trust_level))) { const_width = parseInt(splitWidthInt(settings.topic_above_post_stream_ad_sizes)); const_height = parseInt(splitHeightInt(settings.topic_above_post_stream_ad_sizes)); if (Discourse.Mobile.mobileView) { @@ -116,7 +118,7 @@ function loadGoogle(settings) { .addService(googletag.pubads()); } } - if (settings.dfp_topic_above_suggested_code && !settings.dfp_show_topic_above_suggested && settings.topic_above_suggested_ad_sizes) { + if (settings.dfp_topic_above_suggested_code && !settings.dfp_show_topic_above_suggested && settings.topic_above_suggested_ad_sizes && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.dfp_through_trust_level))) { const_width = parseInt(splitWidthInt(settings.topic_above_suggested_ad_sizes)); const_height = parseInt(splitHeightInt(settings.topic_above_suggested_ad_sizes)); if (Discourse.Mobile.mobileView) { @@ -130,7 +132,7 @@ function loadGoogle(settings) { googletag.addService(googletag.pubads()); } } - if (settings.dfp_post_bottom_code && !settings.dfp_show_post_bottom && settings.post_bottom_ad_sizes) { + if (settings.dfp_post_bottom_code && !settings.dfp_show_post_bottom && settings.post_bottom_ad_sizes && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.dfp_through_trust_level))) { const_width = parseInt(splitWidthInt(settings.post_bottom_ad_sizes)); const_height = parseInt(splitHeightInt(settings.post_bottom_ad_sizes)); if (Discourse.Mobile.mobileView) { diff --git a/assets/javascripts/discourse/templates/components/google-dfp-ad.hbs b/assets/javascripts/discourse/templates/components/google-dfp-ad.hbs index 486c4b0..ca96b4c 100755 --- a/assets/javascripts/discourse/templates/components/google-dfp-ad.hbs +++ b/assets/javascripts/discourse/templates/components/google-dfp-ad.hbs @@ -1,5 +1,3 @@ -

Google Ad Plugin Display

- {{#if site.mobileView}} {{#if loadedGoogletag}}
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 145ec12..38bd1a7 100755 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1,6 +1,7 @@ en: site_settings: dfp_publisher_id: "Put in your publisher id here" + dfp_through_trust_level: "Show your ads to users based on trust." dfp_show_topic_list_top: "Disable topic_list_top ad" dfp_topic_list_top_code: "Show leaderboard ad above topic lists." topic_list_top_ad_sizes: "Choose your ad size" diff --git a/config/settings.yml b/config/settings.yml index c19051d..99994e9 100755 --- a/config/settings.yml +++ b/config/settings.yml @@ -98,6 +98,10 @@ ad_plugin: dfp_publisher_id: client: true default: '' + dfp_through_trust_level: + client: true + default: 2 + enum: 'TrustLevelSetting' dfp_topic_list_top_code: client: true default: ''