Refactored to only have amazon link/banner ads and refactored for check trust levels

This commit is contained in:
vi 2015-09-16 12:11:50 +10:00
parent cc2572e3f1
commit 0adc5bfca7
7 changed files with 95 additions and 229 deletions

View File

@ -5,7 +5,6 @@ var mobile_amazon_height = '';
var user_input = ''; var user_input = '';
var user_input_mobile = ''; var user_input_mobile = '';
var currentUser = Discourse.User.current(); var currentUser = Discourse.User.current();
var product_type = 'Product/Easy Banner Link';
function splitWidthInt(value) { function splitWidthInt(value) {
var str = value.substring(0, 3); var str = value.substring(0, 3);
@ -25,7 +24,7 @@ var data = {
} }
if (Discourse.SiteSettings.amazon_topic_list_top_ad_category === 'Product/Easy Banner Link' && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.amazon_through_trust_level))) {
if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.amazon_topic_list_top_src_code) { if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.amazon_topic_list_top_src_code) {
data["topic-list-top"]["user_input"] = Discourse.SiteSettings.amazon_topic_list_top_src_code; data["topic-list-top"]["user_input"] = Discourse.SiteSettings.amazon_topic_list_top_src_code;
data["topic-list-top"]["amazon_width"] = parseInt(Discourse.SiteSettings.amazon_topic_list_top_ad_width_code); data["topic-list-top"]["amazon_width"] = parseInt(Discourse.SiteSettings.amazon_topic_list_top_ad_width_code);
@ -72,13 +71,9 @@ if (Discourse.SiteSettings.amazon_topic_list_top_ad_category === 'Product/Easy B
data["post-bottom"]["user_input_mobile"] = Discourse.SiteSettings.amazon_mobile_post_bottom_src_code; data["post-bottom"]["user_input_mobile"] = Discourse.SiteSettings.amazon_mobile_post_bottom_src_code;
data["post-bottom"]["mobile_amazon_width"] = parseInt(Discourse.SiteSettings.amazon_mobile_post_bottom_ad_width_code); data["post-bottom"]["mobile_amazon_width"] = parseInt(Discourse.SiteSettings.amazon_mobile_post_bottom_ad_width_code);
data["post-bottom"]["mobile_amazon_height"] = parseInt(Discourse.SiteSettings.amazon_mobile_post_bottom_ad_height_code); data["post-bottom"]["mobile_amazon_height"] = parseInt(Discourse.SiteSettings.amazon_mobile_post_bottom_ad_height_code);
}
} }
// amazon_nth_post_code: "Choose the Nth position for your ad to show"
// amazon_through_trust_level: "Input trust level" */
// Ember component - the class is the adblock and css
export default Ember.Component.extend({ export default Ember.Component.extend({
amazon_width: amazon_width, amazon_width: amazon_width,
amazon_height: amazon_height, amazon_height: amazon_height,
@ -86,10 +81,6 @@ export default Ember.Component.extend({
mobile_amazon_height: mobile_amazon_height, mobile_amazon_height: mobile_amazon_height,
user_input: user_input, user_input: user_input,
user_input_mobile: user_input_mobile, user_input_mobile: user_input_mobile,
product_type: product_type,
// recommended_type: recommended_type,
// search_type: search_type,
// custom_type: custom_type,
classNames: ['amazon-product-links'], classNames: ['amazon-product-links'],
@ -123,19 +114,4 @@ export default Ember.Component.extend({
return !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.amazon_through_trust_level)); return !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.amazon_through_trust_level));
}.property('trust_level'), }.property('trust_level'),
typeProductCategory: function() {
return Discourse.SiteSettings.amazon_topic_list_top_ad_category === this.get('product_type');
}.property('product_type'),
// typeRecommendedCategory: function() {
// return Discourse.SiteSettings.amazon_topic_list_top_ad_category === this.get('recommended_type');
// }.property('recommended_type'),
// typeSearchCategory: function() {
// return Discourse.SiteSettings.amazon_topic_list_top_ad_category === this.get('search_type');
// }.property('search_type'),
// typeCustomCategory: function() {
// return Discourse.SiteSettings.amazon_topic_list_top_ad_category === this.get('custom_type');
// }.property('custom_type'),
}); });

View File

@ -52,7 +52,7 @@ var data = {
if (Discourse.SiteSettings.adsense_publisher_code) { if (Discourse.SiteSettings.adsense_publisher_code) {
if (!Discourse.SiteSettings.adsense_show_topic_list_top && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level))) { if (!Discourse.SiteSettings.adsense_show_topic_list_top) {
if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.adsense_topic_list_top_code) { if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.adsense_topic_list_top_code) {
data["topic-list-top"]["ad_code"] = Discourse.SiteSettings.adsense_topic_list_top_code; data["topic-list-top"]["ad_code"] = Discourse.SiteSettings.adsense_topic_list_top_code;
data["topic-list-top"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_list_top_ad_sizes)); data["topic-list-top"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_list_top_ad_sizes));
@ -62,7 +62,7 @@ if (Discourse.SiteSettings.adsense_publisher_code) {
data["topic-list-top"]["ad_mobile_code"] = Discourse.SiteSettings.adsense_mobile_topic_list_top_code; data["topic-list-top"]["ad_mobile_code"] = Discourse.SiteSettings.adsense_mobile_topic_list_top_code;
} }
} }
if (!Discourse.SiteSettings.adsense_show_topic_above_post_stream && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level))) { if (!Discourse.SiteSettings.adsense_show_topic_above_post_stream) {
if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.adsense_topic_above_post_stream_code) { if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.adsense_topic_above_post_stream_code) {
data["topic-above-post-stream"]["ad_code"] = Discourse.SiteSettings.adsense_topic_above_post_stream_code; data["topic-above-post-stream"]["ad_code"] = Discourse.SiteSettings.adsense_topic_above_post_stream_code;
data["topic-above-post-stream"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_above_post_stream_ad_sizes)); data["topic-above-post-stream"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_above_post_stream_ad_sizes));
@ -72,7 +72,7 @@ if (Discourse.SiteSettings.adsense_publisher_code) {
data["topic-above-post-stream"]["ad_mobile_code"] = Discourse.SiteSettings.adsense_mobile_topic_above_post_stream_code; data["topic-above-post-stream"]["ad_mobile_code"] = Discourse.SiteSettings.adsense_mobile_topic_above_post_stream_code;
} }
} }
if (!Discourse.SiteSettings.adsense_show_topic_above_suggested && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level))) { if (!Discourse.SiteSettings.adsense_show_topic_above_suggested) {
if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.adsense_topic_above_suggested_code) { if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.adsense_topic_above_suggested_code) {
data["topic-above-suggested"]["ad_code"] = Discourse.SiteSettings.adsense_topic_above_suggested_code; data["topic-above-suggested"]["ad_code"] = Discourse.SiteSettings.adsense_topic_above_suggested_code;
data["topic-above-suggested"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_above_suggested_ad_sizes)); data["topic-above-suggested"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_above_suggested_ad_sizes));
@ -82,7 +82,7 @@ if (Discourse.SiteSettings.adsense_publisher_code) {
data["topic-above-suggested"]["ad_mobile_code"] = Discourse.SiteSettings.adsense_mobile_topic_above_suggested_code; data["topic-above-suggested"]["ad_mobile_code"] = Discourse.SiteSettings.adsense_mobile_topic_above_suggested_code;
} }
} }
if (!Discourse.SiteSettings.adsense_show_post_bottom && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level))) { if (!Discourse.SiteSettings.adsense_show_post_bottom) {
if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.adsense_post_bottom_code) { if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.adsense_post_bottom_code) {
data["post-bottom"]["ad_code"] = Discourse.SiteSettings.adsense_post_bottom_code; data["post-bottom"]["ad_code"] = Discourse.SiteSettings.adsense_post_bottom_code;
data["post-bottom"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_post_bottom_ad_sizes)); data["post-bottom"]["ad_width"] = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_post_bottom_ad_sizes));
@ -131,4 +131,8 @@ export default Ember.Component.extend({
adInsStyleMobile: function() { adInsStyleMobile: function() {
return `display: inline-block; ${this.get('adWrapperStyleMobile')}`.htmlSafe(); return `display: inline-block; ${this.get('adWrapperStyleMobile')}`.htmlSafe();
}.property('adWrapperStyleMobile'), }.property('adWrapperStyleMobile'),
checkTrustLevels: function() {
return !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level));
}.property('trust_level'),
}); });

View File

@ -1,5 +1,4 @@
{{#if checkTrustLevels}} {{#if checkTrustLevels}}
{{#if typeProductCategory}}
{{#if site.mobileView}} {{#if site.mobileView}}
<iframe style={{adWrapperStyleMobile}} marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src={{userInput}}> <iframe style={{adWrapperStyleMobile}} marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src={{userInput}}>
</iframe> </iframe>
@ -9,58 +8,4 @@
</iframe> </iframe>
</div> </div>
{{/if}} {{/if}}
{{else}}
{{#if typeRecommendedCategory}}
<script type="text/javascript">
amzn_assoc_placement = "adunit0";
amzn_assoc_enable_interest_ads = "true";
amzn_assoc_tracking_id = "s0fcc-20";
amzn_assoc_ad_mode = "auto";
amzn_assoc_ad_type = "smart";
amzn_assoc_marketplace = "amazon";
amzn_assoc_region = "US";
amzn_assoc_linkid = "0d4f6279a6c527dd41ea063851ee9154";
amzn_assoc_emphasize_categories = "51569011,3760911";
amzn_assoc_size = "autoxauto";
amzn_assoc_rows = "2";
amzn_assoc_fallback_mode = {"type":"search","value":"hello"};
amzn_assoc_default_category = "Electronics";
</script>
<script src={{userInput}}></script>
{{/if}}
{{#if typeSearchCategory}}
<script type="text/javascript">
amzn_assoc_placement = "adunit0";
amzn_assoc_tracking_id = "s0fcc-20";
amzn_assoc_ad_mode = "search";
amzn_assoc_ad_type = "smart";
amzn_assoc_marketplace = "amazon";
amzn_assoc_region = "US";
amzn_assoc_linkid = "a72ad11d9a0bf521a92e8256409f29e1";
amzn_assoc_default_search_phrase = "Nokia Phones";
amzn_assoc_size = "autoxauto";
amzn_assoc_rows = "2";
amzn_assoc_search_bar_position = "bottom";
</script>
<script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>
{{/if}}
{{#if typeCustomCategory}}
<script type="text/javascript">
amzn_assoc_placement = "adunit0";
amzn_assoc_tracking_id = "s0fcc-20";
amzn_assoc_ad_mode = "manual";
amzn_assoc_ad_type = "smart";
amzn_assoc_marketplace = "amazon";
amzn_assoc_region = "US";
amzn_assoc_linkid = "402f6cf98c6537aa462dfa90c96af127";
amzn_assoc_asins = "B012CD7N1Q,B001DPQL2W,B00FFXF8KE,B004W2GTMA,B001DI1G3S,B012CNXH5C,B00OY0YMJW,B00SUYCC9A";
amzn_assoc_size = "500x500";
amzn_assoc_search_bar = "true";
amzn_assoc_title = "My Life";
</script>
<script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>
{{/if}}
{{/if}}
{{/if}} {{/if}}

View File

@ -1,3 +1,4 @@
{{#if checkTrustLevels}}
{{#if site.mobileView}} {{#if site.mobileView}}
<div style={{adWrapperStyleMobile}}> <div style={{adWrapperStyleMobile}}>
<ins class="adsbygoogle" <ins class="adsbygoogle"
@ -23,5 +24,6 @@
</script> </script>
</div> </div>
{{/if}} {{/if}}
{{/if}}

View File

@ -1,17 +1,12 @@
{{#if site.mobileView}}
{{#if loadedGoogletag}}
{{#if checkTrustLevels}} {{#if checkTrustLevels}}
{{#if loadedGoogletag}}
{{#if site.mobileView}}
<div id={{divId}} style={{adWrapperStyleMobile}} class="dfp-ad-unit" align=center> <div id={{divId}} style={{adWrapperStyleMobile}} class="dfp-ad-unit" align=center>
<script type='text/javascript'> <script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('{{divId}}'); }); googletag.cmd.push(function() { googletag.display('{{divId}}'); });
</script> </script>
</div> </div>
{{/if}}
{{/if}}
{{else}} {{else}}
{{#if loadedGoogletag}}
{{#if checkTrustLevels}}
<div id={{divId}} style={{adWrapperStyle}} class="dfp-ad-unit" align=center> <div id={{divId}} style={{adWrapperStyle}} class="dfp-ad-unit" align=center>
<script type='text/javascript'> <script type='text/javascript'>
googletag.cmd.push(function() { googletag.display('{{divId}}'); }); googletag.cmd.push(function() { googletag.display('{{divId}}'); });

View File

@ -41,27 +41,15 @@ en:
adsense_topic_above_suggested_code: "Show leaderboard ad above suggested topics" adsense_topic_above_suggested_code: "Show leaderboard ad above suggested topics"
adsense_mobile_topic_above_suggested_code: "Mobile - Show leaderboard ad above suggested topics" adsense_mobile_topic_above_suggested_code: "Mobile - Show leaderboard ad above suggested topics"
adsense_topic_above_suggested_ad_sizes: "Choose your ad sizes" adsense_topic_above_suggested_ad_sizes: "Choose your ad sizes"
adsense_show_post_bottom: "Disable post_bottom ad"
adsense_post_bottom_code: "Show leaderboard ad post_bottom topics" adsense_post_bottom_code: "Show leaderboard ad post_bottom topics"
adsense_mobile_post_bottom_code: "Mobile - Show leaderboard ad post_bottom topics" adsense_mobile_post_bottom_code: "Mobile - Show leaderboard ad post_bottom topics"
adsense_show_post_bottom: "Disable post_bottom ad"
adsense_post_bottom_ad_sizes: "Choose your ad sizes" adsense_post_bottom_ad_sizes: "Choose your ad sizes"
adsense_nth_post_code: "Choose the Nth position for your ad to show" adsense_nth_post_code: "Choose the Nth position for your ad to show"
amazon_topic_list_top_ad_category: "Choose your Amazon Ad type" amazon_through_trust_level: "Input trust level"
amazon_tracking_id_code: "Choose Tracking ID Code"
amazon_region_code: "Choose the Generic Amazon Marketplace Region"
amazon_topic_list_top_src_code: "Input your Src code" amazon_topic_list_top_src_code: "Input your Src code"
amazon_topic_list_top_title_code: "Input your Ad Description"
amazon_topic_list_top_ad_width_code: "Choose your ad width" amazon_topic_list_top_ad_width_code: "Choose your ad width"
amazon_topic_list_top_ad_height_code: "Choose your ad height" amazon_topic_list_top_ad_height_code: "Choose your ad height"
amazon_topic_list_top_custom_product_id_code: "Input relevant ad codes"
amazon_topic_list_top_link_id_code: "Input your Link ID"
amazon_topic_list_top_ad_mode: "Choose either manual (custom), auto (recommended), search (search)"
amazon_topic_list_top_fallback_mode_value_code: "Input value that corresponds to type: search"
amazon_topic_list_top_row_ads_code: "Input number of ad display rows"
amazon_topic_list_top_default_category_code: "Input default category"
amazon_topic_list_top_search_phrase_code: "Input search phrase"
amazon_nth_post_code: "Choose the Nth position for your ad to show"
amazon_through_trust_level: "Input trust level"
amazon_mobile_topic_list_top_src_code: "Input your Src code (Mobile)" amazon_mobile_topic_list_top_src_code: "Input your Src code (Mobile)"
amazon_mobile_topic_list_top_ad_width_code: "Choose your ad width (Mobile)" amazon_mobile_topic_list_top_ad_width_code: "Choose your ad width (Mobile)"
amazon_mobile_topic_list_top_ad_height_code: "Choose your ad height (Mobile)" amazon_mobile_topic_list_top_ad_height_code: "Choose your ad height (Mobile)"
@ -83,3 +71,4 @@ en:
amazon_mobile_post_bottom_src_code: "Input your Src code (Mobile)" amazon_mobile_post_bottom_src_code: "Input your Src code (Mobile)"
amazon_mobile_post_bottom_ad_width_code: "Choose your ad width (Mobile)" amazon_mobile_post_bottom_ad_width_code: "Choose your ad width (Mobile)"
amazon_mobile_post_bottom_ad_height_code: "Choose your ad height (Mobile)" amazon_mobile_post_bottom_ad_height_code: "Choose your ad height (Mobile)"
amazon_nth_post_code: "Choose the Nth position for your ad to show"

View File

@ -239,63 +239,18 @@ dfp_plugin:
client: true client: true
amazon_plugin: amazon_plugin:
amazon_topic_list_top_ad_category: amazon_through_trust_level:
client: true client: true
default: 'Product/Easy Banner Link' default: 2
type: enum
choices:
- Product/Easy Banner Link
- Native Shopping Ad - Recommended
- Native Shopping Ad - Custom
- Native Shopping Ad - Search
amazon_tracking_id_code:
client: true
default: ''
amazon_region_code:
client: true
default: ''
amazon_topic_list_top_src_code: amazon_topic_list_top_src_code:
client: true client: true
default: '' default: ''
amazon_topic_list_top_title_code:
client: true
default: ''
amazon_topic_list_top_ad_width_code: amazon_topic_list_top_ad_width_code:
client: true client: true
default: '' default: ''
amazon_topic_list_top_ad_height_code: amazon_topic_list_top_ad_height_code:
client: true client: true
default: '' default: ''
amazon_topic_list_top_custom_product_id_code:
default: ''
type: value_list
client: true
amazon_topic_list_top_link_id_code:
client: true
default: ''
amazon_topic_list_top_ad_mode:
client: true
default: 'manual'
type: enum
choices:
- manual
- auto
- search
amazon_topic_list_top_fallback_mode_value_code:
client: true
default: ''
amazon_topic_list_top_row_ads_code:
client: true
default: ''
amazon_topic_list_top_default_category_code:
client: true
default: ''
amazon_topic_list_top_search_phrase_code:
client: true
default: ''
amazon_through_trust_level:
client: true
default: 2
amazon_mobile_topic_list_top_src_code: amazon_mobile_topic_list_top_src_code:
client: true client: true
default: '' default: ''