mirror of
https://github.com/discourse/discourse-adplugin.git
synced 2025-03-09 13:19:11 +00:00
Allows creating ads within Discourse admin at Plugins > House Ads. Write the ads in html and style them with CSS in themes.
32 lines
892 B
JavaScript
32 lines
892 B
JavaScript
import PostModel from "discourse/models/post";
|
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
|
|
|
export default {
|
|
name: "initialize-ad-plugin",
|
|
initialize(container) {
|
|
withPluginApi("0.1", api => {
|
|
api.decorateWidget("post:after", dec => {
|
|
if (dec.canConnectComponent) {
|
|
return dec.connect({
|
|
component: "post-bottom-ad",
|
|
context: "model"
|
|
});
|
|
}
|
|
|
|
// Old way for backwards compatibility
|
|
return dec.connect({
|
|
templateName: "connectors/post-bottom/discourse-adplugin",
|
|
context: "model"
|
|
});
|
|
});
|
|
});
|
|
|
|
const messageBus = container.lookup('message-bus:main');
|
|
if (!messageBus) { return; }
|
|
|
|
messageBus.subscribe("/site/house-creatives", function (houseAdsSettings) {
|
|
Discourse.Site.currentProp("house_creatives", houseAdsSettings);
|
|
});
|
|
}
|
|
};
|