From 9c6c880b1d16447c3dc856f847f815334d3e07e5 Mon Sep 17 00:00:00 2001 From: Diego Barreiro Perez Date: Thu, 3 Jul 2025 00:44:15 +0100 Subject: [PATCH 1/3] Allow customizing Carbon Ads format Carbon Ads now supports a new Cover format, which can be forced using an extra query parameter. --- .../discourse/components/carbonads-ad.gjs | 15 ++++++++++----- config/locales/server.en.yml | 1 + config/settings.yml | 6 ++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/assets/javascripts/discourse/components/carbonads-ad.gjs b/assets/javascripts/discourse/components/carbonads-ad.gjs index b57389db..86257eb0 100644 --- a/assets/javascripts/discourse/components/carbonads-ad.gjs +++ b/assets/javascripts/discourse/components/carbonads-ad.gjs @@ -5,18 +5,23 @@ import AdComponent from "./ad-component"; export default class CarbonadsAd extends AdComponent { serve_id = null; placement = null; + format = null; init() { this.set("serve_id", this.siteSettings.carbonads_serve_id); this.set("placement", this.siteSettings.carbonads_placement); + this.set("format", this.siteSettings.carbonads_format); super.init(); } - @discourseComputed("serve_id", "placement") - url(serveId, placement) { - return htmlSafe( - `//cdn.carbonads.com/carbon.js?serve=${serveId}&placement=${placement}` - ); + @discourseComputed("serve_id", "placement", "format") + url(serveId, placement, format) { + let baseUrl = `//cdn.carbonads.com/carbon.js?serve=${serveId}&placement=${placement}`; + if (format) { + baseUrl += `&format=${format}`; + } + + return htmlSafe(baseUrl); } @discourseComputed diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 09e7012a..3f4bc8ce 100755 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -97,6 +97,7 @@ en: carbonads_serve_id: "Your Carbon Ads Serve ID" carbonads_placement: "Your Carbon Ads Placement" + carbonads_format: "Your Carbon Ads Format" 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." carbonads_exclude_groups: "Ads will not be shown to members of these groups" carbonads_topic_list_top_enabled: "Show an ad above the topic list" diff --git a/config/settings.yml b/config/settings.yml index 6077dcd3..ff3b8fd8 100755 --- a/config/settings.yml +++ b/config/settings.yml @@ -438,6 +438,12 @@ carbonads_plugin: carbonads_placement: client: true default: "" + carbonads_format: + client: true + default: "responsive" + choices: + - responsive + - cover carbonads_through_trust_level: client: true default: 2 From 9d9b6ab7b9d770aea8b843a6a12f370cd6412d0c Mon Sep 17 00:00:00 2001 From: Diego Barreiro Perez Date: Thu, 3 Jul 2025 23:34:14 +0100 Subject: [PATCH 2/3] Add Carbon Ads locations --- assets/javascripts/discourse/components/ad-slot.gjs | 4 ++-- config/locales/server.en.yml | 2 ++ config/settings.yml | 8 ++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/discourse/components/ad-slot.gjs b/assets/javascripts/discourse/components/ad-slot.gjs index 03a71a68..3ec4db59 100644 --- a/assets/javascripts/discourse/components/ad-slot.gjs +++ b/assets/javascripts/discourse/components/ad-slot.gjs @@ -56,9 +56,9 @@ const adConfig = EmberObject.create({ enabledSetting: "carbonads_serve_id", desktop: { "topic-list-top": "carbonads_topic_list_top_enabled", - "post-bottom": false, + "post-bottom": "carbonads_post_bottom_enabled", "topic-above-post-stream": "carbonads_above_post_stream_enabled", - "topic-above-suggested": false, + "topic-above-suggested": "carbonads_above_suggested_enabled", }, }, "adbutler-ad": { diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 3f4bc8ce..71a1cd93 100755 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -102,6 +102,8 @@ en: carbonads_exclude_groups: "Ads will not be shown to members of these groups" carbonads_topic_list_top_enabled: "Show an ad above the topic list" carbonads_above_post_stream_enabled: "Show an ad above the post stream" + carbonads_post_bottom_enabled: "Show an ad above at post bottom" + carbonads_above_suggested_enabled: "Show an ad above the above suggested topics" adbutler_publisher_id: "AdButler Publisher ID. NOTE: You may need to update the 'content security policy script src' setting. See this topic for the latest instructions." adbutler_mobile_topic_list_top_zone_id: "Zone ID for mobile topic list top location" diff --git a/config/settings.yml b/config/settings.yml index ff3b8fd8..5ef4b7c9 100755 --- a/config/settings.yml +++ b/config/settings.yml @@ -440,7 +440,9 @@ carbonads_plugin: default: "" carbonads_format: client: true + type: enum default: "responsive" + allow_any: false choices: - responsive - cover @@ -469,6 +471,12 @@ carbonads_plugin: carbonads_above_post_stream_enabled: client: true default: false + carbonads_post_bottom_enabled: + client: true + default: false + carbonads_above_suggested_enabled: + client: true + default: false adbutler_plugin: adbutler_publisher_id: From dd4d1a1698e571aa4e8e6b61d5e2dab87ee36de2 Mon Sep 17 00:00:00 2001 From: Diego Barreiro Perez Date: Thu, 3 Jul 2025 23:34:46 +0100 Subject: [PATCH 3/3] Do not apply custom CSS on Carbon Cover --- assets/stylesheets/adplugin.scss | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/assets/stylesheets/adplugin.scss b/assets/stylesheets/adplugin.scss index 58444e25..7c8c687e 100644 --- a/assets/stylesheets/adplugin.scss +++ b/assets/stylesheets/adplugin.scss @@ -140,7 +140,7 @@ } } -#carbonads { +#carbonads:not(#carbon-cover *) { display: block; overflow: hidden; padding: 1em; @@ -150,23 +150,23 @@ margin-bottom: 15px; } -#carbonads span { +#carbonads:not(#carbon-cover *) span { position: relative; display: block; overflow: hidden; } -.carbon-img { +.carbon-img:not(#carbon-cover *) { float: left; margin-right: 1em; } -.carbon-img img { +.carbon-img:not(#carbon-cover *) img { display: block; line-height: 1; } -.carbon-text { +.carbon-text:not(#carbon-cover *) { display: block; float: left; max-width: calc(100% - 130px - 1em); @@ -174,7 +174,7 @@ color: var(--primary-med-or-secondary-med); } -.carbon-poweredby { +.carbon-poweredby:not(#carbon-cover *) { position: absolute; right: 0; // You can also set the position to the "left" with the value of calc(130px + carbon-text’s font size). If the font-size is 12px, you’ll want to set the left value as 142px. It’ll align the .carbon-text with .carbon-poweredby bottom: 0;