2018-10-22 19:49:32 +01:00
|
|
|
import PostModel from "discourse/models/post";
|
|
|
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
2015-08-04 11:25:00 +10:00
|
|
|
|
|
|
|
export default {
|
2018-10-22 19:49:32 +01:00
|
|
|
name: "initialize-ad-plugin",
|
2016-02-19 15:06:13 -05:00
|
|
|
initialize(container) {
|
2018-10-22 19:49:32 +01:00
|
|
|
withPluginApi("0.1", api => {
|
|
|
|
api.decorateWidget("post:after", dec => {
|
2016-11-23 14:29:30 -05:00
|
|
|
if (dec.canConnectComponent) {
|
2019-05-10 14:22:18 -04:00
|
|
|
if (!dec.attrs.cloaked) {
|
2019-05-10 15:08:28 -04:00
|
|
|
// return dec.connect({
|
|
|
|
// component: "post-bottom-ad",
|
|
|
|
// context: "model"
|
|
|
|
// });
|
|
|
|
console.log('initialize attach ad-slot');
|
|
|
|
return dec.attach('ad-slot', {
|
|
|
|
placement: 'post-bottom',
|
|
|
|
category: 'TODO',
|
|
|
|
postNumber: dec.attrs.post_number
|
2019-05-10 14:22:18 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Old way for backwards compatibility
|
2018-06-07 17:17:19 -06:00
|
|
|
return dec.connect({
|
2019-05-10 14:22:18 -04:00
|
|
|
templateName: "connectors/post-bottom/discourse-adplugin",
|
2018-10-22 19:49:32 +01:00
|
|
|
context: "model"
|
2018-06-07 17:17:19 -06:00
|
|
|
});
|
2016-11-23 14:29:30 -05:00
|
|
|
}
|
2016-02-22 12:11:29 -05:00
|
|
|
});
|
|
|
|
});
|
2019-04-18 17:52:59 -04:00
|
|
|
|
2019-05-10 14:22:18 -04:00
|
|
|
const messageBus = container.lookup("message-bus:main");
|
|
|
|
if (!messageBus) {
|
|
|
|
return;
|
|
|
|
}
|
2019-04-18 17:52:59 -04:00
|
|
|
|
2019-05-10 14:22:18 -04:00
|
|
|
messageBus.subscribe("/site/house-creatives", function(houseAdsSettings) {
|
2019-04-18 17:52:59 -04:00
|
|
|
Discourse.Site.currentProp("house_creatives", houseAdsSettings);
|
|
|
|
});
|
2015-08-04 11:25:00 +10:00
|
|
|
}
|
|
|
|
};
|