Successfully merge with bug in cmd push

This commit is contained in:
vi 2015-08-25 14:30:23 +10:00
parent 3808410ac2
commit d179ed4fe9
16 changed files with 338 additions and 51 deletions

View File

@ -0,0 +1,87 @@
import PageTracker from 'discourse/lib/page-tracker';
var ad_width = '';
var ad_height = '';
var ad_code = '';
var publisher_id = Discourse.SiteSettings.adsense_publisher_code;
function splitWidthInt(value) {
var str = value.substring(0, 3);
return str.trim();
}
function splitHeightInt(value) {
var str = value.substring(4, 7);
return str.trim();
}
PageTracker.current().on('change', function(url) {
var ads = document.getElementById("adsense_loader");
if (ads) {
// clear the old element and its state
//ads.remove();
ads.parentNode.removeChild(ads);
for (var key in window) {
if (key.indexOf("google") !== -1){
window[key] = undefined;
}
}
}
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.id="adsense_loader";
ga.src = '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
});
if (Discourse.SiteSettings.adsense_publisher_code) {
if (Discourse.SiteSettings.adsense_topic_list_top_code && !Discourse.SiteSettings.adsense_show_topic_list_top) {
ad_code = Discourse.SiteSettings.adsense_topic_list_top_code;
ad_width = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_list_top_ad_sizes));
ad_height = parseInt(splitHeightInt(Discourse.SiteSettings.adsense_topic_list_top_ad_sizes));
}
if (Discourse.SiteSettings.adsense_topic_above_post_stream_code && !Discourse.SiteSettings.adsense_show_topic_above_post_stream) {
ad_code = Discourse.SiteSettings.adsense_topic_above_post_stream_code;
ad_width = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_above_post_stream_ad_sizes));
ad_height = parseInt(splitHeightInt(Discourse.SiteSettings.adsense_topic_above_post_stream_ad_sizes));
}
if (Discourse.SiteSettings.adsense_topic_above_suggested_code && !Discourse.SiteSettings.adsense_show_topic_above_suggested) {
ad_code = Discourse.SiteSettings.adsense_topic_above_suggested_code;
ad_width = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_topic_above_suggested_ad_sizes));
ad_height = parseInt(splitHeightInt(Discourse.SiteSettings.adsense_topic_above_suggested_ad_sizes));
}
if (Discourse.SiteSettings.adsense_post_bottom_code && !Discourse.SiteSettings.adsense_show_post_bottom) {
ad_code = Discourse.SiteSettings.adsense_post_bottom_code;
ad_width = parseInt(splitWidthInt(Discourse.SiteSettings.adsense_post_bottom_ad_sizes));
ad_height = parseInt(splitHeightInt(Discourse.SiteSettings.adsense_post_bottom_ad_sizes));
}
}
export default Ember.Component.extend({
classNames: ['google-adsense'],
loadedGoogletag: false,
publisher_id: publisher_id,
ad_width: ad_width,
ad_height: ad_height,
adWrapperStyle: function() {
return `width: ${this.get('ad_width')}px; height: ${this.get('ad_height')}px; margin:0 auto;`.htmlSafe();
}.property('ad_width', 'ad_height'),
adInsStyle: function() {
return `display: inline-block; ${this.get('adWrapperStyle')}`.htmlSafe();
}.property('adWrapperStyle'),
adWrapperStyleMobile: function() {
return `width: 320px; height: 50px; margin:0 auto;`.htmlSafe();
},
adInsStyleMobile: function() {
return `display: inline-block; ${this.get('adWrapperStyleMobile')}`.htmlSafe();
}.property('adWrapperStyleMobile'),
});

View File

@ -43,11 +43,9 @@ function loadGoogle(settings) {
googletag.defineSlot(settings.dfp_topic_list_top_code, [320,50], 'div-gpt-ad-topic-list-top').addService(googletag.pubads());
}
else {
googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + 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')
// Inventory or slot level custom targeting goes here for each of the defined ad units - needs input and injection.
// The ad runs with .setTargeting('gender', ['female'])
.addService(googletag.pubads());
googletag.defineSlot('/' + settings.dfp_publisher_id + '/' + 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());
}
console.log('working');
}
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));

View File

@ -0,0 +1,30 @@
{{#if site.mobileView}}
<div style={{adWrapperStyleMobile}}>
<ins class="adsbygoogle"
style={{adInsStyleMobile}}
data-ad-client="ca-pub-{{publisher_id}}"
data-ad-slot={{ad_code}}>
</ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
{{else}}
<div class="google-adsense-label"><h2>Google Adsense</h2></div>
<div style={{adWrapperStyle}}>
<ins class="adsbygoogle"
style={{adInsStyle}}
data-ad-client="ca-pub-{{publisher_id}}"
data-ad-slot={{ad_code}}>
</ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
{{/if}}

View File

@ -0,0 +1,3 @@
{{#if siteSettings.adsense_topic_list_top_code}}
{{google-adsense placement="topic-list-top"}}
{{/if}}

View File

@ -1,3 +1,4 @@
{{#if siteSettings.dfp_topic_list_top_code}}
{{google-dfp-ad placement="topic-list-top"}}
{{/if}}
{{/if}}

View File

@ -0,0 +1,3 @@
{{#if postSpecificCountAdsense}}
{{google-adsense placement="post-bottom"}}
{{/if}}

View File

@ -1,4 +1,4 @@
{{#if postSpecificCount}}
{{#if postSpecificCountDFP}}
{{google-dfp-ad placement="post-bottom"}}
{{/if}}

View File

@ -0,0 +1,3 @@
{{#if siteSettings.adsense_topic_above_post_stream_code}}
{{google-adsense placement="topic-above-post-stream"}}
{{/if}}

View File

@ -0,0 +1,3 @@
{{#if siteSettings.adsense_topic_above_suggested_code}}
{{google-adsense placement="topic-above-suggested"}}
{{/if}}

View File

@ -4,8 +4,12 @@ export default {
name: 'extend-post-model',
initialize() {
PostModel.reopen({
postSpecificCount: function() {
postSpecificCountDFP: function() {
return this.get('post_number') === parseInt(Discourse.SiteSettings.dfp_nth_post_code);
}.property('post_number'),
postSpecificCountAdsense: function() {
return this.get('post_number') === parseInt(Discourse.SiteSettings.adsense_nth_post_code);
}.property('post_number')
});
}

View File

@ -0,0 +1,49 @@
.google-dfp-ad {
padding: 3px;
margin-bottom: 10px;
clear: both;
}
.google-dfp-ad .dfp-ad-unit {
margin: 0 auto;
}
.google-dfp-ad .google-dfp-ad-label {
width: 728px;
margin: 0 auto;
}
.google-dfp-ad .google-dfp-ad-label h2 {
margin: 4px 0 !important;
color: #858a8c;
text-transform: uppercase;
font-size: 12px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-weight: normal;
}
.google-adsense {
padding: 3px;
margin-bottom: 10px;
clear: both;
}
.google-adsense .adsense-unit {
margin: 0 auto;
}
.google-adsense .google-adsense-label {
width: 728px;
margin: 0 auto;
}
.google-adsense .google-adsense-label h2 {
margin: 4px 0 !important;
color: #858a8c;
text-transform: uppercase;
font-size: 12px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-weight: normal;
}

View File

@ -1,25 +0,0 @@
.google-dfp-ad {
padding: 3px;
margin-bottom: 10px;
clear: both;
}
.google-dfp-ad .dfp-ad-unit {
margin: 0 auto;
}
.google-dfp-ad .google-dfp-ad-label {
width: 728px;
margin: 0 auto;
}
.google-dfp-ad .google-dfp-ad-label h2 {
margin: 4px 0 !important;
color: #858a8c;
text-transform: uppercase;
font-size: 12px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-weight: normal;
}

View File

@ -3,4 +3,5 @@ en:
admin:
site_settings:
categories:
ad_plugin: 'Ad Plugin'
ad_plugin: 'Ad Plugin'
adsense_plugin: 'Adsense Plugin'

View File

@ -1,20 +1,34 @@
en:
site_settings:
dfp_publisher_id: "Put in your publisher id here"
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_topic_list_top_custom_targeting_code: "Add your custom targeting code - see instructions"
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_topic_above_post_stream_custom_targeting_code: "Add your custom targeting code - see instructions"
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_topic_above_suggested_custom_targeting_code: "Add your custom targeting code - see instructions"
dfp_show_post_bottom: "Disable post_bottom ad"
dfp_post_bottom_code: "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_custom_targeting_code: "Add your custom targeting code - see instructions"
dfp_publisher_id: "Put in your publisher id here"
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_topic_list_top_custom_targeting_code: "Add your custom targeting code - see instructions"
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_topic_above_post_stream_custom_targeting_code: "Add your custom targeting code - see instructions"
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_topic_above_suggested_custom_targeting_code: "Add your custom targeting code - see instructions"
dfp_show_post_bottom: "Disable post_bottom ad"
dfp_post_bottom_code: "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_custom_targeting_code: "Add your custom targeting code - see instructions"
adsense_publisher_code: "Insert your Publisher ID here"
adsense_show_topic_list_top: "Disable topic_list_top ad"
adsense_topic_list_top_code: "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"
adsense_topic_above_post_stream_ad_sizes: "Choose your ad sizes"
adsense_show_topic_above_suggested: "Disable topic_above_suggested ad"
adsense_topic_above_suggested_code: "Show leaderboard ad above suggested topics"
adsense_topic_above_suggested_ad_sizes: "Choose your ad sizes"
adsense_post_bottom_code: "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"

View File

@ -1,3 +1,95 @@
adsense_plugin:
adsense_publisher_code:
client: true
default: ''
adsense_topic_list_top_code:
client: true
default: ''
adsense_show_topic_list_top:
client: true
default: false
adsense_topic_list_top_ad_sizes:
client: true
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
adsense_topic_above_post_stream_code:
client: true
default: ''
adsense_show_topic_above_post_stream:
client: true
default: false
adsense_topic_above_post_stream_ad_sizes:
client: true
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
adsense_topic_above_suggested_code:
client: true
default: ''
adsense_show_topic_above_suggested:
client: true
default: false
adsense_topic_above_suggested_ad_sizes:
client: true
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
adsense_post_bottom_code:
client: true
default: ''
adsense_show_post_bottom:
client: true
default: false
adsense_post_bottom_ad_sizes:
client: true
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
adsense_nth_post_code:
client: true
default: ''
ad_plugin:
dfp_publisher_id:
client: true

View File

@ -29,4 +29,28 @@ register_css <<CSS
font-weight: normal;
}
.google-adsense {
padding: 3px;
margin-bottom: 10px;
clear: both;
}
.google-adsense .adsense-unit {
margin: 0 auto;
}
.google-adsense .google-adsense-label {
width: 728px;
margin: 0 auto;
}
.google-adsense .google-adsense-label h2 {
margin: 4px 0 !important;
color: #858a8c;
text-transform: uppercase;
font-size: 12px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-weight: normal;
}
CSS