Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 5445dab

Browse files
committed
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.
1 parent fcd7340 commit 5445dab

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

.discourse-compatibility

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
< 3.5.0.beta8-dev: fcd734079b10644066d07379071b1de057e7a19c
12
< 3.5.0.beta5-dev: bd9af0b9a577bfd2c01cc8b81a782a4e8b81b9c5
23
< 3.5.0.beta1-dev: 6ceba62e985223c269782c4bc9a1bdc4a5adba28
34
< 3.4.0.beta2-dev: 7685ebf396c93e8accc5a76a81fcec4384a73fa3

assets/javascripts/discourse/initializers/initialize-ad-plugin.js renamed to assets/javascripts/discourse/initializers/initialize-ad-plugin.gjs

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@ import { hbs } from "ember-cli-htmlbars";
22
import { withPluginApi } from "discourse/lib/plugin-api";
33
import Site from "discourse/models/site";
44
import { registerWidgetShim } from "discourse/widgets/render-glimmer";
5+
import { withSilencedDeprecations } from "discourse/lib/deprecated";
6+
import PostBottomAd from "../components/post-bottom-ad";
57

68
export default {
79
name: "initialize-ad-plugin",
810
initialize(container) {
9-
registerWidgetShim(
10-
"after-post-ad",
11-
"div.widget-connector",
12-
hbs`<PostBottomAd @model={{@data}} />`
13-
);
14-
1511
withPluginApi("0.1", (api) => {
16-
api.decorateWidget("post:after", (helper) => {
17-
return helper.attach("after-post-ad", helper.widget.model);
18-
});
12+
customizePost(api);
1913
});
2014

2115
const messageBus = container.lookup("service:message-bus");
@@ -30,3 +24,26 @@ export default {
3024
});
3125
},
3226
};
27+
28+
function customizePost(api) {
29+
api.renderAfterWrapperOutlet(
30+
"post-article",
31+
<template><PostBottomAd @model={{@post}} /></template>
32+
);
33+
34+
withSilencedDeprecations("discourse.post-stream-widget-overrides", () =>
35+
customizeWidgetPost(api)
36+
);
37+
}
38+
39+
function customizeWidgetPost(api) {
40+
registerWidgetShim(
41+
"after-post-ad",
42+
"div.widget-connector",
43+
hbs`<PostBottomAd @model={{@data}} />`
44+
);
45+
46+
api.decorateWidget("post:after", (helper) => {
47+
return helper.attach("after-post-ad", helper.widget.model);
48+
});
49+
}

0 commit comments

Comments
 (0)