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

Commit 9c6c880

Browse files
committed
Allow customizing Carbon Ads format
Carbon Ads now supports a new Cover format, which can be forced using an extra query parameter.
1 parent fcd7340 commit 9c6c880

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

assets/javascripts/discourse/components/carbonads-ad.gjs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,23 @@ import AdComponent from "./ad-component";
55
export default class CarbonadsAd extends AdComponent {
66
serve_id = null;
77
placement = null;
8+
format = null;
89

910
init() {
1011
this.set("serve_id", this.siteSettings.carbonads_serve_id);
1112
this.set("placement", this.siteSettings.carbonads_placement);
13+
this.set("format", this.siteSettings.carbonads_format);
1214
super.init();
1315
}
1416

15-
@discourseComputed("serve_id", "placement")
16-
url(serveId, placement) {
17-
return htmlSafe(
18-
`//cdn.carbonads.com/carbon.js?serve=${serveId}&placement=${placement}`
19-
);
17+
@discourseComputed("serve_id", "placement", "format")
18+
url(serveId, placement, format) {
19+
let baseUrl = `//cdn.carbonads.com/carbon.js?serve=${serveId}&placement=${placement}`;
20+
if (format) {
21+
baseUrl += `&format=${format}`;
22+
}
23+
24+
return htmlSafe(baseUrl);
2025
}
2126

2227
@discourseComputed

config/locales/server.en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ en:
9797

9898
carbonads_serve_id: "Your Carbon Ads Serve ID"
9999
carbonads_placement: "Your Carbon Ads Placement"
100+
carbonads_format: "Your Carbon Ads Format"
100101
carbonads_through_trust_level: "Show your ads to users based on trust levels. Users with trust level higher than this value will not see ads."
101102
carbonads_exclude_groups: "Ads will not be shown to members of these groups"
102103
carbonads_topic_list_top_enabled: "Show an ad above the topic list"

config/settings.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,12 @@ carbonads_plugin:
438438
carbonads_placement:
439439
client: true
440440
default: ""
441+
carbonads_format:
442+
client: true
443+
default: "responsive"
444+
choices:
445+
- responsive
446+
- cover
441447
carbonads_through_trust_level:
442448
client: true
443449
default: 2

0 commit comments

Comments
 (0)