From 013d6bc36319ff21ad2b47c1b5e3692f5ec7da25 Mon Sep 17 00:00:00 2001 From: Sarah Ni Date: Mon, 10 Aug 2015 14:04:21 +1000 Subject: [PATCH 1/2] Dropdown boxes added for each location --- .DS_Store | Bin 6148 -> 6148 bytes .../discourse/components/google-dfp-ad.js.es6 | 26 +++-- .../post-bottom/discourse-google-dfp.hbs | 2 +- ...7129bb0cbeb4d26e08da97f26fb7cc56cd329.css} | 8 +- config/locales/server.en.yml | 22 +--- config/settings.yml | 107 +++++++++--------- plugin.rb | 8 +- 7 files changed, 87 insertions(+), 86 deletions(-) rename auto_generated/{plugin_5e03562e98e357709eaba07c3a0e9054afdd7697.css => plugin_35b7129bb0cbeb4d26e08da97f26fb7cc56cd329.css} (65%) mode change 100755 => 100644 diff --git a/.DS_Store b/.DS_Store index 3ad4406a8359e1ffb2e5c461ace61400439b0bab..55e315b8f7cd4786fc0dd36a5485390aad9402e4 100644 GIT binary patch delta 55 zcmZoMXfc@J&&a+pU^g=(`(_>%S4K%ThD3&9AWUT_VJI#OF3QWv&r4@uU|`(r$2ym3 JGdss$egKk`4xa!3 delta 32 ocmZoMXfc@J&&akhU^g=(+h!gXSH{h`th1OVHppyd=lIJH0HI?E+5i9m diff --git a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 index f693d79..886d67a 100755 --- a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 +++ b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 @@ -7,6 +7,16 @@ var _loaded = false, _promise = null; +function splitWidthInt(value) { + var str = value.substring(0, 3); + return str.trim(); +} + +function splitHeightInt(value) { + var str = value.substring(4, 7); + return str.trim(); +} + function loadGoogle(settings) { if (_loaded) { return Ember.RSVP.resolve(); @@ -26,17 +36,17 @@ function loadGoogle(settings) { // Define our ad units - extend for mobile view. googletag.cmd.push(function() { - if (settings.dfp_topic_list_top_code && !settings.dfp_show_topic_list_top) { - googletag.defineSlot(settings.dfp_topic_list_top_code, [parseInt(settings.dfp_size_topic_list_top_width_code), parseInt(settings.dfp_size_topic_list_top_height_code)], 'div-gpt-ad-topic-list-top').addService(googletag.pubads()); + if (settings.dfp_topic_list_top_code && !settings.dfp_show_topic_list_top && settings.topic_list_top_ad_sizes) { + googletag.defineSlot(settings.dfp_topic_list_top_code, [parseInt(splitWidthInt(settings.topic_list_top_ad_sizes)), parseInt(splitHeightInt(settings.topic_list_top_ad_sizes))], 'div-gpt-ad-topic-list-top').addService(googletag.pubads()); } - if (settings.dfp_topic_above_post_stream_code && !settings.dfp_show_topic_above_post_stream) { - googletag.defineSlot(settings.dfp_topic_above_post_stream_code, [parseInt(settings.dfp_size_topic_above_post_stream_width_code), parseInt(settings.dfp_size_topic_above_post_stream_height_code)], 'div-gpt-ad-topic-above-post-stream').addService(googletag.pubads()); + if (settings.dfp_topic_above_post_stream_code && !settings.dfp_show_topic_above_post_stream && settings.topic_above_post_stream_ad_sizes) { + googletag.defineSlot(settings.dfp_topic_above_post_stream_code, [parseInt(splitWidthInt(settings.topic_above_post_stream_ad_sizes)), parseInt(splitHeightInt(settings.topic_above_post_stream_ad_sizes))], 'div-gpt-ad-topic-above-post-stream').addService(googletag.pubads()); } - if (settings.dfp_topic_above_suggested_code && !settings.dfp_show_topic_above_suggested) { - googletag.defineSlot(settings.dfp_topic_above_suggested_code, [parseInt(settings.dfp_size_topic_above_suggested_width_code), parseInt(settings.dfp_size_topic_above_suggested_height_code)], 'div-gpt-ad-topic-above-suggested').addService(googletag.pubads()); + if (settings.dfp_topic_above_suggested_code && !settings.dfp_show_topic_above_suggested && settings.topic_above_suggested_ad_sizes) { + googletag.defineSlot(settings.dfp_topic_above_suggested_code, [parseInt(splitWidthInt(settings.topic_above_suggested_ad_sizes)), parseInt(splitHeightInt(settings.topic_above_suggested_ad_sizes))], 'div-gpt-ad-topic-above-suggested').addService(googletag.pubads()); } - if (settings.dfp_post_bottom_code && !settings.dfp_show_post_bottom) { - googletag.defineSlot(settings.dfp_post_bottom_code, [parseInt(settings.dfp_size_post_bottom_width_code), parseInt(settings.dfp_size_post_bottom_height_code)], 'div-gpt-ad-post-bottom').addService(googletag.pubads()); + if (settings.dfp_post_bottom_code && !settings.dfp_show_post_bottom && settings.post_bottom_ad_sizes) { + googletag.defineSlot(settings.dfp_post_bottom_code, [parseInt(splitWidthInt(settings.post_bottom_ad_sizes)), parseInt(splitHeightInt(settings.post_bottom_ad_sizes))], 'div-gpt-ad-post-bottom').addService(googletag.pubads()); } googletag.pubads().enableSingleRequest(); googletag.enableServices(); diff --git a/assets/javascripts/discourse/templates/connectors/post-bottom/discourse-google-dfp.hbs b/assets/javascripts/discourse/templates/connectors/post-bottom/discourse-google-dfp.hbs index ea8e1c3..a3c1fc9 100644 --- a/assets/javascripts/discourse/templates/connectors/post-bottom/discourse-google-dfp.hbs +++ b/assets/javascripts/discourse/templates/connectors/post-bottom/discourse-google-dfp.hbs @@ -1,3 +1,3 @@ {{#if postSpecificCount}} {{google-dfp-ad placement="post-bottom"}} - {{/if}} +{{/if}} diff --git a/auto_generated/plugin_5e03562e98e357709eaba07c3a0e9054afdd7697.css b/auto_generated/plugin_35b7129bb0cbeb4d26e08da97f26fb7cc56cd329.css old mode 100755 new mode 100644 similarity index 65% rename from auto_generated/plugin_5e03562e98e357709eaba07c3a0e9054afdd7697.css rename to auto_generated/plugin_35b7129bb0cbeb4d26e08da97f26fb7cc56cd329.css index 677144a..9b1f860 --- a/auto_generated/plugin_5e03562e98e357709eaba07c3a0e9054afdd7697.css +++ b/auto_generated/plugin_35b7129bb0cbeb4d26e08da97f26fb7cc56cd329.css @@ -1,20 +1,20 @@ -.google-dfp-ad { +.discourse-google-dfp { padding: 3px; margin-bottom: 10px; clear: both; } -.google-dfp-ad .dfp-ad-unit { +.discourse-google-dfp .dfp-ad-unit { margin: 0 auto; } -.google-dfp-ad .google-dfp-ad-label { +.discourse-google-dfp .google-dfp-ad-label { width: 728px; margin: 0 auto; } -.google-dfp-ad .google-dfp-ad-label h2 { +.discourse-google-dfp .google-dfp-ad-label h2 { margin: 4px 0 !important; color: #858a8c; text-transform: uppercase; diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 4559e67..6df20c8 100755 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -2,28 +2,14 @@ en: site_settings: dfp_show_topic_list_top: "Disable topic_list_top ad" dfp_topic_list_top_code: "Show leaderboard ad above topic lists." + topic_list_top_ad_sizes: "Choose your ad size" dfp_show_topic_above_post_stream: "Disable topic_above_post_stream ad" dfp_topic_above_post_stream_code: "Show leaderboard ad above post stream" + topic_above_post_stream_ad_sizes: "Choose your ad size" dfp_show_topic_above_suggested: "Disable topic_above_suggested ad" dfp_topic_above_suggested_code: "Show leaderboard ad above suggested topics" + topic_above_suggested_ad_sizes: "Choose your ad size" dfp_show_post_bottom: "Disable post_bottom ad" dfp_post_bottom_code: "Show leaderboard ad post_bottom topics" - dfp_size_topic_list_top_width_code: "Put your ad topic list top size width!" - dfp_size_topic_list_top_height_code: "Put your ad topic above post stream size height!" - dfp_size_topic_above_post_stream_width_code: "Put your ad topic above post stream size width!" - dfp_size_topic_above_post_stream_height_code: "Put your ad topic list top size height!" - dfp_size_topic_above_suggested_width_code: "Put your ad topic above suggested size width!" - dfp_size_topic_above_suggested_height_code: "Put your ad topic above suggested size height!" - dfp_size_post_bottom_width_code: "Put your ad post bottom size width!" - dfp_size_post_bottom_height_code: "Put your ad post bottom size height!" dfp_nth_post_code: "Choose the Nth position for your ad to show" - dfp_show_size_1_example: "leaderboard 728x90" - dfp_show_size_2_example: "large rectangle 336x280" - dfp_show_size_3_example: "medium rectangle 300x250" - dfp_show_size_4_example: "large leaderboard 970x90" - dfp_show_size_5_example: "banner 468x60" - dfp_show_size_6_example: "half banner 234x60" - dfp_show_size_7_example: "button 125x125" - dfp_show_size_8_example: "small rectangle 180x150" - dfp_show_size_9_example: "small square 200x200" - dfp_show_size_10_example: "square 250x250" + post_bottom_ad_sizes: "Choose your ad size" diff --git a/config/settings.yml b/config/settings.yml index 890dd2b..0859ff3 100755 --- a/config/settings.yml +++ b/config/settings.yml @@ -2,82 +2,87 @@ ad_plugin: dfp_topic_list_top_code: client: true default: '' - dfp_size_topic_list_top_width_code: - client: true - default: '' - dfp_size_topic_list_top_height_code: - client: true - default: '' dfp_show_topic_list_top: client: true default: false dfp_topic_above_post_stream_code: client: true default: '' - dfp_size_topic_above_post_stream_width_code: - client: true - default: '' - dfp_size_topic_above_post_stream_height_code: - client: true - default: '' dfp_show_topic_above_post_stream: client: true default: false dfp_topic_above_suggested_code: client: true default: '' - dfp_size_topic_above_suggested_width_code: - client: true - default: '' - dfp_size_topic_above_suggested_height_code: - client: true - default: '' dfp_show_topic_above_suggested: client: true default: false dfp_post_bottom_code: client: true default: '' - dfp_size_post_bottom_width_code: - client: true - default: '' - dfp_size_post_bottom_height_code: - client: true - default: '' dfp_show_post_bottom: client: true default: false dfp_nth_post_code: client: true default: '' - dfp_show_size_1_example: + topic_list_top_ad_sizes: client: true - default: false - dfp_show_size_2_example: + default: '728*90 - leaderboard' + type: enum + choices: + - 728*90 - leaderboard + - 336*280 - large rectangle + - 300*250 - medium rectangle + - 970*90 - large leaderboard + - 468*60 - banner + - 234*60 - half banner + - 125*125 - button + - 180*150 - small rectangle + - 200*200 - small square + - 250*250 - square + topic_above_post_stream_ad_sizes: client: true - default: false - dfp_show_size_3_example: + default: '728*90 - leaderboard' + type: enum + choices: + - 728*90 - leaderboard + - 336*280 - large rectangle + - 300*250 - medium rectangle + - 970*90 - large leaderboard + - 468*60 - banner + - 234*60 - half banner + - 125*125 - button + - 180*150 - small rectangle + - 200*200 - small square + - 250*250 - square + topic_above_suggested_ad_sizes: client: true - default: false - dfp_show_size_4_example: + default: '728*90 - leaderboard' + type: enum + choices: + - 728*90 - leaderboard + - 336*280 - large rectangle + - 300*250 - medium rectangle + - 970*90 - large leaderboard + - 468*60 - banner + - 234*60 - half banner + - 125*125 - button + - 180*150 - small rectangle + - 200*200 - small square + - 250*250 - square + post_bottom_ad_sizes: client: true - default: false - dfp_show_size_5_example: - client: true - default: false - dfp_show_size_6_example: - client: true - default: false - dfp_show_size_7_example: - client: true - default: false - dfp_show_size_8_example: - client: true - default: false - dfp_show_size_9_example: - client: true - default: false - dfp_show_size_10_example: - client: true - default: false - + default: '728*90 - leaderboard' + type: enum + choices: + - 728*90 - leaderboard + - 336*280 - large rectangle + - 300*250 - medium rectangle + - 970*90 - large leaderboard + - 468*60 - banner + - 234*60 - half banner + - 125*125 - button + - 180*150 - small rectangle + - 200*200 - small square + - 250*250 - square \ No newline at end of file diff --git a/plugin.rb b/plugin.rb index 94c8feb..3d18251 100755 --- a/plugin.rb +++ b/plugin.rb @@ -5,22 +5,22 @@ register_css < Date: Mon, 10 Aug 2015 14:19:51 +1000 Subject: [PATCH 2/2] Container responsive to ad sizes --- .../discourse/components/google-dfp-ad.js.es6 | 12 ++++- config/settings.yml | 50 +++++++++---------- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 index 886d67a..d82b820 100755 --- a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 +++ b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 @@ -1,7 +1,7 @@ import loadScript from 'discourse/lib/load-script'; -const const_width = 300; -const const_height = 250; +var const_width = ''; +var const_height = ''; var _loaded = false, _promise = null; @@ -37,15 +37,23 @@ function loadGoogle(settings) { // Define our ad units - extend for mobile view. googletag.cmd.push(function() { if (settings.dfp_topic_list_top_code && !settings.dfp_show_topic_list_top && settings.topic_list_top_ad_sizes) { + const_width = parseInt(splitWidthInt(settings.topic_list_top_ad_sizes)); + const_height = parseInt(splitHeightInt(settings.topic_list_top_ad_sizes)); googletag.defineSlot(settings.dfp_topic_list_top_code, [parseInt(splitWidthInt(settings.topic_list_top_ad_sizes)), parseInt(splitHeightInt(settings.topic_list_top_ad_sizes))], 'div-gpt-ad-topic-list-top').addService(googletag.pubads()); } if (settings.dfp_topic_above_post_stream_code && !settings.dfp_show_topic_above_post_stream && settings.topic_above_post_stream_ad_sizes) { + const_width = parseInt(splitWidthInt(settings.topic_above_post_stream_ad_sizes)); + const_height = parseInt(splitHeightInt(settings.topic_above_post_stream_ad_sizes)); googletag.defineSlot(settings.dfp_topic_above_post_stream_code, [parseInt(splitWidthInt(settings.topic_above_post_stream_ad_sizes)), parseInt(splitHeightInt(settings.topic_above_post_stream_ad_sizes))], 'div-gpt-ad-topic-above-post-stream').addService(googletag.pubads()); } if (settings.dfp_topic_above_suggested_code && !settings.dfp_show_topic_above_suggested && settings.topic_above_suggested_ad_sizes) { + const_width = parseInt(splitWidthInt(settings.topic_above_suggested_ad_sizes)); + const_height = parseInt(splitHeightInt(settings.topic_above_suggested_ad_sizes)); googletag.defineSlot(settings.dfp_topic_above_suggested_code, [parseInt(splitWidthInt(settings.topic_above_suggested_ad_sizes)), parseInt(splitHeightInt(settings.topic_above_suggested_ad_sizes))], 'div-gpt-ad-topic-above-suggested').addService(googletag.pubads()); } if (settings.dfp_post_bottom_code && !settings.dfp_show_post_bottom && settings.post_bottom_ad_sizes) { + const_width = parseInt(splitWidthInt(settings.post_bottom_ad_sizes)); + const_height = parseInt(splitHeightInt(settings.post_bottom_ad_sizes)); googletag.defineSlot(settings.dfp_post_bottom_code, [parseInt(splitWidthInt(settings.post_bottom_ad_sizes)), parseInt(splitHeightInt(settings.post_bottom_ad_sizes))], 'div-gpt-ad-post-bottom').addService(googletag.pubads()); } googletag.pubads().enableSingleRequest(); diff --git a/config/settings.yml b/config/settings.yml index 0859ff3..f076fb3 100755 --- a/config/settings.yml +++ b/config/settings.yml @@ -2,30 +2,6 @@ ad_plugin: dfp_topic_list_top_code: client: true default: '' - dfp_show_topic_list_top: - client: true - default: false - dfp_topic_above_post_stream_code: - client: true - default: '' - dfp_show_topic_above_post_stream: - client: true - default: false - dfp_topic_above_suggested_code: - client: true - default: '' - dfp_show_topic_above_suggested: - client: true - default: false - dfp_post_bottom_code: - client: true - default: '' - dfp_show_post_bottom: - client: true - default: false - dfp_nth_post_code: - client: true - default: '' topic_list_top_ad_sizes: client: true default: '728*90 - leaderboard' @@ -41,6 +17,12 @@ ad_plugin: - 180*150 - small rectangle - 200*200 - small square - 250*250 - square + dfp_show_topic_list_top: + client: true + default: false + dfp_topic_above_post_stream_code: + client: true + default: '' topic_above_post_stream_ad_sizes: client: true default: '728*90 - leaderboard' @@ -56,6 +38,12 @@ ad_plugin: - 180*150 - small rectangle - 200*200 - small square - 250*250 - square + dfp_show_topic_above_post_stream: + client: true + default: false + dfp_topic_above_suggested_code: + client: true + default: '' topic_above_suggested_ad_sizes: client: true default: '728*90 - leaderboard' @@ -71,6 +59,15 @@ ad_plugin: - 180*150 - small rectangle - 200*200 - small square - 250*250 - square + dfp_show_topic_above_suggested: + client: true + default: false + dfp_post_bottom_code: + client: true + default: '' + dfp_nth_post_code: + client: true + default: '' post_bottom_ad_sizes: client: true default: '728*90 - leaderboard' @@ -85,4 +82,7 @@ ad_plugin: - 125*125 - button - 180*150 - small rectangle - 200*200 - small square - - 250*250 - square \ No newline at end of file + - 250*250 - square + dfp_show_post_bottom: + client: true + default: false \ No newline at end of file