2015-08-03 21:25:00 -04:00
|
|
|
import PostModel from 'discourse/models/post';
|
2016-02-22 12:11:29 -05:00
|
|
|
import { withPluginApi } from 'discourse/lib/plugin-api';
|
2015-08-03 21:25:00 -04:00
|
|
|
|
|
|
|
export default {
|
2016-02-22 12:11:29 -05:00
|
|
|
name: 'initialize-ad-plugin',
|
2016-02-19 15:06:13 -05:00
|
|
|
initialize(container) {
|
|
|
|
const siteSettings = container.lookup('site-settings:main');
|
|
|
|
|
2015-08-03 21:25:00 -04:00
|
|
|
PostModel.reopen({
|
2015-08-25 00:30:23 -04:00
|
|
|
postSpecificCountDFP: function() {
|
2016-02-19 15:06:13 -05:00
|
|
|
return this.get('post_number') === parseInt(siteSettings.dfp_nth_post_code);
|
2015-08-25 00:30:23 -04:00
|
|
|
}.property('post_number'),
|
|
|
|
|
|
|
|
postSpecificCountAdsense: function() {
|
2016-02-19 15:06:13 -05:00
|
|
|
return this.get('post_number') === parseInt(siteSettings.adsense_nth_post_code);
|
2015-08-27 22:21:40 -04:00
|
|
|
}.property('post_number'),
|
2015-09-10 08:48:14 -04:00
|
|
|
|
|
|
|
postSpecificCountAmazon: function() {
|
2016-02-19 15:06:13 -05:00
|
|
|
return this.get('post_number') === parseInt(siteSettings.amazon_nth_post_code);
|
2015-09-10 08:48:14 -04:00
|
|
|
}.property('post_number'),
|
2015-08-03 21:25:00 -04:00
|
|
|
});
|
2016-02-22 12:11:29 -05:00
|
|
|
|
|
|
|
withPluginApi('0.1', api => {
|
|
|
|
api.decorateWidget('post:after', dec => {
|
|
|
|
return dec.connect({
|
|
|
|
templateName: 'connectors/post-bottom/discourse-adplugin',
|
|
|
|
context: 'model'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2015-08-03 21:25:00 -04:00
|
|
|
}
|
|
|
|
};
|