1
0
mirror of synced 2026-08-31 14:35:20 +00:00
Files

36 lines
976 B
JavaScript
Raw Permalink Normal View History

2018-10-22 19:49:32 +01:00
import { withPluginApi } from "discourse/lib/plugin-api";
import Site from "discourse/models/site";
2015-08-04 11:25:00 +10:00
export default {
2018-10-22 19:49:32 +01:00
name: "initialize-ad-plugin",
initialize(container) {
2020-09-04 13:24:14 +02:00
withPluginApi("0.1", (api) => {
api.decorateWidget("post:after", (dec) => {
if (dec.canConnectComponent) {
2019-05-10 14:22:18 -04:00
if (!dec.attrs.cloaked) {
return dec.connect({
component: "post-bottom-ad",
2020-09-04 13:24:14 +02:00
context: "model",
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",
2020-09-04 13:24:14 +02:00
context: "model",
2018-06-07 17:17:19 -06: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
2020-09-04 13:24:14 +02:00
messageBus.subscribe("/site/house-creatives", function (houseAdsSettings) {
Site.currentProp("house_creatives", houseAdsSettings);
2019-04-18 17:52:59 -04:00
});
2020-09-04 13:24:14 +02:00
},
2015-08-04 11:25:00 +10:00
};