3 Commits
Author SHA1 Message Date
Penar Musaraj f745ecfbdc Rename adsense_ads_txt setting to ads_txt 2019-06-03 11:39:28 -04:00
Neil Lalonde ab9cf6459e Update translations 2019-05-30 11:30:03 -04:00
Guo Xiang Tan 546101a357 Add frozen string literal to files. 2019-05-13 10:16:50 +08:00
85 changed files with 598 additions and 284 deletions
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
source 'https://rubygems.org'
group :development do
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ::AdPlugin
class HouseAdSettingsController < ::ApplicationController
requires_plugin AdPlugin.plugin_name
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ::AdPlugin
class HouseAdsController < ::ApplicationController
requires_plugin AdPlugin.plugin_name
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ::AdPlugin
class HouseAd
include ActiveModel::Validations
+2
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
module ::AdPlugin
class HouseAdSetting
DEFAULTS = {
@@ -0,0 +1 @@
{{ad-slot placement="post-bottom" category=model.topic.category.slug postNumber=model.post_number}}
@@ -0,0 +1 @@
{{post-bottom-ad model=this}}
@@ -1,194 +0,0 @@
import { createWidget } from "discourse/widgets/widget";
import { h } from "virtual-dom";
const adConfig = Ember.Object.create({
"google-adsense": {
settingPrefix: "adsense", // settings follow naming convention
enabledSetting: "adsense_publisher_code",
nthPost: "adsense_nth_post_code"
},
"google-dfp-ad": {
settingPrefix: "dfp", // settings follow naming convention
enabledSetting: "dfp_publisher_id",
nthPost: "dfp_nth_post_code"
},
"amazon-product-links": {
settingPrefix: "amazon",
enabledSetting: false,
nthPost: "amazon_nth_post_code",
desktop: {
"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: {
"topic-list-top": "amazon_mobile_topic_list_top_src_code",
"post-bottom": "amazon_mobile_post_bottom_src_code",
"topic-above-post-stream":
"amazon_mobile_topic_above_post_stream_src_code",
"topic-above-suggested": "amazon_mobile_topic_above_suggested_src_code"
}
},
"codefund-ad": {
settingPrefix: "codefund",
enabledSetting: "codefund_property_id",
nthPost: "codefund_nth_post",
desktop: {
"topic-list-top": "codefund_top_of_topic_list_enabled",
"post-bottom": "codefund_below_post_enabled",
"topic-above-post-stream": "codefund_above_post_stream_enabled",
"topic-above-suggested": "codefund_above_suggested_enabled"
}
},
"carbonads-ad": {
settingPrefix: "carbonads",
enabledSetting: "carbonads_serve_id",
desktop: {
"topic-list-top": "carbonads_topic_list_top_enabled",
"post-bottom": false,
"topic-above-post-stream": "carbonads_above_post_stream_enabled",
"topic-above-suggested": false
}
}
});
const displayCounts = {
houseAds: 0,
allAds: 0
};
createWidget("ad-slot", {
tagName: "",
html(attrs) {
const adsToShow = this.adComponents();
let output = [];
adsToShow.forEach(widgetName => {
output.push(this.attach(widgetName, this.attrs));
});
return output;
},
/**
* For a given ad placement and optionally a post number if in between posts,
* list all ad network names that are configured to show there.
*/
availableAdTypes() {
const placement = this.attrs.placement,
postNumber = this.attrs.postNumber;
let types = [];
const houseAds = this.site.get("house_creatives"),
placeUnderscored = placement.replace(/-/g, "_");
if (houseAds && houseAds.settings) {
const adsForSlot = houseAds.settings[placeUnderscored];
if (
Object.keys(houseAds.creatives).length > 0 &&
!Ember.isBlank(adsForSlot) &&
(!postNumber ||
this.isNthPost(parseInt(houseAds.settings.after_nth_post, 10)))
) {
types.push("house-ad");
}
}
Object.keys(adConfig).forEach(adNetwork => {
const config = adConfig[adNetwork];
let settingNames = null,
name;
if (
config.enabledSetting &&
!Ember.isBlank(this.siteSettings[config.enabledSetting]) &&
(!postNumber ||
!config.nthPost ||
this.isNthPost(parseInt(this.siteSettings[config.nthPost], 10)))
) {
if (this.site.mobileView) {
settingNames = config.mobile || config.desktop;
} else {
settingNames = config.desktop;
}
if (settingNames) {
name = settingNames[placement];
}
if (name === undefined) {
// follows naming convention: prefix_(mobile_)_{placement}_code
name = `${config.settingPrefix}_${
this.site.mobileView ? "mobile_" : ""
}${placeUnderscored}_code`;
}
if (name !== false && !Ember.isBlank(this.siteSettings[name])) {
types.push(adNetwork);
}
}
});
return types;
},
/**
* Returns a list of the names of ad components that should be rendered
* in the given ad placement. It handles alternating between house ads
* and other ad networks.
*/
adComponents() {
const placement = this.attrs.placement,
availableAdTypes = this.availableAdTypes();
if (
!availableAdTypes.includes("house-ad") ||
availableAdTypes.length === 1
) {
// Current behaviour is to allow multiple ads from different networks
// to show in the same place. We could change this to choose one somehow.
return availableAdTypes;
}
const houseAds = this.site.get("house_creatives");
let houseAdsSkipped = false;
if (houseAds.settings.house_ads_frequency === 100) {
// house always wins
return ["house-ad"];
} else if (houseAds.settings.house_ads_frequency > 0) {
// show house ads the given percent of the time
if (
displayCounts.allAds === 0 ||
(100 * displayCounts.houseAds) / displayCounts.allAds <
houseAds.settings.house_ads_frequency
) {
displayCounts.houseAds += 1;
displayCounts.allAds += 1;
return ["house-ad"];
} else {
houseAdsSkipped = true;
}
}
const networkNames = availableAdTypes.filter(x => x !== "house-ad");
if (houseAdsSkipped) {
displayCounts.allAds += networkNames.length;
}
return networkNames;
},
isNthPost(n) {
if (this.attrs.postNumber && n && n > 0) {
return this.attrs.postNumber % n === 0;
} else {
return false;
}
}
});
@@ -1,32 +0,0 @@
import { createWidget } from "discourse/widgets/widget";
import { h } from "virtual-dom";
createWidget("house-ad", {
tagName: "",
html(attrs) {
console.log('house-ad');
if (attrs.postNumber % 10 === 0) {
return h(
"div.house-creative.house-post-bottom",
h(
"a.h-create.h-socks",
{ href: "#", target: "_blank" },
h(
"div.container",
h(
"div.tall-image",
h("img", {
src:
"http://localhost:3000/uploads/default/original/1X/14844d926f49c3de68a91188661173f694e6b8bc.jpeg"
})
)
)
)
);
} else {
return '';
}
}
});
@@ -8,15 +8,9 @@ export default {
api.decorateWidget("post:after", dec => {
if (dec.canConnectComponent) {
if (!dec.attrs.cloaked) {
// return dec.connect({
// component: "post-bottom-ad",
// context: "model"
// });
console.log('initialize attach ad-slot');
return dec.attach('ad-slot', {
placement: 'post-bottom',
category: 'TODO',
postNumber: dec.attrs.post_number
return dec.connect({
component: "post-bottom-ad",
context: "model"
});
}
} else {
+1
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
# Usage:
# bundle install
+6
View File
@@ -11,3 +11,9 @@ ar:
site_settings:
categories:
amazon_plugin: 'اعلانات امازون'
adplugin:
house_ads:
new: "جديد"
settings: "إعدادات"
save: "احفظ"
delete: "أحذف"
+9 -1
View File
@@ -5,4 +5,12 @@
# To work with us on translations, join this project:
# https://www.transifex.com/projects/p/discourse-org/
bg: {}
bg:
admin_js:
admin:
adplugin:
house_ads:
new: "Нов"
settings: "Настройки"
save: "Запази"
delete: "Изтрий"
+6
View File
@@ -14,3 +14,9 @@ bs_BA:
site_settings:
categories:
amazon_plugin: 'Amazon'
adplugin:
house_ads:
new: "New"
settings: "Postavke"
save: "Sačuvaj"
delete: "Delete"
+6
View File
@@ -11,3 +11,9 @@ ca:
site_settings:
categories:
amazon_plugin: 'Amazon'
adplugin:
house_ads:
new: "Nou"
settings: "Configuracions"
save: "Desa"
delete: "Esborra"
+6
View File
@@ -14,3 +14,9 @@ cs:
site_settings:
categories:
amazon_plugin: 'Amazon'
adplugin:
house_ads:
new: "Noví"
settings: "Nastavení"
save: "Uložit"
delete: "Smazat"
+6
View File
@@ -14,3 +14,9 @@ da:
site_settings:
categories:
amazon_plugin: 'Amazon'
adplugin:
house_ads:
new: "Ny"
settings: "Indstillinger"
save: "Gem"
delete: "Slet"
+26
View File
@@ -13,7 +13,33 @@ de:
admin:
site_settings:
categories:
ad_plugin: 'Anzeigen Plugin'
dfp_plugin: 'DFP/Ad Manager'
adsense_plugin: 'AdSense'
amazon_plugin: 'Amazon'
codefund_plugin: 'CodeFund'
carbonads_plugin: 'Carbon Ads'
adplugin:
house_ads:
title: "Haus Anzeigen"
new: "Neu"
settings: "Einstellungen"
new_name: "Neue Haus Anzeigen"
save: "Speichern"
delete: "Löschen"
description: "Definiere deine eigenen Anzeige und wo sie angezeigt werden sollen."
get_started: "Starte mit dem Erstellen einer neuen Anzeige."
filter_placeholder: "Anzeigen auswählen"
more_settings: "Weitere Einstellungen"
topic_list_top:
title: "Themenliste der Top Anzeigen"
description: "Anzeigen, die oben auf den Themenlisten-Seiten gezeigt werden sollen."
topic_above_post_stream:
title: "Thema oberhalb Beitragsfluss"
description: "Anzeigen, die oberhalb des Titels eines Themas auf der Themenseite gezeigt werden sollen."
topic_above_suggested:
title: "Thema oberhalb Vorgeschlagen"
description: "Anzeigen, die nach dem letzten Beitrag in einem Thema, oberhalb der vorgeschlagenen Themen angezeigt werden sollen."
post_bottom:
title: "Zwischen Beiträgen"
description: "Anzeigen zwischen Beiträgen anzeigen, nach je N Beiträgen."
+6
View File
@@ -11,3 +11,9 @@ el:
site_settings:
categories:
amazon_plugin: 'Amazon'
adplugin:
house_ads:
new: "Νέο"
settings: "Ρυθμίσεις"
save: "Αποθήκευση"
delete: "Σβήσιμο"
+9
View File
@@ -18,3 +18,12 @@ es:
amazon_plugin: 'Amazon'
codefund_plugin: 'CodeFund'
carbonads_plugin: 'Carbon Ads'
adplugin:
house_ads:
new: "Nuevo"
settings: "Ajustes"
save: "Guardar"
delete: "Borrar"
get_started: "Comienza creando un nuevo anuncio."
filter_placeholder: "Seleccionar anuncios..."
more_settings: "Más ajustes"
+6
View File
@@ -14,3 +14,9 @@ et:
site_settings:
categories:
amazon_plugin: 'Amazon'
adplugin:
house_ads:
new: "Uus"
settings: "Seaded"
save: "Salvesta"
delete: "Kustuta"
+6
View File
@@ -11,3 +11,9 @@ fa_IR:
site_settings:
categories:
amazon_plugin: 'آمازون'
adplugin:
house_ads:
new: "جدید"
settings: "تنظیمات"
save: "ذخیره"
delete: "حذف"
+6
View File
@@ -17,3 +17,9 @@ fi:
adsense_plugin: 'AdSense'
amazon_plugin: 'Amazon'
codefund_plugin: 'CodeFund'
adplugin:
house_ads:
new: "Uudet"
settings: "Asetukset"
save: "Tallenna"
delete: "Poista"
+7
View File
@@ -17,3 +17,10 @@ fr:
adsense_plugin: 'AdSense'
amazon_plugin: 'Amazon'
codefund_plugin: 'CodeFund'
carbonads_plugin: 'Carbon Ads'
adplugin:
house_ads:
new: "Nouveau"
settings: "Paramètres"
save: "Sauvegarder"
delete: "Supprimer"
+6
View File
@@ -11,3 +11,9 @@ gl:
site_settings:
categories:
amazon_plugin: 'Amazon'
adplugin:
house_ads:
new: "Novo"
settings: "Axustes"
save: "Gardar"
delete: "Eliminar"
+29
View File
@@ -13,4 +13,33 @@ he:
admin:
site_settings:
categories:
ad_plugin: 'תוסף פרסום'
dfp_plugin: 'DFP/Ad Manager'
adsense_plugin: 'AdSense'
amazon_plugin: 'אמזון'
codefund_plugin: 'CodeFund'
carbonads_plugin: 'Carbon Ads'
adplugin:
house_ads:
title: "מודעות הבית"
new: "חדש"
settings: "הגדרות"
new_name: "מודעת בית חדשה"
save: "שמירה"
delete: "מחיקה"
description: "הגדרת פרסומות משלך והיכן הן תוצגנה."
get_started: "ניתן להתחיל ביצירת פרסומת חדשה."
filter_placeholder: "בחירת פרסומות…"
more_settings: "הגדרות נוספות"
topic_list_top:
title: "פרסומות בראש רשימת הנושאים"
description: "פרסומות שתופענה בראש עמוד רשימת הנושים."
topic_above_post_stream:
title: "מעל שרשור הודעות של נושא"
description: "פרסומות שתופענה מעל כותרת הנושא בעמוד הנושא."
topic_above_suggested:
title: "בנושא מעל ההצעות"
description: "פרסומות שתופענה לאחר הפוסט האחרון בנושא, מעל לנושאים המוצעים"
post_bottom:
title: "בין פוסטים"
description: "פרסומות שתופענה בין פוסטים, לאחר כל N פוסטים."
+6
View File
@@ -15,3 +15,9 @@ hu:
categories:
amazon_plugin: 'Amazon'
codefund_plugin: 'CodeFund'
adplugin:
house_ads:
new: "Új"
settings: "Beállítások"
save: "Mentés"
delete: "Töröl"
+6
View File
@@ -17,3 +17,9 @@ hy:
adsense_plugin: 'AdSense'
amazon_plugin: 'Amazon'
codefund_plugin: 'CodeFund'
adplugin:
house_ads:
new: "Նոր"
settings: "Կարգավորումներ"
save: "Պահպանել"
delete: "Ջնջել"
+7 -1
View File
@@ -5,4 +5,10 @@
# To work with us on translations, join this project:
# https://www.transifex.com/projects/p/discourse-org/
id: {}
id:
admin_js:
admin:
adplugin:
house_ads:
new: "Baru"
delete: "Hapus"
+6
View File
@@ -17,3 +17,9 @@ it:
adsense_plugin: 'AdSense'
amazon_plugin: 'Amazon'
codefund_plugin: 'CodeFund'
adplugin:
house_ads:
new: "Nuovo"
settings: "Impostazioni"
save: "Salva"
delete: "Elimina"

Some files were not shown because too many files have changed in this diff Show More