diff --git a/assets/javascripts/discourse/templates/components/adplugin-container.hbs b/assets/javascripts/discourse/templates/components/adplugin-container.hbs new file mode 100644 index 0000000..65e1b28 --- /dev/null +++ b/assets/javascripts/discourse/templates/components/adplugin-container.hbs @@ -0,0 +1,33 @@ +{{#if site.mobileView}} + {{#if model.postSpecificCountAdsense}} + {{#if siteSettings.adsense_mobile_post_bottom_code}} + {{google-adsense placement="post-bottom" postNumber=model.post_number}} + {{/if}} + {{/if}} + {{#if model.postSpecificCountDFP}} + {{#if siteSettings.dfp_mobile_post_bottom_code}} + {{google-dfp-ad placement="post-bottom" category=model.topic.category.slug postNumber=model.post_number}} + {{/if}} + {{/if}} + {{#if model.postSpecificCountAmazon}} + {{#if siteSettings.amazon_mobile_post_bottom_src_code}} + {{amazon-product-links placement="post-bottom" postNumber=model.post_number}} + {{/if}} + {{/if}} +{{else}} + {{#if model.postSpecificCountAdsense}} + {{#if siteSettings.adsense_post_bottom_code}} + {{google-adsense placement="post-bottom" postNumber=model.post_number}} + {{/if}} + {{/if}} + {{#if model.postSpecificCountDFP}} + {{#if siteSettings.dfp_post_bottom_code}} + {{google-dfp-ad placement="post-bottom" category=model.topic.category.slug postNumber=model.post_number}} + {{/if}} + {{/if}} + {{#if model.postSpecificCountAmazon}} + {{#if siteSettings.amazon_post_bottom_src_code}} + {{amazon-product-links placement="post-bottom" postNumber=model.post_number}} + {{/if}} + {{/if}} +{{/if}} 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 4eababf..ab5aa7d 100644 --- a/assets/javascripts/discourse/templates/connectors/post-bottom/discourse-adplugin.hbs +++ b/assets/javascripts/discourse/templates/connectors/post-bottom/discourse-adplugin.hbs @@ -1,33 +1 @@ -{{#if site.mobileView}} - {{#if postSpecificCountAdsense}} - {{#if siteSettings.adsense_mobile_post_bottom_code}} - {{google-adsense placement="post-bottom" postNumber=post_number}} - {{/if}} - {{/if}} - {{#if postSpecificCountDFP}} - {{#if siteSettings.dfp_mobile_post_bottom_code}} - {{google-dfp-ad placement="post-bottom" category=topic.category.slug postNumber=post_number}} - {{/if}} - {{/if}} - {{#if postSpecificCountAmazon}} - {{#if siteSettings.amazon_mobile_post_bottom_src_code}} - {{amazon-product-links placement="post-bottom" postNumber=post_number}} - {{/if}} - {{/if}} -{{else}} - {{#if postSpecificCountAdsense}} - {{#if siteSettings.adsense_post_bottom_code}} - {{google-adsense placement="post-bottom" postNumber=post_number}} - {{/if}} - {{/if}} - {{#if postSpecificCountDFP}} - {{#if siteSettings.dfp_post_bottom_code}} - {{google-dfp-ad placement="post-bottom" category=topic.category.slug postNumber=post_number}} - {{/if}} - {{/if}} - {{#if postSpecificCountAmazon}} - {{#if siteSettings.amazon_post_bottom_src_code}} - {{amazon-product-links placement="post-bottom" postNumber=post_number}} - {{/if}} - {{/if}} -{{/if}} \ No newline at end of file +{{adplugin-container model=this}} diff --git a/assets/javascripts/initializers/initialize-ad-plugin.js.es6 b/assets/javascripts/initializers/initialize-ad-plugin.js.es6 index 1b6d473..8971918 100644 --- a/assets/javascripts/initializers/initialize-ad-plugin.js.es6 +++ b/assets/javascripts/initializers/initialize-ad-plugin.js.es6 @@ -30,6 +30,12 @@ export default { withPluginApi('0.1', api => { api.decorateWidget('post:after', dec => { + + if (dec.canConnectComponent) { + return dec.connect({ component: 'adplugin-container', context: 'model' }); + } + + // Old way for backwards compatibility return dec.connect({ templateName: 'connectors/post-bottom/discourse-adplugin', context: 'model'