DEV: Add compatibility with the Glimmer Post Stream
Refactored ad plugin initialization to use API enhancements and split logic into smaller functions for better organization. Updated compatibility to include a new version restriction.
This commit is contained in:
parent
fcd734079b
commit
5445dab371
|
|
@ -1,3 +1,4 @@
|
|||
< 3.5.0.beta8-dev: fcd734079b10644066d07379071b1de057e7a19c
|
||||
< 3.5.0.beta5-dev: bd9af0b9a577bfd2c01cc8b81a782a4e8b81b9c5
|
||||
< 3.5.0.beta1-dev: 6ceba62e985223c269782c4bc9a1bdc4a5adba28
|
||||
< 3.4.0.beta2-dev: 7685ebf396c93e8accc5a76a81fcec4384a73fa3
|
||||
|
|
|
|||
|
|
@ -2,20 +2,14 @@ import { hbs } from "ember-cli-htmlbars";
|
|||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import Site from "discourse/models/site";
|
||||
import { registerWidgetShim } from "discourse/widgets/render-glimmer";
|
||||
import { withSilencedDeprecations } from "discourse/lib/deprecated";
|
||||
import PostBottomAd from "../components/post-bottom-ad";
|
||||
|
||||
export default {
|
||||
name: "initialize-ad-plugin",
|
||||
initialize(container) {
|
||||
registerWidgetShim(
|
||||
"after-post-ad",
|
||||
"div.widget-connector",
|
||||
hbs`<PostBottomAd @model={{@data}} />`
|
||||
);
|
||||
|
||||
withPluginApi("0.1", (api) => {
|
||||
api.decorateWidget("post:after", (helper) => {
|
||||
return helper.attach("after-post-ad", helper.widget.model);
|
||||
});
|
||||
customizePost(api);
|
||||
});
|
||||
|
||||
const messageBus = container.lookup("service:message-bus");
|
||||
|
|
@ -30,3 +24,26 @@ export default {
|
|||
});
|
||||
},
|
||||
};
|
||||
|
||||
function customizePost(api) {
|
||||
api.renderAfterWrapperOutlet(
|
||||
"post-article",
|
||||
<template><PostBottomAd @model={{@post}} /></template>
|
||||
);
|
||||
|
||||
withSilencedDeprecations("discourse.post-stream-widget-overrides", () =>
|
||||
customizeWidgetPost(api)
|
||||
);
|
||||
}
|
||||
|
||||
function customizeWidgetPost(api) {
|
||||
registerWidgetShim(
|
||||
"after-post-ad",
|
||||
"div.widget-connector",
|
||||
hbs`<PostBottomAd @model={{@data}} />`
|
||||
);
|
||||
|
||||
api.decorateWidget("post:after", (helper) => {
|
||||
return helper.attach("after-post-ad", helper.widget.model);
|
||||
});
|
||||
}
|
||||
Loading…
Reference in New Issue