Merged amazon with master

This commit is contained in:
vi 2015-09-18 10:46:14 +10:00
commit 335b7cd8dc
15 changed files with 352 additions and 38 deletions

View File

@ -0,0 +1,116 @@
var amazon_width = '';
var amazon_height = '';
var mobile_amazon_width = '';
var mobile_amazon_height = '';
var user_input = '';
var user_input_mobile = '';
var currentUser = Discourse.User.current();
function splitWidthInt(value) {
var str = value.substring(0, 3);
return str.trim();
}
function splitHeightInt(value) {
var str = value.substring(0, 3);
return str.trim();
}
var data = {
"topic-list-top" : {},
"topic-above-post-stream" : {},
"topic-above-suggested" : {},
"post-bottom" : {}
}
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"]["amazon_width"] = parseInt(Discourse.SiteSettings.amazon_topic_list_top_ad_width_code);
data["topic-list-top"]["amazon_height"] = parseInt(Discourse.SiteSettings.amazon_topic_list_top_ad_height_code);
}
if (Discourse.Mobile.mobileView && Discourse.SiteSettings.amazon_mobile_topic_list_top_src_code) {
data["topic-list-top"]["user_input_mobile"] = Discourse.SiteSettings.amazon_mobile_topic_list_top_src_code;
data["topic-list-top"]["mobile_amazon_width"] = parseInt(Discourse.SiteSettings.amazon_mobile_topic_list_top_ad_width_code);
data["topic-list-top"]["mobile_amazon_height"] = parseInt(Discourse.SiteSettings.amazon_mobile_topic_list_top_ad_height_code);
}
if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.amazon_topic_above_post_stream_src_code) {
data["topic-above-post-stream"]["user_input"] = Discourse.SiteSettings.amazon_topic_above_post_stream_src_code;
data["topic-above-post-stream"]["amazon_width"] = parseInt(Discourse.SiteSettings.amazon_topic_above_post_stream_ad_width_code);
data["topic-above-post-stream"]["amazon_height"] = parseInt(Discourse.SiteSettings.amazon_topic_above_post_stream_ad_height_code);
}
if (Discourse.Mobile.mobileView && Discourse.SiteSettings.amazon_mobile_topic_above_post_stream_src_code) {
data["topic-above-post-stream"]["user_input_mobile"] = Discourse.SiteSettings.amazon_mobile_topic_above_post_stream_src_code;
data["topic-above-post-stream"]["mobile_amazon_width"] = parseInt(Discourse.SiteSettings.amazon_mobile_topic_above_post_stream_ad_width_code);
data["topic-above-post-stream"]["mobile_amazon_height"] = parseInt(Discourse.SiteSettings.amazon_mobile_topic_above_post_stream_ad_height_code);
}
if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.amazon_topic_above_suggested_src_code) {
data["topic-above-suggested"]["user_input"] = Discourse.SiteSettings.amazon_topic_above_suggested_src_code;
data["topic-above-suggested"]["amazon_width"] = parseInt(Discourse.SiteSettings.amazon_topic_above_suggested_ad_width_code);
data["topic-above-suggested"]["amazon_height"] = parseInt(Discourse.SiteSettings.amazon_topic_above_suggested_ad_height_code);
}
if (Discourse.Mobile.mobileView && Discourse.SiteSettings.amazon_mobile_topic_above_sugggested_src_code) {
data["topic-above-suggested"]["user_input_mobile"] = Discourse.SiteSettings.amazon_mobile_topic_above_suggested_src_code;
data["topic-above-suggested"]["mobile_amazon_width"] = parseInt(Discourse.SiteSettings.amazon_mobile_topic_above_suggested_ad_width_code);
data["topic-above-suggested"]["mobile_amazon_height"] = parseInt(Discourse.SiteSettings.amazon_mobile_topic_above_suggested_ad_height_code);
}
if (!Discourse.Mobile.mobileView && Discourse.SiteSettings.amazon_post_bottom_src_code) {
data["post-bottom"]["user_input"] = Discourse.SiteSettings.amazon_post_bottom_src_code;
data["post-bottom"]["amazon_width"] = parseInt(Discourse.SiteSettings.amazon_post_bottom_ad_width_code);
data["post-bottom"]["amazon_height"] = parseInt(Discourse.SiteSettings.amazon_post_bottom_ad_height_code);
}
if (Discourse.Mobile.mobileView && 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_height"] = parseInt(Discourse.SiteSettings.amazon_mobile_post_bottom_ad_height_code);
}
export default Ember.Component.extend({
amazon_width: amazon_width,
amazon_height: amazon_height,
mobile_amazon_width: mobile_amazon_width,
mobile_amazon_height: mobile_amazon_height,
user_input: user_input,
user_input_mobile: user_input_mobile,
classNames: ['amazon-product-links'],
init: function() {
this.set('user_input', data[this.placement]["user_input"] );
this.set('amazon_width', data[this.placement]["amazon_width"] );
this.set('amazon_height', data[this.placement]["amazon_height"] );
this.set('user_input_mobile', data[this.placement]["user_input_mobile"] );
this.set('mobile_amazon_height', data[this.placement]["mobile_amazon_height"] );
this.set('mobile_amazon_width', data[this.placement]["mobile_amazon_width"] );
this._super();
},
adWrapperStyle: function() {
return `width: ${this.get('amazon_width')}px; height: ${this.get('amazon_height')}px;`.htmlSafe();
}.property('amazon_width', 'amazon_height'),
adWrapperStyleMobile: function() {
return `width: ${this.get('mobile_amazon_width')}px; height: ${this.get('mobile_amazon_height')}px;`.htmlSafe();
}.property('mobile_amazon_width', 'mobile_amazon_height'),
userInput: function() {
return `${this.get('user_input')}`.htmlSafe();
}.property('user_input'),
userInputMobile: function() {
return `${this.get('user_input_mobile')}`.htmlSafe();
}.property('user_input_mobile'),
checkTrustLevels: function() {
return !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.amazon_through_trust_level));
}.property('trust_level'),
});

View File

@ -52,7 +52,7 @@ var data = {
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) {
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));
@ -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;
}
}
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) {
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));
@ -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;
}
}
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) {
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));
@ -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;
}
}
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) {
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));
@ -131,4 +131,8 @@ export default Ember.Component.extend({
adInsStyleMobile: function() {
return `display: inline-block; ${this.get('adWrapperStyleMobile')}`.htmlSafe();
}.property('adWrapperStyleMobile'),
checkTrustLevels: function() {
return !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.adsense_through_trust_level));
}.property('trust_level'),
});

View File

@ -0,0 +1,11 @@
{{#if checkTrustLevels}}
{{#if site.mobileView}}
<iframe style={{adWrapperStyleMobile}} marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src={{userInput}}>
</iframe>
{{else}}
<div class="container" align="center">
<iframe style={{adWrapperStyle}} marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src={{userInput}}>
</iframe>
</div>
{{/if}}
{{/if}}

View File

@ -1,27 +1,29 @@
{{#if site.mobileView}}
<div style={{adWrapperStyleMobile}}>
<ins class="adsbygoogle"
style={{adInsStyleMobile}}
data-ad-client="ca-pub-{{publisher_id}}"
data-ad-slot={{ad_mobile_code}}>
</ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
{{else}}
<div style={{adWrapperStyle}}>
<ins class="adsbygoogle"
style={{adInsStyle}}
data-ad-client="ca-pub-{{publisher_id}}"
data-ad-slot={{ad_code}}>
</ins>
{{#if checkTrustLevels}}
{{#if site.mobileView}}
<div style={{adWrapperStyleMobile}}>
<ins class="adsbygoogle"
style={{adInsStyleMobile}}
data-ad-client="ca-pub-{{publisher_id}}"
data-ad-slot={{ad_mobile_code}}>
</ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
{{else}}
<div style={{adWrapperStyle}}>
<ins class="adsbygoogle"
style={{adInsStyle}}
data-ad-client="ca-pub-{{publisher_id}}"
data-ad-slot={{ad_code}}>
</ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
{{/if}}
{{/if}}

View File

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

View File

@ -4,3 +4,6 @@
{{#if siteSettings.dfp_topic_list_top_code}}
{{google-dfp-ad placement="topic-list-top"}}
{{/if}}
{{#if siteSettings.amazon_topic_list_top_src_code}}
{{amazon-product-links placement="topic-list-top"}}
{{/if}}

View File

@ -3,4 +3,7 @@
{{/if}}
{{#if postSpecificCountDFP}}
{{google-dfp-ad placement="post-bottom"}}
{{/if}}
{{#if postSpecificCountAmazon}}
{{amazon-product-links placement="post-bottom"}}
{{/if}}

View File

@ -3,4 +3,7 @@
{{/if}}
{{#if siteSettings.dfp_topic_above_post_stream_code}}
{{google-dfp-ad placement="topic-above-post-stream"}}
{{/if}}
{{#if siteSettings.amazon_topic_above_post_stream_src_code}}
{{amazon-product-links placement="topic-above-post-stream"}}
{{/if}}

View File

@ -3,4 +3,7 @@
{{/if}}
{{#if siteSettings.dfp_topic_above_suggested_code}}
{{google-dfp-ad placement="topic-above-suggested"}}
{{/if}}
{{#if siteSettings.amazon_topic_above_suggested_src_code}}
{{amazon-product-links placement="topic-above-suggested"}}
{{/if}}

View File

@ -11,6 +11,10 @@ export default {
postSpecificCountAdsense: function() {
return this.get('post_number') === parseInt(Discourse.SiteSettings.adsense_nth_post_code);
}.property('post_number'),
postSpecificCountAmazon: function() {
return this.get('post_number') === parseInt(Discourse.SiteSettings.amazon_nth_post_code);
}.property('post_number'),
});
}
};

View File

@ -19,3 +19,13 @@
margin: 0 auto;
}
.amazon-product-links {
padding: 3px;
margin-bottom: 10px;
clear: both;
}
.amazon-product-links .amazon-unit {
margin: 0 auto;
}

View File

@ -4,4 +4,5 @@ en:
site_settings:
categories:
dfp_plugin: 'DFP'
adsense_plugin: 'Adsense'
adsense_plugin: 'Adsense'
amazon_plugin: 'Amazon'

View File

@ -1,5 +1,6 @@
en:
site_settings:
<<<<<<< HEAD
dfp_publisher_id: "Input your publisher ID"
dfp_through_trust_level: "Show your ads to users based on trust levels"
dfp_show_topic_list_top: "Disable ad at topic list top location"
@ -32,6 +33,40 @@ en:
adsense_show_topic_list_top: "Disable ad at topic list top location"
adsense_topic_list_top_code: "Enter ad code to display at topic list top location"
adsense_mobile_topic_list_top_code: "Enter ad code to display mobile ads at topic list top location"
=======
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."
dfp_mobile_topic_list_top_code: "Mobile - Show leaderboard ad above topic lists."
dfp_topic_list_top_ad_sizes: "Choose your ad size"
dfp_target_topic_list_top_key_code: "Input key values - Inventory Level"
dfp_target_topic_list_top_value_code: "Input key values - Inventory Level"
dfp_show_topic_above_post_stream: "Disable topic_above_post_stream ad"
dfp_topic_above_post_stream_code: "Show leaderboard ad above post stream"
dfp_mobile_topic_above_post_stream_code: "Mobile - Show leaderboard ad above post stream"
dfp_topic_above_post_stream_ad_sizes: "Choose your ad size"
dfp_target_topic_above_post_stream_key_code: "Input key values - Inventory Level"
dfp_target_topic_above_post_stream_value_code: "Input key values - Inventory Level"
dfp_show_topic_above_suggested: "Disable topic_above_suggested ad"
dfp_topic_above_suggested_code: "Show leaderboard ad above suggested topics"
dfp_mobile_topic_above_suggested_code: "Mobile - Show leaderboard ad above suggested topics"
dfp_topic_above_suggested_ad_sizes: "Choose your ad size"
dfp_target_topic_above_suggested_key_code: "Input key values - Inventory Level"
dfp_target_topic_above_suggested_value_code: "Input key values - Inventory Level"
dfp_show_post_bottom: "Disable post_bottom ad"
dfp_post_bottom_code: "Show leaderboard ad post_bottom topics"
dfp_mobile_post_bottom_code: "Mobile - Show leaderboard ad post_bottom topics"
dfp_nth_post_code: "Choose the Nth position for your ad to show"
dfp_post_bottom_ad_sizes: "Choose your ad size"
dfp_target_post_bottom_key_code: "Input key values - Inventory Level"
dfp_target_post_bottom_value_code: "Input key values - Inventory Level"
adsense_publisher_code: "Insert your Publisher ID here"
adsense_through_trust_level: "Show your ads to users based on trust."
adsense_show_topic_list_top: "Disable topic_list_top ad"
adsense_topic_list_top_code: "Show leaderboard ad above topic lists."
adsense_mobile_topic_list_top_code: "Mobile - Show leaderboard ad above topic lists"
>>>>>>> amazon
adsense_topic_list_top_ad_sizes: "Choose your ad sizes"
adsense_show_topic_above_post_stream: "Disable ad at topic above post stream location"
adsense_topic_above_post_stream_code: "Enter ad code to display at topic above post stream location"
@ -41,8 +76,42 @@ en:
adsense_topic_above_suggested_code: "Enter ad code to display at topic above suggested location"
adsense_mobile_topic_above_suggested_code: "Enter ad code to display mobile ads at topic above suggested location"
adsense_topic_above_suggested_ad_sizes: "Choose your ad sizes"
<<<<<<< HEAD
adsense_post_bottom_code: "Enter ad code to display ads at post bottom location"
adsense_mobile_post_bottom_code: "Enter ad code to display mobile ads at post bottom location"
adsense_show_post_bottom: "Disable ad at post bottom location"
adsense_post_bottom_ad_sizes: "Choose your ad sizes"
adsense_nth_post_code: "Choose a post number for your ad to show in the post bottom location - this is the nth post"
adsense_nth_post_code: "Choose a post number for your ad to show in the post bottom location - this is the nth post"
=======
adsense_show_post_bottom: "Disable post_bottom ad"
adsense_post_bottom_code: "Show leaderboard ad post_bottom topics"
adsense_mobile_post_bottom_code: "Mobile - Show leaderboard ad post_bottom topics"
adsense_post_bottom_ad_sizes: "Choose your ad sizes"
adsense_nth_post_code: "Choose the Nth position for your ad to show"
amazon_through_trust_level: "Input trust level"
amazon_topic_list_top_src_code: "Input your Src code"
amazon_topic_list_top_ad_width_code: "Choose your ad width"
amazon_topic_list_top_ad_height_code: "Choose your ad height"
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_height_code: "Choose your ad height (Mobile)"
amazon_topic_above_post_stream_src_code: "Input your Src code"
amazon_topic_above_post_stream_ad_width_code: "Choose your ad width"
amazon_topic_above_post_stream_ad_height_code: "Choose your ad height"
amazon_mobile_topic_above_post_stream_src_code: "Input your Src code (Mobile)"
amazon_mobile_topic_above_post_stream_ad_width_code: "Choose your ad width (Mobile)"
amazon_mobile_topic_above_post_stream_ad_height_code: "Choose your ad height (Mobile)"
amazon_topic_above_suggested_src_code: "Input your Src code"
amazon_topic_above_suggested_ad_width_code: "Choose your ad width"
amazon_topic_above_suggested_ad_height_code: "Choose your ad height"
amazon_mobile_topic_above_suggested_src_code: "Input your Src code (Mobile)"
amazon_mobile_topic_above_suggested_ad_width_code: "Choose your ad width (Mobile)"
amazon_mobile_topic_above_suggested_ad_height_code: "Choose your ad height (Mobile)"
amazon_post_bottom_src_code: "Input your Src code"
amazon_post_bottom_ad_width_code: "Choose your ad width"
amazon_post_bottom_ad_height_code: "Choose your ad height"
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_height_code: "Choose your ad height (Mobile)"
amazon_nth_post_code: "Choose the Nth position for your ad to show"
>>>>>>> amazon

View File

@ -236,4 +236,84 @@ dfp_plugin:
dfp_target_post_bottom_value_code:
default: ''
type: value_list
client: true
client: true
amazon_plugin:
amazon_through_trust_level:
client: true
default: 2
amazon_topic_list_top_src_code:
client: true
default: ''
amazon_topic_list_top_ad_width_code:
client: true
default: ''
amazon_topic_list_top_ad_height_code:
client: true
default: ''
amazon_mobile_topic_list_top_src_code:
client: true
default: ''
amazon_mobile_topic_list_top_ad_width_code:
client: true
default: ''
amazon_mobile_topic_list_top_ad_height_code:
client: true
default: ''
amazon_topic_above_post_stream_src_code:
client: true
default: ''
amazon_topic_above_post_stream_ad_width_code:
client: true
default: ''
amazon_topic_above_post_stream_ad_height_code:
client: true
default: ''
amazon_mobile_topic_above_post_stream_src_code:
client: true
default: ''
amazon_mobile_topic_above_post_stream_ad_width_code:
client: true
default: ''
amazon_mobile_topic_above_post_stream_ad_height_code:
client: true
default: ''
amazon_topic_above_suggested_src_code:
client: true
default: ''
amazon_topic_above_suggested_ad_width_code:
client: true
default: ''
amazon_topic_above_suggested_ad_height_code:
client: true
default: ''
amazon_mobile_topic_above_suggested_src_code:
client: true
default: ''
amazon_mobile_topic_above_suggested_ad_width_code:
client: true
default: ''
amazon_mobile_topic_above_suggested_ad_height_code:
client: true
default: ''
amazon_post_bottom_src_code:
client: true
default: ''
amazon_nth_post_code:
client: true
default: ''
amazon_post_bottom_ad_width_code:
client: true
default: ''
amazon_post_bottom_ad_height_code:
client: true
default: ''
amazon_mobile_post_bottom_src_code:
client: true
default: ''
amazon_mobile_post_bottom_ad_width_code:
client: true
default: ''
amazon_mobile_post_bottom_ad_height_code:
client: true
default: ''

View File

@ -25,4 +25,14 @@ register_css <<CSS
margin: 0 auto;
}
.amazon-product-links {
padding: 3px;
margin-bottom: 10px;
clear: both;
}
.amazon-product-links .amazon-unit {
margin: 0 auto;
}
CSS