FEATURE: House Ads

Allows creating ads within Discourse admin at Plugins > House Ads.
Write the ads in html and style them with CSS in themes.
This commit is contained in:
Neil Lalonde
2019-05-03 11:39:34 -04:00
parent 5272995e74
commit 1bd80e1afe
47 changed files with 1350 additions and 192 deletions
@@ -16,6 +16,18 @@ acceptance("AdSense", {
adsense_mobile_post_bottom_code: "mobile_post_bottom_ad_unit",
adsense_mobile_post_bottom_ad_size: "300*250 - medium rectangle",
adsense_nth_post_code: 6
},
site: {
house_creatives: {
settings: {
topic_list_top: "",
topic_above_post_stream: "",
topic_above_suggested: "",
post_bottom: "",
after_nth_post: 20
},
creatives: {}
}
}
});
@@ -16,6 +16,18 @@ acceptance("DFP Ads", {
dfp_mobile_post_bottom_code: "mobile_post_bottom_ad_unit",
dfp_mobile_post_bottom_ad_size: "300*250 - medium rectangle",
dfp_nth_post_code: 6
},
site: {
house_creatives: {
settings: {
topic_list_top: "",
topic_above_post_stream: "",
topic_above_suggested: "",
post_bottom: "",
after_nth_post: 20
},
creatives: {}
}
}
});
@@ -0,0 +1,69 @@
import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
acceptance("House Ads", {
loggedIn: true,
settings: {
house_ads_after_nth_post: 6
},
site: {
house_creatives: {
settings: {
topic_list_top: "Topic List",
topic_above_post_stream: "Above Post Stream",
topic_above_suggested: "Above Suggested",
post_bottom: "Post",
after_nth_post: 6
},
creatives: {
"Topic List": "<div class='h-topic-list'>TOPIC LIST</div>",
"Above Post Stream":
"<div class='h-above-post-stream'>ABOVE POST STREAM</div>",
"Above Suggested":
"<div class='h-above-suggested'>ABOVE SUGGESTED</div>",
Post: "<div class='h-post'>BELOW POST</div>"
}
}
}
});
test("correct ads show", async assert => {
replaceCurrentUser({ staff: false, trust_level: 1 });
await visit("/t/280"); // 20 posts
assert.equal(
find(".h-above-post-stream").length,
1,
"it should render ad at top of topic"
);
assert.equal(
find(".h-above-suggested").length,
1,
"it should render ad above suggested topics"
);
const ads = find(".h-post");
assert.equal(ads.length, 3, "it should render 3 ads");
assert.equal(
find("#post_6 + .widget-connector").find(".h-post").length,
1,
"ad after 6th post"
);
assert.equal(
find("#post_12 + .widget-connector").find(".h-post").length,
1,
"ad after 12th post"
);
assert.equal(
find("#post_18 + .widget-connector").find(".h-post").length,
1,
"ad after 18th post"
);
await visit("/latest");
assert.equal(
find(".h-topic-list").length,
1,
"it should render ad above topic list"
);
});