DEV: apply coding standards (#91)
This commit is contained in:
parent
88e2bab0d6
commit
30dad0281d
|
@ -5,3 +5,5 @@ auto_generated
|
|||
.DS_Store
|
||||
*.swp
|
||||
node_modules
|
||||
yarn-error.log
|
||||
.rubocop-https---raw-githubusercontent-com-discourse-*
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
plugins: ["ember-template-lint-plugin-discourse"],
|
||||
extends: "discourse:recommended",
|
||||
};
|
|
@ -2,9 +2,9 @@ export default {
|
|||
resource: "admin.adminPlugins",
|
||||
path: "/plugins",
|
||||
map() {
|
||||
this.route("houseAds", { path: "/pluginad/house_creatives" }, function() {
|
||||
this.route("houseAds", { path: "/pluginad/house_creatives" }, function () {
|
||||
this.route("index", { path: "/" });
|
||||
this.route("show", { path: "/:ad_id" });
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -54,9 +54,9 @@ export default Ember.Component.extend({
|
|||
let noAdsGroups = this.siteSettings.no_ads_for_groups
|
||||
.split("|")
|
||||
.filter(Boolean);
|
||||
let currentGroups = groups.map(g => g.id.toString());
|
||||
let currentGroups = groups.map((g) => g.id.toString());
|
||||
|
||||
return !currentGroups.any(g => noAdsGroups.includes(g));
|
||||
return !currentGroups.any((g) => noAdsGroups.includes(g));
|
||||
},
|
||||
|
||||
@discourseComputed(
|
||||
|
@ -95,5 +95,5 @@ export default Ember.Component.extend({
|
|||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -5,12 +5,12 @@ const adConfig = Ember.Object.create({
|
|||
"google-adsense": {
|
||||
settingPrefix: "adsense", // settings follow naming convention
|
||||
enabledSetting: "adsense_publisher_code",
|
||||
nthPost: "adsense_nth_post_code"
|
||||
nthPost: "adsense_nth_post_code",
|
||||
},
|
||||
"google-dfp-ad": {
|
||||
settingPrefix: "dfp", // settings follow naming convention
|
||||
enabledSetting: "dfp_publisher_id",
|
||||
nthPost: "dfp_nth_post_code"
|
||||
nthPost: "dfp_nth_post_code",
|
||||
},
|
||||
"amazon-product-links": {
|
||||
settingPrefix: "amazon",
|
||||
|
@ -20,15 +20,15 @@ const adConfig = Ember.Object.create({
|
|||
"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"
|
||||
"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"
|
||||
}
|
||||
"topic-above-suggested": "amazon_mobile_topic_above_suggested_src_code",
|
||||
},
|
||||
},
|
||||
"carbonads-ad": {
|
||||
settingPrefix: "carbonads",
|
||||
|
@ -37,8 +37,8 @@ const adConfig = Ember.Object.create({
|
|||
"topic-list-top": "carbonads_topic_list_top_enabled",
|
||||
"post-bottom": false,
|
||||
"topic-above-post-stream": "carbonads_above_post_stream_enabled",
|
||||
"topic-above-suggested": false
|
||||
}
|
||||
"topic-above-suggested": false,
|
||||
},
|
||||
},
|
||||
"adbutler-ad": {
|
||||
settingPrefix: "adbutler",
|
||||
|
@ -47,21 +47,21 @@ const adConfig = Ember.Object.create({
|
|||
"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"
|
||||
"topic-above-suggested": "adbutler_topic_above_suggested_zone_id",
|
||||
},
|
||||
mobile: {
|
||||
"topic-list-top": "adbutler_mobile_topic_list_top_zone_id",
|
||||
"post-bottom": "adbutler_mobile_post_bottom_zone_id",
|
||||
"topic-above-post-stream":
|
||||
"adbutler_mobile_topic_above_post_stream_zone_id",
|
||||
"topic-above-suggested": "adbutler_mobile_topic_above_suggested_zone_id"
|
||||
}
|
||||
}
|
||||
"topic-above-suggested": "adbutler_mobile_topic_above_suggested_zone_id",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const displayCounts = {
|
||||
houseAds: 0,
|
||||
allAds: 0
|
||||
allAds: 0,
|
||||
};
|
||||
|
||||
export default AdComponent.extend({
|
||||
|
@ -90,7 +90,7 @@ export default AdComponent.extend({
|
|||
}
|
||||
}
|
||||
|
||||
Object.keys(adConfig).forEach(adNetwork => {
|
||||
Object.keys(adConfig).forEach((adNetwork) => {
|
||||
const config = adConfig[adNetwork];
|
||||
let settingNames = null,
|
||||
name;
|
||||
|
@ -185,12 +185,12 @@ export default AdComponent.extend({
|
|||
}
|
||||
}
|
||||
|
||||
const networkNames = availableAdTypes.filter(x => x !== "house-ad");
|
||||
const networkNames = availableAdTypes.filter((x) => x !== "house-ad");
|
||||
|
||||
if (houseAdsSkipped) {
|
||||
displayCounts.allAds += networkNames.length;
|
||||
}
|
||||
|
||||
return networkNames;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -19,8 +19,8 @@ function loadAdbutler() {
|
|||
}
|
||||
|
||||
_promise = loadScript("https://" + adserverHostname + "/app.js", {
|
||||
scriptTag: true
|
||||
}).then(function() {
|
||||
scriptTag: true,
|
||||
}).then(function () {
|
||||
_loaded = true;
|
||||
});
|
||||
|
||||
|
@ -61,7 +61,7 @@ export default AdComponent.extend({
|
|||
divId: divId,
|
||||
publisherId: publisherId,
|
||||
zoneId: zoneId,
|
||||
dimensions: dimensions
|
||||
dimensions: dimensions,
|
||||
});
|
||||
|
||||
this.set("publisherId", publisherId);
|
||||
|
@ -74,11 +74,11 @@ export default AdComponent.extend({
|
|||
}
|
||||
|
||||
loadAdbutler().then(
|
||||
function() {
|
||||
function () {
|
||||
if (this.divs.length > 0) {
|
||||
let abkw = window.abkw || "";
|
||||
window.AdButler.ads.push({
|
||||
handler: function(opt) {
|
||||
handler: function (opt) {
|
||||
window.AdButler.register(
|
||||
opt.place.publisherId,
|
||||
opt.place.zoneId,
|
||||
|
@ -91,8 +91,8 @@ export default AdComponent.extend({
|
|||
place: this.divs.pop(),
|
||||
keywords: abkw,
|
||||
domain: adserverHostname,
|
||||
click: "CLICK_MACRO_PLACEHOLDER"
|
||||
}
|
||||
click: "CLICK_MACRO_PLACEHOLDER",
|
||||
},
|
||||
});
|
||||
}
|
||||
}.bind(this)
|
||||
|
@ -144,5 +144,5 @@ export default AdComponent.extend({
|
|||
return true;
|
||||
}
|
||||
return this.isNthPost(parseInt(this.siteSettings.adbutler_nth_post, 10));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ const data = {
|
|||
"topic-list-top": {},
|
||||
"topic-above-post-stream": {},
|
||||
"topic-above-suggested": {},
|
||||
"post-bottom": {}
|
||||
"post-bottom": {},
|
||||
};
|
||||
|
||||
let mobileView = Discourse.Site.currentProp("mobileView");
|
||||
|
@ -190,5 +190,5 @@ export default AdComponent.extend({
|
|||
}
|
||||
|
||||
return this.isNthPost(parseInt(this.siteSettings.amazon_nth_post_code, 10));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -32,5 +32,5 @@ export default AdComponent.extend({
|
|||
showToGroups &&
|
||||
showOnCurrentPage
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -49,7 +49,7 @@ function loadAdsense() {
|
|||
const adsenseSrc =
|
||||
("https:" === document.location.protocol ? "https:" : "http:") +
|
||||
"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js";
|
||||
_promise = loadScript(adsenseSrc, { scriptTag: true }).then(function() {
|
||||
_promise = loadScript(adsenseSrc, { scriptTag: true }).then(function () {
|
||||
_loaded = true;
|
||||
});
|
||||
|
||||
|
@ -59,46 +59,46 @@ function loadAdsense() {
|
|||
const DESKTOP_SETTINGS = {
|
||||
"topic-list-top": {
|
||||
code: "adsense_topic_list_top_code",
|
||||
sizes: "adsense_topic_list_top_ad_sizes"
|
||||
sizes: "adsense_topic_list_top_ad_sizes",
|
||||
},
|
||||
"topic-above-post-stream": {
|
||||
code: "adsense_topic_above_post_stream_code",
|
||||
sizes: "adsense_topic_above_post_stream_ad_sizes"
|
||||
sizes: "adsense_topic_above_post_stream_ad_sizes",
|
||||
},
|
||||
"topic-above-suggested": {
|
||||
code: "adsense_topic_above_suggested_code",
|
||||
sizes: "adsense_topic_above_suggested_ad_sizes"
|
||||
sizes: "adsense_topic_above_suggested_ad_sizes",
|
||||
},
|
||||
"post-bottom": {
|
||||
code: "adsense_post_bottom_code",
|
||||
sizes: "adsense_post_bottom_ad_sizes"
|
||||
}
|
||||
sizes: "adsense_post_bottom_ad_sizes",
|
||||
},
|
||||
};
|
||||
|
||||
const MOBILE_SETTINGS = {
|
||||
"topic-list-top": {
|
||||
code: "adsense_mobile_topic_list_top_code",
|
||||
sizes: "adsense_mobile_topic_list_top_ad_size"
|
||||
sizes: "adsense_mobile_topic_list_top_ad_size",
|
||||
},
|
||||
"topic-above-post-stream": {
|
||||
code: "adsense_mobile_topic_above_post_stream_code",
|
||||
sizes: "adsense_mobile_topic_above_post_stream_ad_size"
|
||||
sizes: "adsense_mobile_topic_above_post_stream_ad_size",
|
||||
},
|
||||
"topic-above-suggested": {
|
||||
code: "adsense_mobile_topic_above_suggested_code",
|
||||
sizes: "adsense_mobile_topic_above_suggested_ad_size"
|
||||
sizes: "adsense_mobile_topic_above_suggested_ad_size",
|
||||
},
|
||||
"post-bottom": {
|
||||
code: "adsense_mobile_post_bottom_code",
|
||||
sizes: "adsense_mobile_post_bottom_ad_size"
|
||||
}
|
||||
sizes: "adsense_mobile_post_bottom_ad_size",
|
||||
},
|
||||
};
|
||||
|
||||
export default AdComponent.extend({
|
||||
classNameBindings: [
|
||||
":google-adsense",
|
||||
"classForSlot",
|
||||
"isResponsive:adsense-responsive"
|
||||
"isResponsive:adsense-responsive",
|
||||
],
|
||||
loadedGoogletag: false,
|
||||
|
||||
|
@ -143,7 +143,7 @@ export default AdComponent.extend({
|
|||
}
|
||||
|
||||
this.set("adRequested", true);
|
||||
loadAdsense().then(function() {
|
||||
loadAdsense().then(function () {
|
||||
const adsbygoogle = window.adsbygoogle || [];
|
||||
|
||||
try {
|
||||
|
@ -244,5 +244,5 @@ export default AdComponent.extend({
|
|||
return this.isNthPost(
|
||||
parseInt(this.siteSettings.adsense_nth_post_code, 10)
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -52,26 +52,26 @@ const DESKTOP_SETTINGS = {
|
|||
code: "dfp_topic_list_top_code",
|
||||
sizes: "dfp_topic_list_top_ad_sizes",
|
||||
targeting_keys: "dfp_target_topic_list_top_key_code",
|
||||
targeting_values: "dfp_target_topic_list_top_value_code"
|
||||
targeting_values: "dfp_target_topic_list_top_value_code",
|
||||
},
|
||||
"topic-above-post-stream": {
|
||||
code: "dfp_topic_above_post_stream_code",
|
||||
sizes: "dfp_topic_above_post_stream_ad_sizes",
|
||||
targeting_keys: "dfp_target_topic_above_post_stream_key_code",
|
||||
targeting_values: "dfp_target_topic_above_post_stream_value_code"
|
||||
targeting_values: "dfp_target_topic_above_post_stream_value_code",
|
||||
},
|
||||
"topic-above-suggested": {
|
||||
code: "dfp_topic_above_suggested_code",
|
||||
sizes: "dfp_topic_above_suggested_ad_sizes",
|
||||
targeting_keys: "dfp_target_topic_above_suggested_key_code",
|
||||
targeting_values: "dfp_target_topic_above_suggested_value_code"
|
||||
targeting_values: "dfp_target_topic_above_suggested_value_code",
|
||||
},
|
||||
"post-bottom": {
|
||||
code: "dfp_post_bottom_code",
|
||||
sizes: "dfp_post_bottom_ad_sizes",
|
||||
targeting_keys: "dfp_target_post_bottom_key_code",
|
||||
targeting_values: "dfp_target_post_bottom_value_code"
|
||||
}
|
||||
targeting_values: "dfp_target_post_bottom_value_code",
|
||||
},
|
||||
};
|
||||
|
||||
const MOBILE_SETTINGS = {
|
||||
|
@ -79,26 +79,26 @@ const MOBILE_SETTINGS = {
|
|||
code: "dfp_mobile_topic_list_top_code",
|
||||
sizes: "dfp_mobile_topic_list_top_ad_sizes",
|
||||
targeting_keys: "dfp_target_topic_list_top_key_code",
|
||||
targeting_values: "dfp_target_topic_list_top_value_code"
|
||||
targeting_values: "dfp_target_topic_list_top_value_code",
|
||||
},
|
||||
"topic-above-post-stream": {
|
||||
code: "dfp_mobile_topic_above_post_stream_code",
|
||||
sizes: "dfp_mobile_topic_above_post_stream_ad_sizes",
|
||||
targeting_keys: "dfp_target_topic_above_post_stream_key_code",
|
||||
targeting_values: "dfp_target_topic_above_post_stream_value_code"
|
||||
targeting_values: "dfp_target_topic_above_post_stream_value_code",
|
||||
},
|
||||
"topic-above-suggested": {
|
||||
code: "dfp_mobile_topic_above_suggested_code",
|
||||
sizes: "dfp_mobile_topic_above_suggested_ad_sizes",
|
||||
targeting_keys: "dfp_target_topic_above_suggested_key_code",
|
||||
targeting_values: "dfp_target_topic_above_suggested_value_code"
|
||||
targeting_values: "dfp_target_topic_above_suggested_value_code",
|
||||
},
|
||||
"post-bottom": {
|
||||
code: "dfp_mobile_post_bottom_code",
|
||||
sizes: "dfp_mobile_post_bottom_ad_sizes",
|
||||
targeting_keys: "dfp_target_post_bottom_key_code",
|
||||
targeting_values: "dfp_target_post_bottom_value_code"
|
||||
}
|
||||
targeting_values: "dfp_target_post_bottom_value_code",
|
||||
},
|
||||
};
|
||||
|
||||
function getWidthAndHeight(placement, settings, isMobile) {
|
||||
|
@ -129,7 +129,7 @@ function getWidthAndHeight(placement, settings, isMobile) {
|
|||
|
||||
const sizeObj = {
|
||||
width: parseInt(splitWidthInt(size), 10),
|
||||
height: parseInt(splitHeightInt(size), 10)
|
||||
height: parseInt(splitHeightInt(size), 10),
|
||||
};
|
||||
|
||||
if (!isNaN(sizeObj.width) && !isNaN(sizeObj.height)) {
|
||||
|
@ -211,14 +211,14 @@ function loadGoogle() {
|
|||
var dfpSrc =
|
||||
("https:" === document.location.protocol ? "https:" : "http:") +
|
||||
"//securepubads.g.doubleclick.net/tag/js/gpt.js";
|
||||
_promise = loadScript(dfpSrc, { scriptTag: true }).then(function() {
|
||||
_promise = loadScript(dfpSrc, { scriptTag: true }).then(function () {
|
||||
_loaded = true;
|
||||
if (window.googletag === undefined) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log("googletag is undefined!");
|
||||
}
|
||||
|
||||
window.googletag.cmd.push(function() {
|
||||
window.googletag.cmd.push(function () {
|
||||
// Infinite scroll requires SRA:
|
||||
window.googletag.pubads().enableSingleRequest();
|
||||
|
||||
|
@ -415,5 +415,5 @@ export default AdComponent.extend({
|
|||
@on("willDestroyElement")
|
||||
cleanup() {
|
||||
destroySlot(this.get("divId"));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ const adIndex = {
|
|||
topic_list_top: null,
|
||||
topic_above_post_stream: null,
|
||||
topic_above_suggested: null,
|
||||
post_bottom: null
|
||||
post_bottom: null,
|
||||
};
|
||||
|
||||
export default AdComponent.extend({
|
||||
|
@ -92,12 +92,12 @@ export default AdComponent.extend({
|
|||
|
||||
if (adIndex.topic_list_top === null) {
|
||||
// start at a random spot in the ad inventory
|
||||
Object.keys(adIndex).forEach(placement => {
|
||||
Object.keys(adIndex).forEach((placement) => {
|
||||
const adNames = this.adsNamesForSlot(placement);
|
||||
adIndex[placement] = Math.floor(Math.random() * adNames.length);
|
||||
});
|
||||
}
|
||||
|
||||
this.refreshAd();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@ export default MultiSelectComponent.extend({
|
|||
valueAttribute: null,
|
||||
nameProperty: null,
|
||||
|
||||
value: computed("settingValue", function() {
|
||||
value: computed("settingValue", function () {
|
||||
return this.settingValue
|
||||
.toString()
|
||||
.split(this.tokenSeparator)
|
||||
|
@ -28,7 +28,7 @@ export default MultiSelectComponent.extend({
|
|||
return this.settingValue.split(this.tokenSeparator).filter(Boolean);
|
||||
},
|
||||
|
||||
content: computed("choices", function() {
|
||||
content: computed("choices", function () {
|
||||
return makeArray(this.choices);
|
||||
}),
|
||||
|
||||
|
@ -36,6 +36,6 @@ export default MultiSelectComponent.extend({
|
|||
onChange(value) {
|
||||
const settingValue = makeArray(value).join(this.tokenSeparator);
|
||||
this.attrs.onChange && this.attrs.onChange(settingValue);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -2,5 +2,5 @@ import HouseAdsSetting from "discourse/plugins/discourse-adplugin/discourse/comp
|
|||
|
||||
export default HouseAdsSetting.extend({
|
||||
classNames: "house-ads-setting house-ads-list-setting",
|
||||
adNames: Ember.computed.mapBy("allAds", "name")
|
||||
adNames: Ember.computed.mapBy("allAds", "name"),
|
||||
});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { ajax } from "discourse/lib/ajax";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { i18n, propertyNotEqual } from "discourse/lib/computed";
|
||||
import I18n from "I18n";
|
||||
|
||||
export default Ember.Component.extend({
|
||||
classNames: "house-ads-setting",
|
||||
|
@ -21,14 +22,14 @@ export default Ember.Component.extend({
|
|||
if (!this.get("saving")) {
|
||||
this.setProperties({
|
||||
saving: true,
|
||||
savingStatus: I18n.t("saving")
|
||||
savingStatus: I18n.t("saving"),
|
||||
});
|
||||
|
||||
ajax(
|
||||
`/admin/plugins/pluginad/house_settings/${this.get("name")}.json`,
|
||||
{
|
||||
type: "PUT",
|
||||
data: { value: this.get("adValue") }
|
||||
data: { value: this.get("adValue") },
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
|
@ -36,14 +37,14 @@ export default Ember.Component.extend({
|
|||
adSettings.set(this.get("name"), this.get("adValue"));
|
||||
this.setProperties({
|
||||
value: this.get("adValue"),
|
||||
savingStatus: I18n.t("saved")
|
||||
savingStatus: I18n.t("saved"),
|
||||
});
|
||||
})
|
||||
.catch(popupAjaxError)
|
||||
.finally(() => {
|
||||
this.setProperties({
|
||||
saving: false,
|
||||
savingStatus: ""
|
||||
savingStatus: "",
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -51,6 +52,6 @@ export default Ember.Component.extend({
|
|||
|
||||
cancel() {
|
||||
this.set("adValue", this.get("value"));
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export default Ember.Controller.extend({
|
||||
adminPluginsHouseAds: Ember.inject.controller("adminPlugins.houseAds"),
|
||||
houseAds: Ember.computed.alias("adminPluginsHouseAds.model"),
|
||||
adSettings: Ember.computed.alias("adminPluginsHouseAds.houseAdsSettings")
|
||||
adSettings: Ember.computed.alias("adminPluginsHouseAds.houseAdsSettings"),
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import I18n from "I18n";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { propertyNotEqual } from "discourse/lib/computed";
|
||||
|
@ -19,7 +20,7 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
|
|||
if (!this.get("saving")) {
|
||||
this.setProperties({
|
||||
saving: true,
|
||||
savingStatus: I18n.t("saving")
|
||||
savingStatus: I18n.t("saving"),
|
||||
});
|
||||
|
||||
const data = {},
|
||||
|
@ -38,10 +39,10 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
|
|||
: `/admin/plugins/pluginad/house_creatives/${buffered.get("id")}`,
|
||||
{
|
||||
type: newRecord ? "POST" : "PUT",
|
||||
data
|
||||
data,
|
||||
}
|
||||
)
|
||||
.then(ajaxData => {
|
||||
.then((ajaxData) => {
|
||||
this.commitBuffer();
|
||||
this.set("savingStatus", I18n.t("saved"));
|
||||
if (newRecord) {
|
||||
|
@ -61,7 +62,7 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
|
|||
.finally(() => {
|
||||
this.setProperties({
|
||||
saving: false,
|
||||
savingStatus: ""
|
||||
savingStatus: "",
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -81,13 +82,13 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
|
|||
}
|
||||
|
||||
ajax(`/admin/plugins/pluginad/house_creatives/${model.get("id")}`, {
|
||||
type: "DELETE"
|
||||
type: "DELETE",
|
||||
})
|
||||
.then(() => {
|
||||
houseAds.removeObject(model);
|
||||
this.transitionToRoute("adminPlugins.houseAds.index");
|
||||
})
|
||||
.catch(() => bootbox.alert(I18n.t("generic_error")));
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export default Ember.Controller.extend({
|
||||
loadingAds: true
|
||||
loadingAds: true,
|
||||
});
|
||||
|
|
|
@ -4,6 +4,6 @@ export default DiscourseRoute.extend({
|
|||
actions: {
|
||||
moreSettings() {
|
||||
this.transitionTo("adminSiteSettingsCategory", "ad_plugin");
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import I18n from "I18n";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
model(params) {
|
||||
if (params.ad_id === "new") {
|
||||
return Ember.Object.create({
|
||||
name: I18n.t("admin.adplugin.house_ads.new_name"),
|
||||
html: ""
|
||||
html: "",
|
||||
});
|
||||
} else {
|
||||
return this.modelFor("adminPlugins.houseAds").findBy(
|
||||
|
@ -13,5 +14,5 @@ export default DiscourseRoute.extend({
|
|||
parseInt(params.ad_id, 10)
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -5,9 +5,9 @@ export default DiscourseRoute.extend({
|
|||
settings: null,
|
||||
|
||||
model() {
|
||||
return ajax("/admin/plugins/pluginad/house_creatives.json").then(data => {
|
||||
return ajax("/admin/plugins/pluginad/house_creatives.json").then((data) => {
|
||||
this.set("settings", Ember.Object.create(data.settings));
|
||||
return data.house_ads.map(ad => Ember.Object.create(ad));
|
||||
return data.house_ads.map((ad) => Ember.Object.create(ad));
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -15,7 +15,7 @@ export default DiscourseRoute.extend({
|
|||
controller.setProperties({
|
||||
model,
|
||||
houseAdsSettings: this.get("settings"),
|
||||
loadingAds: false
|
||||
loadingAds: false,
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
{{#d-section class="house-ads-settings content-body"}}
|
||||
<div>{{i18n 'admin.adplugin.house_ads.description'}}</div>
|
||||
<div>{{i18n "admin.adplugin.house_ads.description"}}</div>
|
||||
|
||||
{{#unless houseAds.length}}
|
||||
<p>
|
||||
{{#link-to 'adminPlugins.houseAds.show' 'new'}}
|
||||
{{i18n 'admin.adplugin.house_ads.get_started'}}
|
||||
{{/link-to}}
|
||||
</p>
|
||||
{{else}}
|
||||
{{#if houseAds.length}}
|
||||
<form class="form-horizontal">
|
||||
{{house-ads-list-setting name="topic_list_top" value=adSettings.topic_list_top allAds=houseAds adSettings=adSettings}}
|
||||
{{house-ads-list-setting name="topic_above_post_stream" value=adSettings.topic_above_post_stream allAds=houseAds adSettings=adSettings}}
|
||||
|
@ -17,7 +11,14 @@
|
|||
{{d-button label="admin.adplugin.house_ads.more_settings"
|
||||
icon="cog"
|
||||
class="btn-default"
|
||||
action=(route-action "moreSettings")}}
|
||||
action=(route-action "moreSettings")
|
||||
}}
|
||||
</form>
|
||||
{{/unless}}
|
||||
{{else}}
|
||||
<p>
|
||||
{{#link-to "adminPlugins.houseAds.show" "new"}}
|
||||
{{i18n "admin.adplugin.house_ads.get_started"}}
|
||||
{{/link-to}}
|
||||
</p>
|
||||
{{/if}}
|
||||
{{/d-section}}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
{{savingStatus}}
|
||||
{{else}}
|
||||
{{#if dirty}}
|
||||
<a href {{action "cancel"}}>{{i18n 'cancel'}}</a>
|
||||
<a href {{action "cancel"}}>{{i18n "cancel"}}</a>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
<div class="adplugin-mgmt">
|
||||
<h1>{{i18n 'admin.adplugin.house_ads.title'}}</h1>
|
||||
<h1>{{i18n "admin.adplugin.house_ads.title"}}</h1>
|
||||
{{#if model.length}}
|
||||
<div class="content-list">
|
||||
<div class="house-ads-actions">
|
||||
{{#link-to 'adminPlugins.houseAds.show' 'new' class="btn btn-primary"}}
|
||||
{{#link-to "adminPlugins.houseAds.show" "new" class="btn btn-primary"}}
|
||||
{{d-icon "plus"}}
|
||||
<span>{{i18n 'admin.adplugin.house_ads.new'}}</span>
|
||||
<span>{{i18n "admin.adplugin.house_ads.new"}}</span>
|
||||
{{/link-to}}
|
||||
{{#link-to 'adminPlugins.houseAds.index' class="btn btn-default"}}
|
||||
{{#link-to "adminPlugins.houseAds.index" class="btn btn-default"}}
|
||||
{{d-icon "cog"}}
|
||||
<span>{{i18n 'admin.adplugin.house_ads.settings'}}</span>
|
||||
<span>{{i18n "admin.adplugin.house_ads.settings"}}</span>
|
||||
{{/link-to}}
|
||||
</div>
|
||||
<ul class="house-ads-list">
|
||||
{{#each model as |ad|}}
|
||||
<li class="house-ads-list-item">
|
||||
{{#link-to 'adminPlugins.houseAds.show' ad.id}}
|
||||
{{#link-to "adminPlugins.houseAds.show" ad.id}}
|
||||
{{ad.name}}
|
||||
{{/link-to}}
|
||||
</li>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{{#if showAd}}
|
||||
<div id={{divId}} class={{className}}></div>
|
||||
<div id={{divId}} class={{className}}></div>
|
||||
{{/if}}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
{{#if showAd}}
|
||||
{{#if site.mobileView}}
|
||||
<div class="amazon-product-links-label" style={{adTitleStyleMobile}}><h2>{{i18n 'adplugin.advertisement_label'}}</h2></div>
|
||||
<iframe style={{adWrapperStyleMobile}} marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src={{userInputMobile}}>
|
||||
</iframe>
|
||||
{{else}}
|
||||
<div class="amazon-product-links-label"><h2>{{i18n 'adplugin.advertisement_label'}}</h2></div>
|
||||
<div class="container" align="center">
|
||||
<iframe style={{adWrapperStyle}} marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src={{userInput}}>
|
||||
</iframe>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if site.mobileView}}
|
||||
<div class="amazon-product-links-label" style={{adTitleStyleMobile}}><h2>{{i18n "adplugin.advertisement_label"}}</h2></div>
|
||||
<iframe style={{adWrapperStyleMobile}} marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src={{userInputMobile}}>
|
||||
</iframe>
|
||||
{{else}}
|
||||
<div class="amazon-product-links-label"><h2>{{i18n "adplugin.advertisement_label"}}</h2></div>
|
||||
<div class="container" align="center">
|
||||
<iframe style={{adWrapperStyle}} marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src={{userInput}}>
|
||||
</iframe>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{{#if showAd}}
|
||||
<div class="google-adsense-label"><h2>{{i18n 'adplugin.advertisement_label'}}</h2></div>
|
||||
<div class="google-adsense-label"><h2>{{i18n "adplugin.advertisement_label"}}</h2></div>
|
||||
<div class="google-adsense-content" style={{adWrapperStyle}}>
|
||||
<ins class="adsbygoogle"
|
||||
style={{adInsStyle}}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{{#if showAd}}
|
||||
{{#if site.mobileView}}
|
||||
<div class="google-dfp-ad-label" style={{adTitleStyleMobile}}><h2>{{i18n 'adplugin.advertisement_label'}}</h2></div>
|
||||
<div id={{divId}} style={{adWrapperStyle}} class="dfp-ad-unit" align=center></div>
|
||||
<div class="google-dfp-ad-label" style={{adTitleStyleMobile}}><h2>{{i18n "adplugin.advertisement_label"}}</h2></div>
|
||||
<div id={{divId}} style={{adWrapperStyle}} class="dfp-ad-unit" align="center"></div>
|
||||
{{else}}
|
||||
<div class="google-dfp-ad-label"><h2>{{i18n 'adplugin.advertisement_label'}}</h2></div>
|
||||
<div id={{divId}} style={{adWrapperStyle}} class="dfp-ad-unit" align=center></div>
|
||||
<div class="google-dfp-ad-label"><h2>{{i18n "adplugin.advertisement_label"}}</h2></div>
|
||||
<div id={{divId}} style={{adWrapperStyle}} class="dfp-ad-unit" align="center"></div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<label for="{{name}}">{{title}}</label>
|
||||
<label for={{name}}>{{title}}</label>
|
||||
{{house-ads-chooser
|
||||
settingValue=adValue
|
||||
choices=adNames
|
||||
onChange=(action (mut adValue))
|
||||
}}
|
||||
<div class='setting-controls'>
|
||||
<div class="setting-controls">
|
||||
{{#if changed}}
|
||||
{{d-button class="ok" action=(action "save") icon="check"}}
|
||||
{{d-button class="cancel" action=(action "cancel") icon="times"}}
|
||||
{{/if}}
|
||||
</div>
|
||||
<p class='help'>{{help}}</p>
|
||||
<p class="help">{{help}}</p>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<label for="{{name}}">{{title}}</label>
|
||||
<label for={{name}}>{{title}}</label>
|
||||
{{text-field value=adValue classNames="house-ads-text-input"}}
|
||||
<div class='setting-controls'>
|
||||
<div class="setting-controls">
|
||||
{{#if changed}}
|
||||
{{d-button class="ok" action=(action "save") icon="check"}}
|
||||
{{d-button class="cancel" action=(action "cancel") icon="times"}}
|
||||
{{/if}}
|
||||
</div>
|
||||
<p class='help'>{{help}}</p>
|
||||
<p class="help">{{help}}</p>
|
||||
|
|
|
@ -3,20 +3,20 @@ import { withPluginApi } from "discourse/lib/plugin-api";
|
|||
export default {
|
||||
name: "initialize-ad-plugin",
|
||||
initialize(container) {
|
||||
withPluginApi("0.1", api => {
|
||||
api.decorateWidget("post:after", dec => {
|
||||
withPluginApi("0.1", (api) => {
|
||||
api.decorateWidget("post:after", (dec) => {
|
||||
if (dec.canConnectComponent) {
|
||||
if (!dec.attrs.cloaked) {
|
||||
return dec.connect({
|
||||
component: "post-bottom-ad",
|
||||
context: "model"
|
||||
context: "model",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Old way for backwards compatibility
|
||||
return dec.connect({
|
||||
templateName: "connectors/post-bottom/discourse-adplugin",
|
||||
context: "model"
|
||||
context: "model",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -27,8 +27,8 @@ export default {
|
|||
return;
|
||||
}
|
||||
|
||||
messageBus.subscribe("/site/house-creatives", function(houseAdsSettings) {
|
||||
messageBus.subscribe("/site/house-creatives", function (houseAdsSettings) {
|
||||
Discourse.Site.currentProp("house_creatives", houseAdsSettings);
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
"author": "Discourse",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"eslint-config-discourse": "1.1.0"
|
||||
"eslint-config-discourse": "latest"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ acceptance("AdSense", {
|
|||
adsense_mobile_post_bottom_ad_size: "300*250 - medium rectangle",
|
||||
adsense_nth_post_code: 6,
|
||||
adsense_topic_above_post_stream_code: "above_post_stream_ad_unit",
|
||||
adsense_topic_above_post_stream_ad_sizes: "728*90 - leaderboard"
|
||||
adsense_topic_above_post_stream_ad_sizes: "728*90 - leaderboard",
|
||||
},
|
||||
site: {
|
||||
house_creatives: {
|
||||
|
@ -27,14 +27,14 @@ acceptance("AdSense", {
|
|||
topic_above_post_stream: "",
|
||||
topic_above_suggested: "",
|
||||
post_bottom: "",
|
||||
after_nth_post: 20
|
||||
after_nth_post: 20,
|
||||
},
|
||||
creatives: {}
|
||||
}
|
||||
}
|
||||
creatives: {},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
test("correct number of ads should show", async assert => {
|
||||
test("correct number of ads should show", async (assert) => {
|
||||
updateCurrentUser({ staff: false, trust_level: 1 });
|
||||
await visit("/t/280"); // 20 posts
|
||||
|
||||
|
@ -69,7 +69,7 @@ test("correct number of ads should show", async assert => {
|
|||
);
|
||||
});
|
||||
|
||||
test("no ads for trust level 3", async assert => {
|
||||
test("no ads for trust level 3", async (assert) => {
|
||||
updateCurrentUser({ staff: false, trust_level: 3 });
|
||||
await visit("/t/280");
|
||||
assert.equal(
|
||||
|
@ -79,11 +79,11 @@ test("no ads for trust level 3", async assert => {
|
|||
);
|
||||
});
|
||||
|
||||
test("can omit ads based on groups", async assert => {
|
||||
test("can omit ads based on groups", async (assert) => {
|
||||
updateCurrentUser({
|
||||
staff: false,
|
||||
trust_level: 1,
|
||||
groups: [groupFixtures["/groups/discourse.json"].group]
|
||||
groups: [groupFixtures["/groups/discourse.json"].group],
|
||||
});
|
||||
await visit("/t/280");
|
||||
assert.equal(
|
||||
|
@ -93,7 +93,7 @@ test("can omit ads based on groups", async assert => {
|
|||
);
|
||||
});
|
||||
|
||||
test("can omit ads based on category", async assert => {
|
||||
test("can omit ads based on category", async (assert) => {
|
||||
updateCurrentUser({ staff: false, trust_level: 1 });
|
||||
await visit("/t/28830");
|
||||
assert.equal(
|
||||
|
|
|
@ -18,7 +18,7 @@ acceptance("DFP Ads", {
|
|||
dfp_mobile_post_bottom_ad_size: "300*250 - medium rectangle",
|
||||
dfp_nth_post_code: 6,
|
||||
dfp_topic_above_post_stream_code: "list_top_ad_unit",
|
||||
dfp_topic_above_post_stream_ad_sizes: "728*90 - leaderboard"
|
||||
dfp_topic_above_post_stream_ad_sizes: "728*90 - leaderboard",
|
||||
},
|
||||
site: {
|
||||
house_creatives: {
|
||||
|
@ -27,14 +27,14 @@ acceptance("DFP Ads", {
|
|||
topic_above_post_stream: "",
|
||||
topic_above_suggested: "",
|
||||
post_bottom: "",
|
||||
after_nth_post: 20
|
||||
after_nth_post: 20,
|
||||
},
|
||||
creatives: {}
|
||||
}
|
||||
}
|
||||
creatives: {},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
test("correct number of ads should show", async assert => {
|
||||
test("correct number of ads should show", async (assert) => {
|
||||
updateCurrentUser({ staff: false, trust_level: 1 });
|
||||
await visit("/t/280"); // 20 posts
|
||||
const ads = find(".google-dfp-ad.dfp-ad-post-bottom");
|
||||
|
@ -62,7 +62,7 @@ test("correct number of ads should show", async assert => {
|
|||
);
|
||||
});
|
||||
|
||||
test("no ads for trust level 3", async assert => {
|
||||
test("no ads for trust level 3", async (assert) => {
|
||||
updateCurrentUser({ staff: false, trust_level: 3 });
|
||||
await visit("/t/280");
|
||||
assert.equal(
|
||||
|
@ -72,11 +72,11 @@ test("no ads for trust level 3", async assert => {
|
|||
);
|
||||
});
|
||||
|
||||
test("can omit ads based on groups", async assert => {
|
||||
test("can omit ads based on groups", async (assert) => {
|
||||
updateCurrentUser({
|
||||
staff: false,
|
||||
trust_level: 1,
|
||||
groups: [groupFixtures["/groups/discourse.json"].group]
|
||||
groups: [groupFixtures["/groups/discourse.json"].group],
|
||||
});
|
||||
await visit("/t/280");
|
||||
assert.equal(
|
||||
|
@ -86,7 +86,7 @@ test("can omit ads based on groups", async assert => {
|
|||
);
|
||||
});
|
||||
|
||||
test("can omit ads based on category", async assert => {
|
||||
test("can omit ads based on category", async (assert) => {
|
||||
updateCurrentUser({ staff: false, trust_level: 1 });
|
||||
await visit("/t/28830");
|
||||
assert.equal(
|
||||
|
|
|
@ -4,7 +4,7 @@ acceptance("House Ads", {
|
|||
loggedIn: true,
|
||||
settings: {
|
||||
no_ads_for_categories: "1",
|
||||
house_ads_after_nth_post: 6
|
||||
house_ads_after_nth_post: 6,
|
||||
},
|
||||
site: {
|
||||
house_creatives: {
|
||||
|
@ -13,7 +13,7 @@ acceptance("House Ads", {
|
|||
topic_above_post_stream: "Above Post Stream",
|
||||
topic_above_suggested: "Above Suggested",
|
||||
post_bottom: "Post",
|
||||
after_nth_post: 6
|
||||
after_nth_post: 6,
|
||||
},
|
||||
creatives: {
|
||||
"Topic List": "<div class='h-topic-list'>TOPIC LIST</div>",
|
||||
|
@ -21,13 +21,13 @@ acceptance("House Ads", {
|
|||
"<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>"
|
||||
}
|
||||
}
|
||||
}
|
||||
Post: "<div class='h-post'>BELOW POST</div>",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
test("correct ads show", async assert => {
|
||||
test("correct ads show", async (assert) => {
|
||||
updateCurrentUser({ staff: false, trust_level: 1 });
|
||||
await visit("/t/280"); // 20 posts
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ acceptance("Mixed Ads", {
|
|||
dfp_post_bottom_ad_sizes: "728*90 - leaderboard",
|
||||
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
|
||||
dfp_nth_post_code: 6,
|
||||
},
|
||||
site: {
|
||||
house_creatives: {
|
||||
|
@ -24,7 +24,7 @@ acceptance("Mixed Ads", {
|
|||
topic_above_post_stream: "Above Post Stream",
|
||||
topic_above_suggested: "Above Suggested",
|
||||
post_bottom: "Post",
|
||||
after_nth_post: 6
|
||||
after_nth_post: 6,
|
||||
},
|
||||
creatives: {
|
||||
"Topic List": "<div class='h-topic-list'>TOPIC LIST</div>",
|
||||
|
@ -32,13 +32,13 @@ acceptance("Mixed Ads", {
|
|||
"<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>"
|
||||
}
|
||||
}
|
||||
}
|
||||
Post: "<div class='h-post'>BELOW POST</div>",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
test("correct ads show", async assert => {
|
||||
test("correct ads show", async (assert) => {
|
||||
updateCurrentUser({ staff: false, trust_level: 1 });
|
||||
await visit("/t/280"); // 20 posts
|
||||
|
||||
|
|
Loading…
Reference in New Issue