Skip to content

DEV: Add compatibility with the Glimmer Post Stream #247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .discourse-compatibility
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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