diff --git a/.DS_Store b/.DS_Store index 3ad4406..55e315b 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 index f693d79..d82b820 100755 --- a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 +++ b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 @@ -1,12 +1,22 @@ 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; +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,25 @@ 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) { + 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) { - 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) { + 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) { - 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) { + 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) { - 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) { + 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(); 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 7386dfb..bde0ec1 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,4 @@ {{#if postSpecificCount}} {{google-dfp-ad placement="post-bottom"}} -{{/if}} \ No newline at end of file +{{/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..f076fb3 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: + topic_list_top_ad_sizes: client: true - default: '' - dfp_size_topic_list_top_height_code: - client: true - default: '' + 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 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: + topic_above_post_stream_ad_sizes: client: true - default: '' - dfp_size_topic_above_post_stream_height_code: - client: true - default: '' + 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 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: + topic_above_suggested_ad_sizes: client: true - default: '' - dfp_size_topic_above_suggested_height_code: - client: true - default: '' + 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 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: + post_bottom_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 + dfp_show_post_bottom: client: true - default: false - dfp_show_size_3_example: - client: true - default: false - dfp_show_size_4_example: - 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: false \ No newline at end of file