mirror of
https://github.com/discourse/discourse-adplugin.git
synced 2025-07-05 21:02:34 +00:00
REFACTOR: applies discourse core coding practices (#82)
This commit is contained in:
parent
cd82a905ae
commit
270799166b
104
.eslintrc
104
.eslintrc
@ -1,105 +1,3 @@
|
|||||||
{
|
{
|
||||||
"env": {
|
"extends": "eslint-config-discourse"
|
||||||
"jasmine": true,
|
|
||||||
"node": true,
|
|
||||||
"mocha": true,
|
|
||||||
"browser": true,
|
|
||||||
"builtin": true
|
|
||||||
},
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 7,
|
|
||||||
"sourceType": "module"
|
|
||||||
},
|
|
||||||
"globals":
|
|
||||||
{"Ember":true,
|
|
||||||
"jQuery":true,
|
|
||||||
"$":true,
|
|
||||||
"RSVP":true,
|
|
||||||
"Discourse":true,
|
|
||||||
"Em":true,
|
|
||||||
"PreloadStore":true,
|
|
||||||
"Handlebars":true,
|
|
||||||
"I18n":true,
|
|
||||||
"bootbox":true,
|
|
||||||
"module":true,
|
|
||||||
"moduleFor":true,
|
|
||||||
"moduleForComponent":true,
|
|
||||||
"Pretender":true,
|
|
||||||
"sandbox":true,
|
|
||||||
"controllerFor":true,
|
|
||||||
"test":true,
|
|
||||||
"ok":true,
|
|
||||||
"not":true,
|
|
||||||
"expect":true,
|
|
||||||
"equal":true,
|
|
||||||
"visit":true,
|
|
||||||
"andThen":true,
|
|
||||||
"click":true,
|
|
||||||
"currentPath":true,
|
|
||||||
"currentRouteName":true,
|
|
||||||
"currentURL":true,
|
|
||||||
"fillIn":true,
|
|
||||||
"keyEvent":true,
|
|
||||||
"triggerEvent":true,
|
|
||||||
"count":true,
|
|
||||||
"exists":true,
|
|
||||||
"visible":true,
|
|
||||||
"invisible":true,
|
|
||||||
"asyncRender":true,
|
|
||||||
"selectDropdown":true,
|
|
||||||
"asyncTestDiscourse":true,
|
|
||||||
"fixture":true,
|
|
||||||
"find":true,
|
|
||||||
"sinon":true,
|
|
||||||
"moment":true,
|
|
||||||
"start":true,
|
|
||||||
"_":true,
|
|
||||||
"alert":true,
|
|
||||||
"containsInstance":true,
|
|
||||||
"deepEqual":true,
|
|
||||||
"notEqual":true,
|
|
||||||
"define":true,
|
|
||||||
"require":true,
|
|
||||||
"requirejs":true,
|
|
||||||
"hasModule":true,
|
|
||||||
"Blob":true,
|
|
||||||
"File":true},
|
|
||||||
"rules": {
|
|
||||||
"block-scoped-var": 2,
|
|
||||||
"dot-notation": 0,
|
|
||||||
"eqeqeq": [
|
|
||||||
2,
|
|
||||||
"allow-null"
|
|
||||||
],
|
|
||||||
"guard-for-in": 2,
|
|
||||||
"no-bitwise": 2,
|
|
||||||
"no-caller": 2,
|
|
||||||
"no-cond-assign": 0,
|
|
||||||
"no-debugger": 2,
|
|
||||||
"no-empty": 0,
|
|
||||||
"no-eval": 2,
|
|
||||||
"no-extend-native": 2,
|
|
||||||
"no-extra-parens": 0,
|
|
||||||
"no-irregular-whitespace": 2,
|
|
||||||
"no-iterator": 2,
|
|
||||||
"no-loop-func": 2,
|
|
||||||
"no-multi-str": 2,
|
|
||||||
"no-new": 2,
|
|
||||||
"no-plusplus": 0,
|
|
||||||
"no-proto": 2,
|
|
||||||
"no-script-url": 2,
|
|
||||||
"no-sequences": 2,
|
|
||||||
"no-shadow": 2,
|
|
||||||
"no-undef": 2,
|
|
||||||
"no-unused-vars": 2,
|
|
||||||
"no-with": 2,
|
|
||||||
"semi": 2,
|
|
||||||
"strict": 0,
|
|
||||||
"valid-typeof": 2,
|
|
||||||
"wrap-iife": [
|
|
||||||
2,
|
|
||||||
"inside"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"parser": "babel-eslint"
|
|
||||||
}
|
}
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@ Gemfile.lock
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
*.swp
|
*.swp
|
||||||
.rubocop-https---raw-githubusercontent-com-discourse-discourse-master--rubocop-yml
|
.rubocop-https---raw-githubusercontent-com-discourse-discourse-master--rubocop-yml
|
||||||
|
node_modules
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import computed from "ember-addons/ember-computed-decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
router: Ember.inject.service(),
|
router: Ember.inject.service(),
|
||||||
@ -23,7 +23,7 @@ export default Ember.Component.extend({
|
|||||||
"router.currentRoute.parent.attributes.category.read_restricted"
|
"router.currentRoute.parent.attributes.category.read_restricted"
|
||||||
),
|
),
|
||||||
|
|
||||||
@computed(
|
@discourseComputed(
|
||||||
"router.currentRoute.attributes.__type",
|
"router.currentRoute.attributes.__type",
|
||||||
"router.currentRoute.attributes.id"
|
"router.currentRoute.attributes.id"
|
||||||
)
|
)
|
||||||
@ -33,12 +33,12 @@ export default Ember.Component.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("router.currentRoute.parent.attributes.archetype")
|
@discourseComputed("router.currentRoute.parent.attributes.archetype")
|
||||||
isPersonalMessage(topicType) {
|
isPersonalMessage(topicType) {
|
||||||
return topicType === "private_message";
|
return topicType === "private_message";
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("currentUser.groups")
|
@discourseComputed("currentUser.groups")
|
||||||
showToGroups(groups) {
|
showToGroups(groups) {
|
||||||
const currentUser = Discourse.User.current();
|
const currentUser = Discourse.User.current();
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ export default Ember.Component.extend({
|
|||||||
return !currentGroups.any(g => noAdsGroups.includes(g));
|
return !currentGroups.any(g => noAdsGroups.includes(g));
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed(
|
@discourseComputed(
|
||||||
"currentCategoryId",
|
"currentCategoryId",
|
||||||
"topicTagsDisableAds",
|
"topicTagsDisableAds",
|
||||||
"topicListTag",
|
"topicListTag",
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
||||||
import {
|
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
||||||
default as computed,
|
|
||||||
observes
|
|
||||||
} from "ember-addons/ember-computed-decorators";
|
|
||||||
|
|
||||||
const adConfig = Ember.Object.create({
|
const adConfig = Ember.Object.create({
|
||||||
"google-adsense": {
|
"google-adsense": {
|
||||||
@ -85,7 +82,7 @@ export default AdComponent.extend({
|
|||||||
* For a given ad placement and optionally a post number if in between posts,
|
* 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.
|
* list all ad network names that are configured to show there.
|
||||||
*/
|
*/
|
||||||
@computed("placement", "postNumber")
|
@discourseComputed("placement", "postNumber")
|
||||||
availableAdTypes(placement, postNumber) {
|
availableAdTypes(placement, postNumber) {
|
||||||
let types = [];
|
let types = [];
|
||||||
const houseAds = this.site.get("house_creatives"),
|
const houseAds = this.site.get("house_creatives"),
|
||||||
@ -167,7 +164,7 @@ export default AdComponent.extend({
|
|||||||
* in the given ad placement. It handles alternating between house ads
|
* in the given ad placement. It handles alternating between house ads
|
||||||
* and other ad networks.
|
* and other ad networks.
|
||||||
*/
|
*/
|
||||||
@computed("placement", "availableAdTypes", "needsUpdate")
|
@discourseComputed("placement", "availableAdTypes", "needsUpdate")
|
||||||
adComponents(placement, availableAdTypes) {
|
adComponents(placement, availableAdTypes) {
|
||||||
if (
|
if (
|
||||||
!availableAdTypes.includes("house-ad") ||
|
!availableAdTypes.includes("house-ad") ||
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
||||||
import {
|
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
||||||
default as computed,
|
|
||||||
observes
|
|
||||||
} from "ember-addons/ember-computed-decorators";
|
|
||||||
import loadScript from "discourse/lib/load-script";
|
import loadScript from "discourse/lib/load-script";
|
||||||
|
|
||||||
const publisherId = Discourse.SiteSettings.adbutler_publisher_id;
|
const publisherId = Discourse.SiteSettings.adbutler_publisher_id;
|
||||||
@ -117,7 +114,7 @@ export default AdComponent.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("currentUser.trust_level")
|
@discourseComputed("currentUser.trust_level")
|
||||||
showToTrustLevel(trustLevel) {
|
showToTrustLevel(trustLevel) {
|
||||||
return !(
|
return !(
|
||||||
trustLevel &&
|
trustLevel &&
|
||||||
@ -125,7 +122,7 @@ export default AdComponent.extend({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed(
|
@discourseComputed(
|
||||||
"showToTrustLevel",
|
"showToTrustLevel",
|
||||||
"showToGroups",
|
"showToGroups",
|
||||||
"showAfterPost",
|
"showAfterPost",
|
||||||
@ -141,7 +138,7 @@ export default AdComponent.extend({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("postNumber")
|
@discourseComputed("postNumber")
|
||||||
showAfterPost(postNumber) {
|
showAfterPost(postNumber) {
|
||||||
if (!postNumber) {
|
if (!postNumber) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
||||||
import computed from "ember-addons/ember-computed-decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
"topic-list-top": {},
|
"topic-list-top": {},
|
||||||
@ -157,32 +157,32 @@ export default AdComponent.extend({
|
|||||||
this._super();
|
this._super();
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("amazon_width", "amazon_height")
|
@discourseComputed("amazon_width", "amazon_height")
|
||||||
adWrapperStyle(w, h) {
|
adWrapperStyle(w, h) {
|
||||||
return `width: ${w}px; height: ${h}px;`.htmlSafe();
|
return `width: ${w}px; height: ${h}px;`.htmlSafe();
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("mobile_amazon_width", "mobile_amazon_height")
|
@discourseComputed("mobile_amazon_width", "mobile_amazon_height")
|
||||||
adWrapperStyleMobile(w, h) {
|
adWrapperStyleMobile(w, h) {
|
||||||
return `width: ${w}px; height: ${h}px;`.htmlSafe();
|
return `width: ${w}px; height: ${h}px;`.htmlSafe();
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("mobile_amazon_width")
|
@discourseComputed("mobile_amazon_width")
|
||||||
adTitleStyleMobile(w) {
|
adTitleStyleMobile(w) {
|
||||||
return `width: ${w}px;`.htmlSafe();
|
return `width: ${w}px;`.htmlSafe();
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("user_input")
|
@discourseComputed("user_input")
|
||||||
userInput(userInput) {
|
userInput(userInput) {
|
||||||
return `${userInput}`.htmlSafe();
|
return `${userInput}`.htmlSafe();
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("user_input_mobile")
|
@discourseComputed("user_input_mobile")
|
||||||
userInputMobile(userInput) {
|
userInputMobile(userInput) {
|
||||||
return `${userInput}`.htmlSafe();
|
return `${userInput}`.htmlSafe();
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("currentUser.trust_level")
|
@discourseComputed("currentUser.trust_level")
|
||||||
showToTrustLevel(trustLevel) {
|
showToTrustLevel(trustLevel) {
|
||||||
return !(
|
return !(
|
||||||
trustLevel &&
|
trustLevel &&
|
||||||
@ -190,7 +190,7 @@ export default AdComponent.extend({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("postNumber")
|
@discourseComputed("postNumber")
|
||||||
showAfterPost(postNumber) {
|
showAfterPost(postNumber) {
|
||||||
if (!postNumber) {
|
if (!postNumber) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
||||||
import { default as computed } from "ember-addons/ember-computed-decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
const serve_id = Discourse.SiteSettings.carbonads_serve_id,
|
const serve_id = Discourse.SiteSettings.carbonads_serve_id,
|
||||||
placement = Discourse.SiteSettings.carbonads_placement;
|
placement = Discourse.SiteSettings.carbonads_placement;
|
||||||
@ -10,12 +10,12 @@ export default AdComponent.extend({
|
|||||||
this._super();
|
this._super();
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("serve_id")
|
@discourseComputed("serve_id")
|
||||||
url(serveId) {
|
url(serveId) {
|
||||||
return `//cdn.carbonads.com/carbon.js?serve=${serveId}&placement=${placement}`.htmlSafe();
|
return `//cdn.carbonads.com/carbon.js?serve=${serveId}&placement=${placement}`.htmlSafe();
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("currentUser.trust_level")
|
@discourseComputed("currentUser.trust_level")
|
||||||
showToTrustLevel(trustLevel) {
|
showToTrustLevel(trustLevel) {
|
||||||
return !(
|
return !(
|
||||||
trustLevel &&
|
trustLevel &&
|
||||||
@ -23,7 +23,7 @@ export default AdComponent.extend({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("showToTrustLevel", "showToGroups", "showOnCurrentPage")
|
@discourseComputed("showToTrustLevel", "showToGroups", "showOnCurrentPage")
|
||||||
showAd(showToTrustLevel, showToGroups, showOnCurrentPage) {
|
showAd(showToTrustLevel, showToGroups, showOnCurrentPage) {
|
||||||
return (
|
return (
|
||||||
placement &&
|
placement &&
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
||||||
import {
|
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
||||||
default as computed,
|
|
||||||
observes
|
|
||||||
} from "ember-addons/ember-computed-decorators";
|
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
|
|
||||||
let _loaded = false,
|
let _loaded = false,
|
||||||
@ -108,14 +105,14 @@ export default AdComponent.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("currentUser.trust_level")
|
@discourseComputed("currentUser.trust_level")
|
||||||
showToTrustLevel(trustLevel) {
|
showToTrustLevel(trustLevel) {
|
||||||
return !(
|
return !(
|
||||||
trustLevel && trustLevel > this.siteSettings.codefund_through_trust_level
|
trustLevel && trustLevel > this.siteSettings.codefund_through_trust_level
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed(
|
@discourseComputed(
|
||||||
"showToTrustLevel",
|
"showToTrustLevel",
|
||||||
"showToGroups",
|
"showToGroups",
|
||||||
"showAfterPost",
|
"showAfterPost",
|
||||||
@ -131,7 +128,7 @@ export default AdComponent.extend({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("postNumber")
|
@discourseComputed("postNumber")
|
||||||
showAfterPost(postNumber) {
|
showAfterPost(postNumber) {
|
||||||
if (!postNumber) {
|
if (!postNumber) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
||||||
import {
|
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
||||||
default as computed,
|
|
||||||
observes
|
|
||||||
} from "ember-addons/ember-computed-decorators";
|
|
||||||
import loadScript from "discourse/lib/load-script";
|
import loadScript from "discourse/lib/load-script";
|
||||||
|
|
||||||
let _loaded = false,
|
let _loaded = false,
|
||||||
@ -173,41 +170,41 @@ export default AdComponent.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("ad_width")
|
@discourseComputed("ad_width")
|
||||||
isResponsive(adWidth) {
|
isResponsive(adWidth) {
|
||||||
return adWidth === "auto";
|
return adWidth === "auto";
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("placement", "showAd")
|
@discourseComputed("placement", "showAd")
|
||||||
classForSlot(placement, showAd) {
|
classForSlot(placement, showAd) {
|
||||||
return showAd ? `adsense-${placement}`.htmlSafe() : "";
|
return showAd ? `adsense-${placement}`.htmlSafe() : "";
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("isResponsive")
|
@discourseComputed("isResponsive")
|
||||||
autoAdFormat(isResponsive) {
|
autoAdFormat(isResponsive) {
|
||||||
return isResponsive ? "auto".htmlSafe() : false;
|
return isResponsive ? "auto".htmlSafe() : false;
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("ad_width", "ad_height", "isResponsive")
|
@discourseComputed("ad_width", "ad_height", "isResponsive")
|
||||||
adWrapperStyle(w, h, isResponsive) {
|
adWrapperStyle(w, h, isResponsive) {
|
||||||
return (isResponsive ? "" : `width: ${w}; height: ${h};`).htmlSafe();
|
return (isResponsive ? "" : `width: ${w}; height: ${h};`).htmlSafe();
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("adWrapperStyle", "isResponsive")
|
@discourseComputed("adWrapperStyle", "isResponsive")
|
||||||
adInsStyle(adWrapperStyle, isResponsive) {
|
adInsStyle(adWrapperStyle, isResponsive) {
|
||||||
return `display: ${
|
return `display: ${
|
||||||
isResponsive ? "block" : "inline-block"
|
isResponsive ? "block" : "inline-block"
|
||||||
}; ${adWrapperStyle}`.htmlSafe();
|
}; ${adWrapperStyle}`.htmlSafe();
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("currentUser.trust_level")
|
@discourseComputed("currentUser.trust_level")
|
||||||
showToTrustLevel(trustLevel) {
|
showToTrustLevel(trustLevel) {
|
||||||
return !(
|
return !(
|
||||||
trustLevel && trustLevel > this.siteSettings.adsense_through_trust_level
|
trustLevel && trustLevel > this.siteSettings.adsense_through_trust_level
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed(
|
@discourseComputed(
|
||||||
"showToTrustLevel",
|
"showToTrustLevel",
|
||||||
"showToGroups",
|
"showToGroups",
|
||||||
"showAfterPost",
|
"showAfterPost",
|
||||||
@ -223,7 +220,7 @@ export default AdComponent.extend({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("postNumber")
|
@discourseComputed("postNumber")
|
||||||
showAfterPost(postNumber) {
|
showAfterPost(postNumber) {
|
||||||
if (!postNumber) {
|
if (!postNumber) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
||||||
import {
|
import discourseComputed, { on } from "discourse-common/utils/decorators";
|
||||||
default as computed,
|
|
||||||
on
|
|
||||||
} from "ember-addons/ember-computed-decorators";
|
|
||||||
import loadScript from "discourse/lib/load-script";
|
import loadScript from "discourse/lib/load-script";
|
||||||
|
|
||||||
let _loaded = false,
|
let _loaded = false,
|
||||||
@ -246,7 +243,7 @@ export default AdComponent.extend({
|
|||||||
width: Ember.computed.alias("size.width"),
|
width: Ember.computed.alias("size.width"),
|
||||||
height: Ember.computed.alias("size.height"),
|
height: Ember.computed.alias("size.height"),
|
||||||
|
|
||||||
@computed()
|
@discourseComputed
|
||||||
size() {
|
size() {
|
||||||
return getWidthAndHeight(
|
return getWidthAndHeight(
|
||||||
this.get("placement"),
|
this.get("placement"),
|
||||||
@ -255,7 +252,7 @@ export default AdComponent.extend({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed(
|
@discourseComputed(
|
||||||
"siteSettings.dfp_publisher_id",
|
"siteSettings.dfp_publisher_id",
|
||||||
"siteSettings.dfp_publisher_id_mobile",
|
"siteSettings.dfp_publisher_id_mobile",
|
||||||
"site.mobileView"
|
"site.mobileView"
|
||||||
@ -268,7 +265,7 @@ export default AdComponent.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("placement", "postNumber")
|
@discourseComputed("placement", "postNumber")
|
||||||
divId(placement, postNumber) {
|
divId(placement, postNumber) {
|
||||||
let slotNum = getNextSlotNum();
|
let slotNum = getNextSlotNum();
|
||||||
if (postNumber) {
|
if (postNumber) {
|
||||||
@ -278,26 +275,26 @@ export default AdComponent.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("placement", "showAd")
|
@discourseComputed("placement", "showAd")
|
||||||
adUnitClass(placement, showAd) {
|
adUnitClass(placement, showAd) {
|
||||||
return showAd ? `dfp-ad-${placement}` : "";
|
return showAd ? `dfp-ad-${placement}` : "";
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("width", "height")
|
@discourseComputed("width", "height")
|
||||||
adWrapperStyle(w, h) {
|
adWrapperStyle(w, h) {
|
||||||
if (w !== "fluid") {
|
if (w !== "fluid") {
|
||||||
return `width: ${w}px; height: ${h}px;`.htmlSafe();
|
return `width: ${w}px; height: ${h}px;`.htmlSafe();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("width")
|
@discourseComputed("width")
|
||||||
adTitleStyleMobile(w) {
|
adTitleStyleMobile(w) {
|
||||||
if (w !== "fluid") {
|
if (w !== "fluid") {
|
||||||
return `width: ${w}px;`.htmlSafe();
|
return `width: ${w}px;`.htmlSafe();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed(
|
@discourseComputed(
|
||||||
"publisherId",
|
"publisherId",
|
||||||
"showToTrustLevel",
|
"showToTrustLevel",
|
||||||
"showToGroups",
|
"showToGroups",
|
||||||
@ -323,14 +320,14 @@ export default AdComponent.extend({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("currentUser.trust_level")
|
@discourseComputed("currentUser.trust_level")
|
||||||
showToTrustLevel(trustLevel) {
|
showToTrustLevel(trustLevel) {
|
||||||
return !(
|
return !(
|
||||||
trustLevel && trustLevel > this.siteSettings.dfp_through_trust_level
|
trustLevel && trustLevel > this.siteSettings.dfp_through_trust_level
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("postNumber")
|
@discourseComputed("postNumber")
|
||||||
showAfterPost(postNumber) {
|
showAfterPost(postNumber) {
|
||||||
if (!postNumber) {
|
if (!postNumber) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
||||||
import {
|
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
||||||
default as computed,
|
|
||||||
observes
|
|
||||||
} from "ember-addons/ember-computed-decorators";
|
|
||||||
|
|
||||||
const adIndex = {
|
const adIndex = {
|
||||||
topic_list_top: null,
|
topic_list_top: null,
|
||||||
@ -16,17 +13,17 @@ export default AdComponent.extend({
|
|||||||
classNameBindings: ["adUnitClass"],
|
classNameBindings: ["adUnitClass"],
|
||||||
adHtml: "",
|
adHtml: "",
|
||||||
|
|
||||||
@computed("placement", "showAd")
|
@discourseComputed("placement", "showAd")
|
||||||
adUnitClass(placement, showAd) {
|
adUnitClass(placement, showAd) {
|
||||||
return showAd ? `house-${placement}` : "";
|
return showAd ? `house-${placement}` : "";
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("showToGroups", "showAfterPost", "showOnCurrentPage")
|
@discourseComputed("showToGroups", "showAfterPost", "showOnCurrentPage")
|
||||||
showAd(showToGroups, showAfterPost, showOnCurrentPage) {
|
showAd(showToGroups, showAfterPost, showOnCurrentPage) {
|
||||||
return showToGroups && showAfterPost && showOnCurrentPage;
|
return showToGroups && showAfterPost && showOnCurrentPage;
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("postNumber")
|
@discourseComputed("postNumber")
|
||||||
showAfterPost(postNumber) {
|
showAfterPost(postNumber) {
|
||||||
if (!postNumber) {
|
if (!postNumber) {
|
||||||
return true;
|
return true;
|
||||||
|
10
package.json
Normal file
10
package.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"name": "discourse-adplugin",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"repository": "git@github.com:discourse/discourse-adplugin.git",
|
||||||
|
"author": "Discourse",
|
||||||
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"eslint-config-discourse": "1.1.0"
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user