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