Added trust levels to site settings for dfp
This commit is contained in:
parent
2f1ac77380
commit
6452c9c5b1
|
@ -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) {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
<div class="google-dfp-ad-label"><h2>Google Ad Plugin Display</h2></div>
|
||||
|
||||
{{#if site.mobileView}}
|
||||
{{#if loadedGoogletag}}
|
||||
<div id={{divId}} style={{adWrapperStyleMobile}} class="dfp-ad-unit" align=center>
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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: ''
|
||||
|
|
Loading…
Reference in New Issue