Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Add above-site-header Ad slot (#42940)

Juan David Martínez Cubillos3935876e5391
diff --git a/plugins/discourse-adplugin/admin/assets/javascripts/admin/components/house-ads-settings-panel.gjs b/plugins/discourse-adplugin/admin/assets/javascripts/admin/components/house-ads-settings-panel.gjs
index b8957b46c21..12ba9ade069 100644
--- a/plugins/discourse-adplugin/admin/assets/javascripts/admin/components/house-ads-settings-panel.gjs
+++ b/plugins/discourse-adplugin/admin/assets/javascripts/admin/components/house-ads-settings-panel.gjs
@@ -4,6 +4,12 @@ import HouseAdsListSetting from "./house-ads-list-setting";
const HouseAdsSettingsPanel = <template>
<section class="house-ads-settings" ...attributes>
<form class="form-horizontal">
+ <HouseAdsListSetting
+ @name="above_site_header"
+ @value={{@adSettings.above_site_header}}
+ @allAds={{@houseAds}}
+ @adSettings={{@adSettings}}
+ />
<HouseAdsListSetting
@name="topic_list_top"
@value={{@adSettings.topic_list_top}}
diff --git a/plugins/discourse-adplugin/app/models/ad_plugin/house_ad_setting.rb b/plugins/discourse-adplugin/app/models/ad_plugin/house_ad_setting.rb
index 6d45e72ccff..732d77c51d8 100644
--- a/plugins/discourse-adplugin/app/models/ad_plugin/house_ad_setting.rb
+++ b/plugins/discourse-adplugin/app/models/ad_plugin/house_ad_setting.rb
@@ -9,6 +9,7 @@ module AdPlugin
post_bottom: "",
topic_list_between: "",
nested_roots_between: "",
+ above_site_header: "",
}
def self.all
diff --git a/plugins/discourse-adplugin/assets/javascripts/discourse/components/ad-slot.gjs b/plugins/discourse-adplugin/assets/javascripts/discourse/components/ad-slot.gjs
index 7955b707b3b..6cb4d51746c 100644
--- a/plugins/discourse-adplugin/assets/javascripts/discourse/components/ad-slot.gjs
+++ b/plugins/discourse-adplugin/assets/javascripts/discourse/components/ad-slot.gjs
@@ -37,12 +37,14 @@ const adConfig = EmberObject.create({
enabledSetting: false,
nthPost: "amazon_nth_post_code",
desktop: {
+ "above-site-header": "amazon_above_site_header_src_code",
"topic-list-top": "amazon_topic_list_top_src_code",
"post-bottom": "amazon_post_bottom_src_code",
"topic-above-post-stream": "amazon_topic_above_post_stream_src_code",
"topic-above-suggested": "amazon_topic_above_suggested_src_code",
},
mobile: {
+ "above-site-header": "amazon_mobile_above_site_header_src_code",
"topic-list-top": "amazon_mobile_topic_list_top_src_code",
"post-bottom": "amazon_mobile_post_bottom_src_code",
"topic-above-post-stream":
@@ -54,6 +56,7 @@ const adConfig = EmberObject.create({
settingPrefix: "carbonads",
enabledSetting: "carbonads_serve_id",
desktop: {
+ "above-site-header": "carbonads_above_site_header_enabled",
"topic-list-top": "carbonads_topic_list_top_enabled",
"post-bottom": false,
"topic-above-post-stream": "carbonads_above_post_stream_enabled",
@@ -64,12 +67,14 @@ const adConfig = EmberObject.create({
settingPrefix: "adbutler",
enabledSetting: "adbutler_publisher_id",
desktop: {
+ "above-site-header": "adbutler_above_site_header_zone_id",
"topic-list-top": "adbutler_topic_list_top_zone_id",
"post-bottom": "adbutler_post_bottom_zone_id",
"topic-above-post-stream": "adbutler_topic_above_post_stream_zone_id",
"topic-above-suggested": "adbutler_topic_above_suggested_zone_id",
},
mobile: {
+ "above-site-header": "adbutler_mobile_above_site_header_zone_id",
"topic-list-top": "adbutler_mobile_topic_list_top_zone_id",
"post-bottom": "adbutler_mobile_post_bottom_zone_id",
"topic-above-post-stream":
diff --git a/plugins/discourse-adplugin/assets/javascripts/discourse/components/amazon-product-links.gjs b/plugins/discourse-adplugin/assets/javascripts/discourse/components/amazon-product-links.gjs
index 9c49b545da1..80f4e548d14 100644
--- a/plugins/discourse-adplugin/assets/javascripts/discourse/components/amazon-product-links.gjs
+++ b/plugins/discourse-adplugin/assets/javascripts/discourse/components/amazon-product-links.gjs
@@ -8,6 +8,7 @@ import AdComponent from "./ad-component";
export default class AmazonProductLinks extends AdComponent {
init() {
const data = {
+ "above-site-header": {},
"topic-list-top": {},
"topic-above-post-stream": {},
"topic-above-suggested": {},
@@ -16,6 +17,35 @@ export default class AmazonProductLinks extends AdComponent {
const mobileView = this.site.get("mobileView");
const placement = this.get("placement");
+ if (!mobileView && this.siteSettings.amazon_above_site_header_src_code) {
+ data["above-site-header"]["user_input"] =
+ this.siteSettings.amazon_above_site_header_src_code;
+ data["above-site-header"]["amazon_width"] = parseInt(
+ this.siteSettings.amazon_above_site_header_ad_width_code,
+ 10
+ );
+ data["above-site-header"]["amazon_height"] = parseInt(
+ this.siteSettings.amazon_above_site_header_ad_height_code,
+ 10
+ );
+ }
+
+ if (
+ mobileView &&
+ this.siteSettings.amazon_mobile_above_site_header_src_code
+ ) {
+ data["above-site-header"]["user_input_mobile"] =
+ this.siteSettings.amazon_mobile_above_site_header_src_code;
+ data["above-site-header"]["mobile_amazon_width"] = parseInt(
+ this.siteSettings.amazon_mobile_above_site_header_ad_width_code,
+ 10
+ );
+ data["above-site-header"]["mobile_amazon_height"] = parseInt(
+ this.siteSettings.amazon_mobile_above_site_header_ad_height_code,
+ 10
+ );
+ }
+
if (!mobileView && this.siteSettings.amazon_topic_list_top_src_code) {
data["topic-list-top"]["user_input"] =
this.siteSettings.amazon_topic_list_top_src_code;
diff --git a/plugins/discourse-adplugin/assets/javascripts/discourse/components/google-adsense.gjs b/plugins/discourse-adplugin/assets/javascripts/discourse/components/google-adsense.gjs
index f1549618003..5cbb367b537 100644
--- a/plugins/discourse-adplugin/assets/javascripts/discourse/components/google-adsense.gjs
+++ b/plugins/discourse-adplugin/assets/javascripts/discourse/components/google-adsense.gjs
@@ -63,6 +63,10 @@ function loadAdsense() {
}
const DESKTOP_SETTINGS = {
+ "above-site-header": {
+ code: "adsense_above_site_header_code",
+ sizes: "adsense_above_site_header_ad_sizes",
+ },
"topic-list-top": {
code: "adsense_topic_list_top_code",
sizes: "adsense_topic_list_top_ad_sizes",
@@ -82,6 +86,10 @@ const DESKTOP_SETTINGS = {
};
const MOBILE_SETTINGS = {
+ "above-site-header": {
+ code: "adsense_mobile_above_site_header_code",
+ sizes: "adsense_mobile_above_site_header_ad_size",
+ },
"topic-list-top": {
code: "adsense_mobile_topic_list_top_code",
sizes: "adsense_mobile_topic_list_top_ad_size",
diff --git a/plugins/discourse-adplugin/assets/javascripts/discourse/components/google-dfp-ad.gjs b/plugins/discourse-adplugin/assets/javascripts/discourse/components/google-dfp-ad.gjs
index 4e068fd0b40..cdcd47bbc9f 100644
--- a/plugins/discourse-adplugin/assets/javascripts/discourse/components/google-dfp-ad.gjs
+++ b/plugins/discourse-adplugin/assets/javascripts/discourse/components/google-dfp-ad.gjs
@@ -57,6 +57,12 @@ function custom_targeting(key_array, value_array) {
}
const DESKTOP_SETTINGS = {
+ "above-site-header": {
+ code: "dfp_above_site_header_code",
+ sizes: "dfp_above_site_header_ad_sizes",
+ targeting_keys: "dfp_target_above_site_header_key_code",
+ targeting_values: "dfp_target_above_site_header_value_code",
+ },
"topic-list-top": {
code: "dfp_topic_list_top_code",
sizes: "dfp_topic_list_top_ad_sizes",
@@ -84,6 +90,12 @@ const DESKTOP_SETTINGS = {
};
const MOBILE_SETTINGS = {
+ "above-site-header": {
+ code: "dfp_mobile_above_site_header_code",
+ sizes: "dfp_mobile_above_site_header_ad_sizes",
+ targeting_keys: "dfp_target_above_site_header_key_code",
+ targeting_values: "dfp_target_above_site_header_value_code",
+ },
"topic-list-top": {
code: "dfp_mobile_topic_list_top_code",
sizes: "dfp_mobile_topic_list_top_ad_sizes",
diff --git a/plugins/discourse-adplugin/assets/javascripts/discourse/components/house-ad.gjs b/plugins/discourse-adplugin/assets/javascripts/discourse/components/house-ad.gjs
index 193196b2bc9..1abe1a68138 100644
--- a/plugins/discourse-adplugin/assets/javascripts/discourse/components/house-ad.gjs
+++ b/plugins/discourse-adplugin/assets/javascripts/discourse/components/house-ad.gjs
@@ -6,6 +6,7 @@ import dConcatClass from "discourse/ui-kit/helpers/d-concat-class";
import AdComponent from "./ad-component";
const adIndex = {
+ above_site_header: null,
topic_list_top: null,
topic_above_post_stream: null,
topic_above_suggested: null,
diff --git a/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/above-site-header/discourse-adplugin.gjs b/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/above-site-header/discourse-adplugin.gjs
new file mode 100644
index 00000000000..f5b007ca4d6
--- /dev/null
+++ b/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/above-site-header/discourse-adplugin.gjs
@@ -0,0 +1,12 @@
+import AdSlot from "../../components/ad-slot";
+
+const DiscourseAdplugin = <template>
+ <div class="above-site-header-outlet discourse-adplugin">
+ <AdSlot
+ @placement="above-site-header"
+ @category={{@outletArgs.category.slug}}
+ />
+ </div>
+</template>;
+
+export default DiscourseAdplugin;
diff --git a/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/after-topic-list-item/discourse-adplugin.gjs b/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/after-topic-list-item/discourse-adplugin.gjs
index e85221ae6c5..88183644164 100644
--- a/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/after-topic-list-item/discourse-adplugin.gjs
+++ b/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/after-topic-list-item/discourse-adplugin.gjs
@@ -1,10 +1,7 @@
-/* eslint-disable ember/no-classic-components */
-import Component from "@ember/component";
-import { tagName } from "@ember-decorators/component";
+import Component from "@glimmer/component";
import { slotContenders } from "discourse/plugins/discourse-adplugin/discourse/components/ad-slot";
import AdSlot from "../../components/ad-slot";
-@tagName("")
export default class DiscourseAdplugin extends Component {
static shouldRender(args, context) {
return (
@@ -19,11 +16,11 @@ export default class DiscourseAdplugin extends Component {
}
<template>
- <tr class="after-topic-list-item-outlet discourse-adplugin" ...attributes>
+ <tr class="after-topic-list-item-outlet discourse-adplugin">
<AdSlot
@placement="topic-list-between"
- @category={{this.category.slug}}
- @indexNumber={{this.index}}
+ @category={{@outletArgs.category.slug}}
+ @indexNumber={{@outletArgs.index}}
@childTagName="td"
@colspan="5"
/>
diff --git a/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/discovery-list-container-top/discourse-adplugin.gjs b/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/discovery-list-container-top/discourse-adplugin.gjs
index 4c2a8ddb5e0..1139199b317 100644
--- a/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/discovery-list-container-top/discourse-adplugin.gjs
+++ b/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/discovery-list-container-top/discourse-adplugin.gjs
@@ -1,16 +1,12 @@
-/* eslint-disable ember/no-classic-components */
-import Component from "@ember/component";
-import { tagName } from "@ember-decorators/component";
import AdSlot from "../../components/ad-slot";
-@tagName("")
-export default class DiscourseAdplugin extends Component {
- <template>
- <span
- class="discovery-list-container-top-outlet discourse-adplugin"
- ...attributes
- >
- <AdSlot @placement="topic-list-top" @category={{this.category.slug}} />
- </span>
- </template>
-}
+const DiscourseAdplugin = <template>
+ <span class="discovery-list-container-top-outlet discourse-adplugin">
+ <AdSlot
+ @placement="topic-list-top"
+ @category={{@outletArgs.category.slug}}
+ />
+ </span>
+</template>;
+
+export default DiscourseAdplugin;
diff --git a/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/topic-above-post-stream/discourse-adplugin.gjs b/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/topic-above-post-stream/discourse-adplugin.gjs
index ce849e3a039..4c08fe20394 100644
--- a/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/topic-above-post-stream/discourse-adplugin.gjs
+++ b/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/topic-above-post-stream/discourse-adplugin.gjs
@@ -1,19 +1,12 @@
-/* eslint-disable ember/no-classic-components */
-import Component from "@ember/component";
-import { tagName } from "@ember-decorators/component";
import AdSlot from "../../components/ad-slot";
-@tagName("")
-export default class DiscourseAdplugin extends Component {
- <template>
- <div
- class="topic-above-post-stream-outlet discourse-adplugin"
- ...attributes
- >
- <AdSlot
- @placement="topic-above-post-stream"
- @category={{this.model.category.slug}}
- />
- </div>
- </template>
-}
+const DiscourseAdplugin = <template>
+ <div class="topic-above-post-stream-outlet discourse-adplugin">
+ <AdSlot
+ @placement="topic-above-post-stream"
+ @category={{@outletArgs.model.category.slug}}
+ />
+ </div>
+</template>;
+
+export default DiscourseAdplugin;
diff --git a/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/topic-above-suggested/discourse-adplugin.gjs b/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/topic-above-suggested/discourse-adplugin.gjs
index eb7094dde25..ab177c80269 100644
--- a/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/topic-above-suggested/discourse-adplugin.gjs
+++ b/plugins/discourse-adplugin/assets/javascripts/discourse/connectors/topic-above-suggested/discourse-adplugin.gjs
@@ -1,16 +1,12 @@
-/* eslint-disable ember/no-classic-components */
-import Component from "@ember/component";
-import { tagName } from "@ember-decorators/component";
import AdSlot from "../../components/ad-slot";
-@tagName("")
-export default class DiscourseAdplugin extends Component {
- <template>
- <div class="topic-above-suggested-outlet discourse-adplugin" ...attributes>
- <AdSlot
- @placement="topic-above-suggested"
- @category={{this.model.category.slug}}
- />
- </div>
- </template>
-}
+const DiscourseAdplugin = <template>
+ <div class="topic-above-suggested-outlet discourse-adplugin">
+ <AdSlot
+ @placement="topic-above-suggested"
+ @category={{@outletArgs.model.category.slug}}
+ />
+ </div>
+</template>;
+
+export default DiscourseAdplugin;
diff --git a/plugins/discourse-adplugin/assets/stylesheets/adplugin.scss b/plugins/discourse-adplugin/assets/stylesheets/adplugin.scss
index a7ae5f6e921..78620363119 100644
--- a/plugins/discourse-adplugin/assets/stylesheets/adplugin.scss
+++ b/plugins/discourse-adplugin/assets/stylesheets/adplugin.scss
@@ -129,6 +129,11 @@
margin: 0 auto;
}
+.house-creative.house-above-site-header {
+ margin: 10px 0;
+ text-align: center;
+}
+
.house-creative.house-post-bottom {
margin: 0 0 10px 52px;
clear: both;
@@ -202,6 +207,14 @@
text-align: center;
}
+.adbutler-above-site-header,
+.adsense-above-site-header,
+.dfp-above-site-header,
+.amazon-above-site-header {
+ margin: 10px 0;
+ text-align: center;
+}
+
.adbutler-topic-above-post-stream {
margin: 10px 0 10px 0;
}
diff --git a/plugins/discourse-adplugin/config/locales/client.en.yml b/plugins/discourse-adplugin/config/locales/client.en.yml
index 86a61a48578..6e0e81f796f 100755
--- a/plugins/discourse-adplugin/config/locales/client.en.yml
+++ b/plugins/discourse-adplugin/config/locales/client.en.yml
@@ -55,6 +55,9 @@ en:
ads: "Ads"
settings: "Settings"
+ above_site_header:
+ title: "Above site header"
+ description: "Ads to show at the top of the page, above the site header."
topic_list_top:
title: "Topic list top ads"
description: "Ads to show at the top of topic list pages."
diff --git a/plugins/discourse-adplugin/config/locales/server.en.yml b/plugins/discourse-adplugin/config/locales/server.en.yml
index efb5e5d741a..aac7cf17b21 100755
--- a/plugins/discourse-adplugin/config/locales/server.en.yml
+++ b/plugins/discourse-adplugin/config/locales/server.en.yml
@@ -43,6 +43,13 @@ en:
dfp_through_trust_level: "Show your ads to users based on trust levels. Users with trust level higher than this value will not see ads."
dfp_exclude_groups: "Ads will not be shown to members of these groups"
+ dfp_above_site_header_code: "Enter the unique Code of the ad unit to display above the site header. This is the short code (max 100 chars) given to the ad unit when it was created, not the JavaScript code."
+ dfp_above_site_header_ad_sizes: "Choose your ad size for the ad unit above the site header."
+ dfp_mobile_above_site_header_code: "Enter the unique Code of the ad unit to display above the site header on mobile view. This is the short code (max 100 chars) given to the ad unit when it was created, not the JavaScript code."
+ dfp_mobile_above_site_header_ad_sizes: "Choose your ad size for the ad unit above the site header on mobile view."
+ dfp_target_above_site_header_key_code: "Input custom targeting keys - inventory Level"
+ dfp_target_above_site_header_value_code: "Input custom targeting values - inventory Level"
+
dfp_topic_list_top_code: "Enter the unique Code of the ad unit to display above topic lists. This is the short code (max 100 chars) given to the ad unit when it was created, not the JavaScript code."
dfp_topic_list_top_ad_sizes: "Choose your ad size for the ad unit above topic lists."
dfp_mobile_topic_list_top_code: "Enter the unique Code of the ad unit to display above topic lists on mobile view. This is the short code (max 100 chars) given to the ad unit when it was created, not the JavaScript code."
@@ -75,6 +82,10 @@ en:
adsense_publisher_code: "Your publisher ID. Enter only the number, excluding 'pub-'. NOTE: You will need to update the {{setting:content_security_policy_script_src}} setting. See <a href='https://meta.discourse.org/t/33734' target='_blank'>this topic</a> for the latest instructions."
adsense_through_trust_level: "Show your ads to users based on trust levels. Users with trust level higher than this value will not see ads."
adsense_exclude_groups: "Ads will not be shown to members of these groups"
+ adsense_above_site_header_code: "Enter code of the ad unit to display at above site header location. This is the number assigned to the ad unit, not the JavaScript code."
+ adsense_mobile_above_site_header_code: "Enter code of the ad unit to display mobile ads at above site header location. This is the number assigned to the ad unit, not the JavaScript code."
+ adsense_above_site_header_ad_sizes: "Choose your ad size"
+ adsense_mobile_above_site_header_ad_size: "Choose your ad size"
adsense_topic_list_top_code: "Enter code of the ad unit to display at topic list top location. This is the number assigned to the ad unit, not the JavaScript code."
adsense_mobile_topic_list_top_code: "Enter code of the ad unit to display mobile ads at topic list top location. This is the number assigned to the ad unit, not the JavaScript code."
adsense_topic_list_top_ad_sizes: "Choose your ad size"
@@ -95,6 +106,12 @@ en:
amazon_through_trust_level: "Show your ads to users based on trust levels. Users with trust level higher than this value will not see ads."
amazon_exclude_groups: "Ads will not be shown to members of these groups"
+ amazon_above_site_header_src_code: "Enter src code to display at above site header location"
+ amazon_above_site_header_ad_width_code: "Input your ad width"
+ amazon_above_site_header_ad_height_code: "Input your ad height"
+ amazon_mobile_above_site_header_src_code: "Enter src code to display mobile ads at above site header location"
+ amazon_mobile_above_site_header_ad_width_code: "Input your ad width (mobile)"
+ amazon_mobile_above_site_header_ad_height_code: "Input your ad height (mobile)"
amazon_topic_list_top_src_code: "Enter src code to display at topic list top location"
amazon_topic_list_top_ad_width_code: "Input your ad width"
amazon_topic_list_top_ad_height_code: "Input your ad height"
@@ -125,10 +142,13 @@ en:
carbonads_placement: "Your Carbon Ads Placement"
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_above_site_header_enabled: "Show an ad above the site header"
carbonads_topic_list_top_enabled: "Show an ad above the topic list"
carbonads_above_post_stream_enabled: "Show an ad above the post stream"
adbutler_publisher_id: "AdButler Publisher ID. NOTE: You may need to update the {{setting:content_security_policy_script_src}} setting. See <a href='https://meta.discourse.org/t/33734' target='_blank'>this topic</a> for the latest instructions."
+ adbutler_above_site_header_zone_id: "Zone ID for above site header location"
+ adbutler_mobile_above_site_header_zone_id: "Zone ID for mobile above site header location"
adbutler_mobile_topic_list_top_zone_id: "Zone ID for mobile topic list top location"
adbutler_mobile_topic_above_post_stream_zone_id: "Zone ID for mobile topic above post stream location"
adbutler_mobile_post_bottom_zone_id: "Zone ID for mobile post bottom location"
diff --git a/plugins/discourse-adplugin/config/settings.yml b/plugins/discourse-adplugin/config/settings.yml
index e812e21153f..6540c5fc7fe 100755
--- a/plugins/discourse-adplugin/config/settings.yml
+++ b/plugins/discourse-adplugin/config/settings.yml
@@ -111,6 +111,26 @@ adsense_plugin:
default: "responsive"
type: list
choices: *adsense_choices
+ adsense_above_site_header_code:
+ client: true
+ default: ""
+ max: 50
+ regex: '^[\d]*$'
+ adsense_above_site_header_ad_sizes:
+ client: true
+ default: "728*90 - leaderboard"
+ type: list
+ choices: *adsense_choices
+ adsense_mobile_above_site_header_code:
+ client: true
+ default: ""
+ max: 50
+ regex: '^[\d]*$'
+ adsense_mobile_above_site_header_ad_size:
+ client: true
+ default: "responsive"
+ type: list
+ choices: *adsense_choices
adsense_topic_above_post_stream_code:
client: true
default: ""
@@ -261,6 +281,32 @@ dfp_plugin:
default: ""
type: value_list
client: true
+ dfp_above_site_header_code:
+ client: true
+ default: ""
+ max: 50
+ dfp_above_site_header_ad_sizes:
+ client: true
+ default: "728*90 - leaderboard"
+ type: list
+ choices: *dfp_choices
+ dfp_mobile_above_site_header_code:
+ client: true
+ default: ""
+ max: 50
+ dfp_mobile_above_site_header_ad_sizes:
+ client: true
+ default: "320*50 - mobile leaderboard"
+ type: list
+ choices: *dfp_choices
+ dfp_target_above_site_header_key_code:
+ default: ""
+ type: value_list
+ client: true
+ dfp_target_above_site_header_value_code:
+ default: ""
+ type: value_list
+ client: true
dfp_topic_above_post_stream_code:
client: true
default: ""
@@ -383,6 +429,24 @@ amazon_plugin:
amazon_mobile_topic_list_top_ad_height_code:
client: true
default: ""
+ amazon_above_site_header_src_code:
+ client: true
+ default: ""
+ amazon_above_site_header_ad_width_code:
+ client: true
+ default: ""
+ amazon_above_site_header_ad_height_code:
+ client: true
+ default: ""
+ amazon_mobile_above_site_header_src_code:
+ client: true
+ default: ""
+ amazon_mobile_above_site_header_ad_width_code:
+ client: true
+ default: ""
+ amazon_mobile_above_site_header_ad_height_code:
+ client: true
+ default: ""
amazon_topic_above_post_stream_src_code:
client: true
default: ""
@@ -468,6 +532,9 @@ carbonads_plugin:
allow_any: false
refresh: true
validator: "AtLeastOneGroupValidator"
+ carbonads_above_site_header_enabled:
+ client: true
+ default: false
carbonads_topic_list_top_enabled:
client: true
default: false
@@ -504,6 +571,12 @@ adbutler_plugin:
adbutler_mobile_topic_list_top_zone_id:
client: true
default: ""
+ adbutler_above_site_header_zone_id:
+ client: true
+ default: ""
+ adbutler_mobile_above_site_header_zone_id:
+ client: true
+ default: ""
adbutler_topic_above_post_stream_zone_id:
client: true
default: ""
diff --git a/plugins/discourse-adplugin/spec/models/house_ad_setting_spec.rb b/plugins/discourse-adplugin/spec/models/house_ad_setting_spec.rb
index 3ab4f85dab3..cc2d99682ee 100644
--- a/plugins/discourse-adplugin/spec/models/house_ad_setting_spec.rb
+++ b/plugins/discourse-adplugin/spec/models/house_ad_setting_spec.rb
@@ -32,6 +32,14 @@ describe AdPlugin::HouseAdSetting do
expect(AdPlugin::HouseAdSetting.all[:topic_list_top]).to eq("Banner|Donate")
end
+ it "can set the above site header override" do
+ AdPlugin::HouseAd.create(name: "Header", html: "<p>Header</p>")
+ expect { AdPlugin::HouseAdSetting.update(:above_site_header, "Header") }.to change {
+ PluginStoreRow.count
+ }.by(1)
+ expect(AdPlugin::HouseAdSetting.all[:above_site_header]).to eq("Header")
+ end
+
it "can update an existing override" do
AdPlugin.pstore_set("ad-setting:topic_list_top", "Banner")
expect { AdPlugin::HouseAdSetting.update(:topic_list_top, "Banner|Donate") }.to_not change {
diff --git a/plugins/discourse-adplugin/test/javascripts/acceptance/house-ad-test.js b/plugins/discourse-adplugin/test/javascripts/acceptance/house-ad-test.js
index 6b506bfb75d..dbba7796113 100644
--- a/plugins/discourse-adplugin/test/javascripts/acceptance/house-ad-test.js
+++ b/plugins/discourse-adplugin/test/javascripts/acceptance/house-ad-test.js
@@ -128,6 +128,81 @@ acceptance(`House Ads`, function (needs) {
});
});
+acceptance(`House Ads | Above site header`, function (needs) {
+ needs.user();
+ needs.settings({ no_ads_for_categories: "" });
+ needs.site({
+ house_creatives: {
+ settings: {
+ above_site_header: "Above Site Header",
+ },
+ creatives: {
+ "Above Site Header": {
+ html: "<div class='h-above-site-header'>ABOVE SITE HEADER</div>",
+ category_ids: [],
+ },
+ },
+ },
+ });
+
+ test("renders a house ad above the site header", async function (assert) {
+ updateCurrentUser({
+ staff: false,
+ trust_level: 1,
+ show_to_groups: true,
+ });
+ await visit("/latest");
+
+ assert
+ .dom(".above-site-header-outlet .h-above-site-header")
+ .exists({ count: 1 }, "renders an ad above the site header");
+ });
+});
+
+acceptance(
+ `House Ads | Above site header | no_ads_for_categories`,
+ function (needs) {
+ needs.user();
+ needs.settings({ no_ads_for_categories: "1" });
+ needs.site({
+ house_creatives: {
+ settings: {
+ above_site_header: "Above Site Header",
+ },
+ creatives: {
+ "Above Site Header": {
+ html: "<div class='h-above-site-header'>ABOVE SITE HEADER</div>",
+ category_ids: [],
+ },
+ },
+ },
+ });
+
+ test("hides the ad above the site header in no-ads categories", async function (assert) {
+ updateCurrentUser({
+ staff: false,
+ trust_level: 1,
+ show_to_groups: true,
+ });
+
+ await visit("/t/28830"); // topic in a no_ads_for_categories category
+ assert
+ .dom(".above-site-header-outlet .h-above-site-header")
+ .doesNotExist(
+ "ad is hidden because the topic category is in no_ads_for_categories"
+ );
+
+ await visit("/t/280"); // topic in a category not in no_ads_for_categories
+ assert
+ .dom(".above-site-header-outlet .h-above-site-header")
+ .exists(
+ { count: 1 },
+ "ad is shown on topics in categories not in no_ads_for_categories"
+ );
+ });
+ }
+);
+
acceptance(`House Ads | Route Filtering | Display Ad`, function (needs) {
needs.user();
needs.settings({
diff --git a/plugins/discourse-adplugin/test/javascripts/acceptance/mixed-ads-test.js b/plugins/discourse-adplugin/test/javascripts/acceptance/mixed-ads-test.js
index 56738123bf6..e23c3bed457 100644
--- a/plugins/discourse-adplugin/test/javascripts/acceptance/mixed-ads-test.js
+++ b/plugins/discourse-adplugin/test/javascripts/acceptance/mixed-ads-test.js
@@ -17,6 +17,10 @@ acceptance("Mixed Ads", function (needs) {
dfp_topic_list_top_ad_sizes: "728*90 - leaderboard",
dfp_mobile_topic_list_top_code: "mobile_list_top_ad_unit",
dfp_mobile_topic_list_top_ad_size: "300*250 - medium rectangle",
+ dfp_above_site_header_code: "above_site_header_ad_unit",
+ dfp_above_site_header_ad_sizes: "728*90 - leaderboard",
+ dfp_mobile_above_site_header_code: "mobile_above_site_header_ad_unit",
+ dfp_mobile_above_site_header_ad_sizes: "320*50 - mobile leaderboard",
dfp_post_bottom_code: "post_bottom_ad_unit",
dfp_post_bottom_ad_sizes: "728*90 - leaderboard",
dfp_mobile_post_bottom_code: "mobile_post_bottom_ad_unit",
@@ -53,11 +57,15 @@ acceptance("Mixed Ads", function (needs) {
await visit("/t/280"); // 20 posts
assert.dom(".house-creative").exists({ count: 2 });
- assert.dom(".google-dfp-ad").exists({ count: 3 });
+ // 3 post-bottom ads + 1 above-site-header ad
+ assert.dom(".google-dfp-ad").exists({ count: 4 });
await visit("/latest");
assert
.dom(".h-topic-list-top, .dfp-ad-topic-list-top")
.exists({ count: 1 }, "renders ad above topic list");
+ assert
+ .dom(".dfp-ad-above-site-header")
+ .exists({ count: 1 }, "renders ad above the site header");
});
});