2018-10-22 14:49:32 -04:00
|
|
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
2015-08-03 21:25:00 -04:00
|
|
|
|
|
|
|
export default {
|
2018-10-22 14:49:32 -04:00
|
|
|
name: "initialize-ad-plugin",
|
2016-02-19 15:06:13 -05:00
|
|
|
initialize(container) {
|
2018-10-22 14:49:32 -04: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) {
|
|
|
|
return dec.connect({
|
|
|
|
component: "post-bottom-ad",
|
|
|
|
context: "model"
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Old way for backwards compatibility
|
2018-06-07 19:17:19 -04:00
|
|
|
return dec.connect({
|
2019-05-10 14:22:18 -04:00
|
|
|
templateName: "connectors/post-bottom/discourse-adplugin",
|
2018-10-22 14:49:32 -04:00
|
|
|
context: "model"
|
2018-06-07 19:17:19 -04: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-03 21:25:00 -04:00
|
|
|
}
|
|
|
|
};
|