From 082f4e336d22139fa66a94449654123f42aab82f Mon Sep 17 00:00:00 2001 From: Sarah Ni Date: Thu, 10 Sep 2015 12:23:36 +1000 Subject: [PATCH 1/6] amazon settings --- config/settings.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/config/settings.yml b/config/settings.yml index 9b62578..7e119dd 100755 --- a/config/settings.yml +++ b/config/settings.yml @@ -236,4 +236,24 @@ dfp_plugin: dfp_target_post_bottom_value_code: default: '' type: value_list - client: true \ No newline at end of file + client: true + +amazon_plugin: + amazon_topic_list_top_code: + client: true + default: '' + amazon_topic_list_top_ad_sizes: + client: true + default: '728*90 - leaderboard' + type: enum + choices: + - 728*90 - leaderboard + - 234*60 - small banner + - 300*250 - medium rectangle + - 468*60 - banner + - 125*125 - button + - 120*90 - small rectangle + - 120*60 - mini rectangle + - 88*31 - button + - 160*600 - vertical leaderboard + - 120*240 - product link \ No newline at end of file From 2d752d8b2f32243459d68b02ce9f4bfe48712990 Mon Sep 17 00:00:00 2001 From: Sarah Ni Date: Thu, 10 Sep 2015 22:48:14 +1000 Subject: [PATCH 2/6] basic amazon product link inputs added and works --- .../components/amazon-product-links.js.es6 | 56 +++++++++++++++++++ .../components/amazon-product-links.hbs | 12 ++++ .../discourse-adplugin.hbs | 3 + .../initializers/extend-post-model.js.es6 | 4 ++ ...bae62698596cbd1cca7ad6261ef903cf8fc2c.css} | 10 ++++ config/locales/client.en.yml | 3 +- config/locales/server.en.yml | 5 +- config/settings.yml | 6 ++ plugin.rb | 10 ++++ 9 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 assets/javascripts/discourse/components/amazon-product-links.js.es6 create mode 100644 assets/javascripts/discourse/templates/components/amazon-product-links.hbs rename auto_generated/{plugin_e37c3ee1ca7c7c4d4ef14a99312037cc7c47ecb5.css => plugin_954bae62698596cbd1cca7ad6261ef903cf8fc2c.css} (64%) diff --git a/assets/javascripts/discourse/components/amazon-product-links.js.es6 b/assets/javascripts/discourse/components/amazon-product-links.js.es6 new file mode 100644 index 0000000..e57a0fb --- /dev/null +++ b/assets/javascripts/discourse/components/amazon-product-links.js.es6 @@ -0,0 +1,56 @@ +var amazon_code = ''; +var amazon_width = ''; +var amazon_height = ''; +var amazon_mobile_width = 320; +var amazon_mobile_height = 50; +var user_input = Discourse.SiteSettings.amazon_topic_list_top_code; +var currentUser = Discourse.User.current(); + +function splitWidthInt(value) { + var str = value.substring(0, 3); + return str.trim(); +} + +function splitHeightInt(value) { + var str = value.substring(4, 7); + return str.trim(); +} + +if (Discourse.SiteSettings.amazon_topic_list_top_code) { + if (!((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.amazon_through_trust_level))) { + user_input = Discourse.SiteSettings.amazon_topic_list_top_code; + amazon_width = parseInt(splitWidthInt(Discourse.SiteSettings.amazon_topic_list_top_ad_sizes)); + amazon_height = parseInt(splitHeightInt(Discourse.SiteSettings.amazon_topic_list_top_ad_sizes)); + } + //if (Discourse.Mobile.mobileView && Discourse.SiteSettings.adsense_mobile_topic_list_top_code) { + // data["topic-list-top"]["ad_mobile_code"] = Discourse.SiteSettings.adsense_mobile_topic_list_top_code; + //} +} + +// Ember component - the class is the adblock and css +export default Ember.Component.extend({ + amazon_width: amazon_width, + amazon_height: amazon_height, + amazon_mobile_width: amazon_mobile_width, + amazon_mobile_height: amazon_mobile_height, + user_input: user_input, + + classNames: ['amazon-product-links'], + + 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('amazon_mobile_width')}px; height: ${this.get('amazon_mobile_height')}px;`.htmlSafe(); + }.property('amazon_mobile_width', 'amazon_mobile_height'), + + userInput: function() { + return `${this.get('user_input')}`.htmlSafe(); + }.property('user_input'), + + checkTrustLevels: function() { + return !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.amazon_through_trust_level)); + }.property('trust_level'), + +}); \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/components/amazon-product-links.hbs b/assets/javascripts/discourse/templates/components/amazon-product-links.hbs new file mode 100644 index 0000000..00dcc5f --- /dev/null +++ b/assets/javascripts/discourse/templates/components/amazon-product-links.hbs @@ -0,0 +1,12 @@ +{{#if site.mobileView}} + {{#if checkTrustLevels}} + + {{/if}} + +{{else}} + {{#if checkTrustLevels}} + + {{/if}} +{{/if}} \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/connectors/discovery-list-container-top/discourse-adplugin.hbs b/assets/javascripts/discourse/templates/connectors/discovery-list-container-top/discourse-adplugin.hbs index 20b187d..723659e 100644 --- a/assets/javascripts/discourse/templates/connectors/discovery-list-container-top/discourse-adplugin.hbs +++ b/assets/javascripts/discourse/templates/connectors/discovery-list-container-top/discourse-adplugin.hbs @@ -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_code}} + {{amazon-product-links placement="topic-list-top"}} +{{/if}} \ No newline at end of file diff --git a/assets/javascripts/initializers/extend-post-model.js.es6 b/assets/javascripts/initializers/extend-post-model.js.es6 index 22f911d..534f642 100644 --- a/assets/javascripts/initializers/extend-post-model.js.es6 +++ b/assets/javascripts/initializers/extend-post-model.js.es6 @@ -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'), }); } }; diff --git a/auto_generated/plugin_e37c3ee1ca7c7c4d4ef14a99312037cc7c47ecb5.css b/auto_generated/plugin_954bae62698596cbd1cca7ad6261ef903cf8fc2c.css similarity index 64% rename from auto_generated/plugin_e37c3ee1ca7c7c4d4ef14a99312037cc7c47ecb5.css rename to auto_generated/plugin_954bae62698596cbd1cca7ad6261ef903cf8fc2c.css index a426f0c..ff9eb03 100644 --- a/auto_generated/plugin_e37c3ee1ca7c7c4d4ef14a99312037cc7c47ecb5.css +++ b/auto_generated/plugin_954bae62698596cbd1cca7ad6261ef903cf8fc2c.css @@ -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; +} + diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 1d8dc2f..191c522 100755 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -4,4 +4,5 @@ en: site_settings: categories: dfp_plugin: 'DFP Plugin' - adsense_plugin: 'Adsense Plugin' \ No newline at end of file + adsense_plugin: 'Adsense Plugin' + amazon_plugin: 'Amazon Plugin' \ No newline at end of file diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 2da21dd..6bcd6f2 100755 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -45,4 +45,7 @@ en: 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_nth_post_code: "Choose the Nth position for your ad to show" \ No newline at end of file + adsense_nth_post_code: "Choose the Nth position for your ad to show" + amazon_topic_list_top_code: "Insert your src code here" + amazon_topic_list_top_ad_sizes: "Choose your ad sizes" + amazon_nth_post_code: "Choose the Nth position for your ad to show" \ No newline at end of file diff --git a/config/settings.yml b/config/settings.yml index 7e119dd..ef66d89 100755 --- a/config/settings.yml +++ b/config/settings.yml @@ -242,6 +242,12 @@ amazon_plugin: amazon_topic_list_top_code: client: true default: '' + amazon_through_trust_level: + client: true + default: 2 + amazon_nth_post_code: + client: true + default: '' amazon_topic_list_top_ad_sizes: client: true default: '728*90 - leaderboard' diff --git a/plugin.rb b/plugin.rb index 79d6be8..ecf23a5 100755 --- a/plugin.rb +++ b/plugin.rb @@ -25,4 +25,14 @@ register_css < Date: Fri, 11 Sep 2015 16:33:55 +1000 Subject: [PATCH 3/6] Product and Easy Ads work, still building Native Ads --- .../components/amazon-product-links.js.es6 | 56 +++++++++++++-- .../components/amazon-product-links.hbs | 72 ++++++++++++++++--- .../discourse-adplugin.hbs | 2 +- config/locales/server.en.yml | 29 +++++--- config/settings.yml | 70 +++++++++++++----- 5 files changed, 187 insertions(+), 42 deletions(-) diff --git a/assets/javascripts/discourse/components/amazon-product-links.js.es6 b/assets/javascripts/discourse/components/amazon-product-links.js.es6 index e57a0fb..731656b 100644 --- a/assets/javascripts/discourse/components/amazon-product-links.js.es6 +++ b/assets/javascripts/discourse/components/amazon-product-links.js.es6 @@ -3,8 +3,12 @@ var amazon_width = ''; var amazon_height = ''; var amazon_mobile_width = 320; var amazon_mobile_height = 50; -var user_input = Discourse.SiteSettings.amazon_topic_list_top_code; +var user_input = ''; var currentUser = Discourse.User.current(); +var product_type = 'Product/Easy Banner Link'; +var custom_type = 'Native Shopping Ad - Recommended'; +var recommended_type = 'Native Shopping Ad - Custom'; +var search_type = 'Native Shopping Ad - Search'; function splitWidthInt(value) { var str = value.substring(0, 3); @@ -12,21 +16,40 @@ function splitWidthInt(value) { } function splitHeightInt(value) { - var str = value.substring(4, 7); + var str = value.substring(0, 3); return str.trim(); } -if (Discourse.SiteSettings.amazon_topic_list_top_code) { - if (!((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.amazon_through_trust_level))) { - user_input = Discourse.SiteSettings.amazon_topic_list_top_code; - amazon_width = parseInt(splitWidthInt(Discourse.SiteSettings.amazon_topic_list_top_ad_sizes)); - amazon_height = parseInt(splitHeightInt(Discourse.SiteSettings.amazon_topic_list_top_ad_sizes)); +if (Discourse.SiteSettings.amazon_topic_list_top_src_code) { + if (Discourse.SiteSettings.amazon_topic_list_top_ad_category === 'Product/Easy Banner Link' && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.amazon_through_trust_level))) { + user_input = Discourse.SiteSettings.amazon_topic_list_top_src_code; + amazon_width = parseInt(Discourse.SiteSettings.amazon_topic_list_top_ad_width_code); + amazon_height = parseInt(Discourse.SiteSettings.amazon_topic_list_top_ad_height_code); } //if (Discourse.Mobile.mobileView && 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.amazon_topic_list_top_ad_category === "Native Shopping Ad - Recommended") { + user_input = Discourse.SiteSettings.amazon_topic_list_top_src_code; +} +/* 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_title_code: "Input your Ad Description" + 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_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_code: "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" */ + // Ember component - the class is the adblock and css export default Ember.Component.extend({ amazon_width: amazon_width, @@ -34,6 +57,10 @@ export default Ember.Component.extend({ amazon_mobile_width: amazon_mobile_width, amazon_mobile_height: amazon_mobile_height, user_input: user_input, + product_type: product_type, + recommended_type: recommended_type, + search_type: search_type, + custom_type: custom_type, classNames: ['amazon-product-links'], @@ -53,4 +80,19 @@ export default Ember.Component.extend({ return !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.amazon_through_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'), }); \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/components/amazon-product-links.hbs b/assets/javascripts/discourse/templates/components/amazon-product-links.hbs index 00dcc5f..e6f7ac9 100644 --- a/assets/javascripts/discourse/templates/components/amazon-product-links.hbs +++ b/assets/javascripts/discourse/templates/components/amazon-product-links.hbs @@ -1,12 +1,66 @@ -{{#if site.mobileView}} - {{#if checkTrustLevels}} - - {{/if}} +{{#if checkTrustLevels}} + {{#if typeProductCategory}} + {{#if site.mobileView}} + + {{else}} +
+ +
+ {{/if}} + {{else}} + {{#if typeRecommendedCategory}} + + + {{/if}} -{{else}} - {{#if checkTrustLevels}} - + {{#if typeSearchCategory}} + + + {{/if}} + + {{#if typeCustomCategory}} + + + {{/if}} {{/if}} {{/if}} \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/connectors/discovery-list-container-top/discourse-adplugin.hbs b/assets/javascripts/discourse/templates/connectors/discovery-list-container-top/discourse-adplugin.hbs index 723659e..5718677 100644 --- a/assets/javascripts/discourse/templates/connectors/discovery-list-container-top/discourse-adplugin.hbs +++ b/assets/javascripts/discourse/templates/connectors/discovery-list-container-top/discourse-adplugin.hbs @@ -4,6 +4,6 @@ {{#if siteSettings.dfp_topic_list_top_code}} {{google-dfp-ad placement="topic-list-top"}} {{/if}} -{{#if siteSettings.amazon_topic_list_top_code}} +{{#if siteSettings.amazon_topic_list_top_src_code}} {{amazon-product-links placement="topic-list-top"}} {{/if}} \ No newline at end of file diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 6bcd6f2..8000bb9 100755 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -5,33 +5,33 @@ en: 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." - topic_list_top_ad_sizes: "Choose your ad size" + 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" - topic_above_post_stream_ad_sizes: "Choose your ad size" + 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" - topic_above_suggested_ad_sizes: "Choose your ad size" + 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" - post_bottom_ad_sizes: "Choose your ad size" + 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." + adsense_mobile_topic_list_top_code: "Mobile - Show leaderboard ad above topic lists" adsense_topic_list_top_ad_sizes: "Choose your ad sizes" adsense_show_topic_above_post_stream: "Disable topic_above_post_stream ad" adsense_topic_above_post_stream_code: "Show leaderboard ad above post stream" @@ -46,6 +46,19 @@ en: adsense_show_post_bottom: "Disable post_bottom ad" adsense_post_bottom_ad_sizes: "Choose your ad sizes" adsense_nth_post_code: "Choose the Nth position for your ad to show" - amazon_topic_list_top_code: "Insert your src code here" - amazon_topic_list_top_ad_sizes: "Choose your ad sizes" - amazon_nth_post_code: "Choose the Nth position for your ad to show" \ No newline at end of file + amazon_topic_list_top_ad_category: "Choose your Amazon Ad type" + 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_title_code: "Input your Ad Description" + 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_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" \ No newline at end of file diff --git a/config/settings.yml b/config/settings.yml index ef66d89..f9d6c90 100755 --- a/config/settings.yml +++ b/config/settings.yml @@ -239,7 +239,58 @@ dfp_plugin: client: true amazon_plugin: - amazon_topic_list_top_code: + amazon_topic_list_top_ad_category: + client: true + default: 'Product/Easy Banner Link' + 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: + client: true + default: '' + amazon_topic_list_top_title_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_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: @@ -247,19 +298,4 @@ amazon_plugin: default: 2 amazon_nth_post_code: client: true - default: '' - amazon_topic_list_top_ad_sizes: - client: true - default: '728*90 - leaderboard' - type: enum - choices: - - 728*90 - leaderboard - - 234*60 - small banner - - 300*250 - medium rectangle - - 468*60 - banner - - 125*125 - button - - 120*90 - small rectangle - - 120*60 - mini rectangle - - 88*31 - button - - 160*600 - vertical leaderboard - - 120*240 - product link \ No newline at end of file + default: '' \ No newline at end of file From cc2572e3f1c76c1266394447d2c53951a9da4289 Mon Sep 17 00:00:00 2001 From: vi Date: Wed, 16 Sep 2015 11:44:31 +1000 Subject: [PATCH 4/6] Added working product links --- .../components/amazon-product-links.js.es6 | 139 ++++++++++++------ .../post-bottom/discourse-adplugin.hbs | 3 + .../discourse-adplugin.hbs | 3 + .../discourse-adplugin.hbs | 3 + config/locales/client.en.yml | 6 +- config/locales/server.en.yml | 23 ++- config/settings.yml | 63 ++++++++ 7 files changed, 188 insertions(+), 52 deletions(-) diff --git a/assets/javascripts/discourse/components/amazon-product-links.js.es6 b/assets/javascripts/discourse/components/amazon-product-links.js.es6 index 731656b..f7f315c 100644 --- a/assets/javascripts/discourse/components/amazon-product-links.js.es6 +++ b/assets/javascripts/discourse/components/amazon-product-links.js.es6 @@ -1,14 +1,11 @@ -var amazon_code = ''; var amazon_width = ''; var amazon_height = ''; -var amazon_mobile_width = 320; -var amazon_mobile_height = 50; +var mobile_amazon_width = ''; +var mobile_amazon_height = ''; var user_input = ''; +var user_input_mobile = ''; var currentUser = Discourse.User.current(); var product_type = 'Product/Easy Banner Link'; -var custom_type = 'Native Shopping Ad - Recommended'; -var recommended_type = 'Native Shopping Ad - Custom'; -var search_type = 'Native Shopping Ad - Search'; function splitWidthInt(value) { var str = value.substring(0, 3); @@ -20,62 +17,108 @@ function splitHeightInt(value) { return str.trim(); } -if (Discourse.SiteSettings.amazon_topic_list_top_src_code) { - if (Discourse.SiteSettings.amazon_topic_list_top_ad_category === 'Product/Easy Banner Link' && !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.amazon_through_trust_level))) { - user_input = Discourse.SiteSettings.amazon_topic_list_top_src_code; - amazon_width = parseInt(Discourse.SiteSettings.amazon_topic_list_top_ad_width_code); - amazon_height = parseInt(Discourse.SiteSettings.amazon_topic_list_top_ad_height_code); - } - //if (Discourse.Mobile.mobileView && Discourse.SiteSettings.adsense_mobile_topic_list_top_code) { - // data["topic-list-top"]["ad_mobile_code"] = Discourse.SiteSettings.adsense_mobile_topic_list_top_code; - //} +var data = { + "topic-list-top" : {}, + "topic-above-post-stream" : {}, + "topic-above-suggested" : {}, + "post-bottom" : {} } -if (Discourse.SiteSettings.amazon_topic_list_top_ad_category === "Native Shopping Ad - Recommended") { - user_input = Discourse.SiteSettings.amazon_topic_list_top_src_code; + +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) { + 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); + } } -/* 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_title_code: "Input your Ad Description" - 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_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_code: "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_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({ amazon_width: amazon_width, amazon_height: amazon_height, - amazon_mobile_width: amazon_mobile_width, - amazon_mobile_height: amazon_mobile_height, + mobile_amazon_width: mobile_amazon_width, + mobile_amazon_height: mobile_amazon_height, user_input: user_input, + user_input_mobile: user_input_mobile, product_type: product_type, - recommended_type: recommended_type, - search_type: search_type, - custom_type: custom_type, + // recommended_type: recommended_type, + // search_type: search_type, + // custom_type: custom_type, 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('amazon_mobile_width')}px; height: ${this.get('amazon_mobile_height')}px;`.htmlSafe(); - }.property('amazon_mobile_width', 'amazon_mobile_height'), + 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'), @@ -84,15 +127,15 @@ export default Ember.Component.extend({ 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'), + // 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'), + // 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'), + // typeCustomCategory: function() { + // return Discourse.SiteSettings.amazon_topic_list_top_ad_category === this.get('custom_type'); + // }.property('custom_type'), }); \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/connectors/post-bottom/discourse-adplugin.hbs b/assets/javascripts/discourse/templates/connectors/post-bottom/discourse-adplugin.hbs index 813f65e..84f0984 100644 --- a/assets/javascripts/discourse/templates/connectors/post-bottom/discourse-adplugin.hbs +++ b/assets/javascripts/discourse/templates/connectors/post-bottom/discourse-adplugin.hbs @@ -3,4 +3,7 @@ {{/if}} {{#if postSpecificCountDFP}} {{google-dfp-ad placement="post-bottom"}} +{{/if}} +{{#if postSpecificCountAmazon}} + {{amazon-product-links placement="post-bottom"}} {{/if}} \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/connectors/topic-above-post-stream/discourse-adplugin.hbs b/assets/javascripts/discourse/templates/connectors/topic-above-post-stream/discourse-adplugin.hbs index b9d5657..59e6ffd 100644 --- a/assets/javascripts/discourse/templates/connectors/topic-above-post-stream/discourse-adplugin.hbs +++ b/assets/javascripts/discourse/templates/connectors/topic-above-post-stream/discourse-adplugin.hbs @@ -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}} \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/connectors/topic-above-suggested/discourse-adplugin.hbs b/assets/javascripts/discourse/templates/connectors/topic-above-suggested/discourse-adplugin.hbs index c429a37..f739266 100644 --- a/assets/javascripts/discourse/templates/connectors/topic-above-suggested/discourse-adplugin.hbs +++ b/assets/javascripts/discourse/templates/connectors/topic-above-suggested/discourse-adplugin.hbs @@ -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}} \ No newline at end of file diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 191c522..853de08 100755 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -3,6 +3,6 @@ en: admin: site_settings: categories: - dfp_plugin: 'DFP Plugin' - adsense_plugin: 'Adsense Plugin' - amazon_plugin: 'Amazon Plugin' \ No newline at end of file + dfp_plugin: 'DFP' + adsense_plugin: 'Adsense' + amazon_plugin: 'Amazon Links/Banners' \ No newline at end of file diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 8000bb9..5abec75 100755 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -61,4 +61,25 @@ en: 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" \ No newline at end of file + amazon_through_trust_level: "Input trust level" + 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)" \ No newline at end of file diff --git a/config/settings.yml b/config/settings.yml index f9d6c90..e94d7ca 100755 --- a/config/settings.yml +++ b/config/settings.yml @@ -296,6 +296,69 @@ amazon_plugin: amazon_through_trust_level: client: true default: 2 + 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: '' \ No newline at end of file From 0adc5bfca7a2a8dc46a327a8032697324b71756a Mon Sep 17 00:00:00 2001 From: vi Date: Wed, 16 Sep 2015 12:11:50 +1000 Subject: [PATCH 5/6] Refactored to only have amazon link/banner ads and refactored for check trust levels --- .../components/amazon-product-links.js.es6 | 112 +++++++----------- .../components/google-adsense.js.es6 | 12 +- .../components/amazon-product-links.hbs | 73 ++---------- .../templates/components/google-adsense.hbs | 48 ++++---- .../templates/components/google-dfp-ad.hbs | 11 +- config/locales/server.en.yml | 19 +-- config/settings.yml | 49 +------- 7 files changed, 95 insertions(+), 229 deletions(-) diff --git a/assets/javascripts/discourse/components/amazon-product-links.js.es6 b/assets/javascripts/discourse/components/amazon-product-links.js.es6 index f7f315c..e7d3e10 100644 --- a/assets/javascripts/discourse/components/amazon-product-links.js.es6 +++ b/assets/javascripts/discourse/components/amazon-product-links.js.es6 @@ -5,7 +5,6 @@ var mobile_amazon_height = ''; var user_input = ''; var user_input_mobile = ''; var currentUser = Discourse.User.current(); -var product_type = 'Product/Easy Banner Link'; function splitWidthInt(value) { var str = value.substring(0, 3); @@ -25,60 +24,56 @@ 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) { - 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_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_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_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_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); - } +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); } - // 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({ amazon_width: amazon_width, amazon_height: amazon_height, @@ -86,10 +81,6 @@ export default Ember.Component.extend({ mobile_amazon_height: mobile_amazon_height, user_input: user_input, 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'], @@ -123,19 +114,4 @@ export default Ember.Component.extend({ return !((currentUser) && (currentUser.get('trust_level') > Discourse.SiteSettings.amazon_through_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'), }); \ No newline at end of file diff --git a/assets/javascripts/discourse/components/google-adsense.js.es6 b/assets/javascripts/discourse/components/google-adsense.js.es6 index f368071..b1626ce 100644 --- a/assets/javascripts/discourse/components/google-adsense.js.es6 +++ b/assets/javascripts/discourse/components/google-adsense.js.es6 @@ -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'), }); \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/components/amazon-product-links.hbs b/assets/javascripts/discourse/templates/components/amazon-product-links.hbs index e6f7ac9..5ddf9b5 100644 --- a/assets/javascripts/discourse/templates/components/amazon-product-links.hbs +++ b/assets/javascripts/discourse/templates/components/amazon-product-links.hbs @@ -1,66 +1,11 @@ {{#if checkTrustLevels}} - {{#if typeProductCategory}} - {{#if site.mobileView}} - - {{else}} -
- -
- {{/if}} - {{else}} - {{#if typeRecommendedCategory}} - - - {{/if}} - - {{#if typeSearchCategory}} - - - {{/if}} - - {{#if typeCustomCategory}} - - - {{/if}} - {{/if}} + {{#if site.mobileView}} + + {{else}} +
+ +
+ {{/if}} {{/if}} \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/components/google-adsense.hbs b/assets/javascripts/discourse/templates/components/google-adsense.hbs index 1401e5d..53c645d 100644 --- a/assets/javascripts/discourse/templates/components/google-adsense.hbs +++ b/assets/javascripts/discourse/templates/components/google-adsense.hbs @@ -1,27 +1,29 @@ -{{#if site.mobileView}} -
- - - - -
-{{else}} -
- - +{{#if checkTrustLevels}} + {{#if site.mobileView}} +
+ + + + +
+ {{else}} +
+ + - -
+ +
+ {{/if}} {{/if}} diff --git a/assets/javascripts/discourse/templates/components/google-dfp-ad.hbs b/assets/javascripts/discourse/templates/components/google-dfp-ad.hbs index 256bf73..480e1cf 100755 --- a/assets/javascripts/discourse/templates/components/google-dfp-ad.hbs +++ b/assets/javascripts/discourse/templates/components/google-dfp-ad.hbs @@ -1,17 +1,12 @@ -{{#if site.mobileView}} +{{#if checkTrustLevels}} {{#if loadedGoogletag}} - {{#if checkTrustLevels}} + {{#if site.mobileView}}
- {{/if}} - {{/if}} - -{{else}} - {{#if loadedGoogletag}} - {{#if checkTrustLevels}} + {{else}}