From b4f177d947fd70406c31081e10b25ff7cd187401 Mon Sep 17 00:00:00 2001 From: Sarah Ni Date: Fri, 11 Sep 2015 16:33:55 +1000 Subject: [PATCH] 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