mirror of
https://github.com/discourse/discourse-adplugin.git
synced 2025-02-18 01:15:00 +00:00
DEV: Fix imports (#132)
This commit is contained in:
parent
c788b7bf1f
commit
7e2a490b67
1
.prettierrc
Normal file
1
.prettierrc
Normal file
@ -0,0 +1 @@
|
|||||||
|
{}
|
@ -1,24 +1,27 @@
|
|||||||
|
import Component from "@ember/component";
|
||||||
|
import { inject as service } from "@ember/service";
|
||||||
|
import { alias, or } from "@ember/object/computed";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Component.extend({
|
||||||
router: Ember.inject.service(),
|
router: service(),
|
||||||
|
|
||||||
currentCategoryId: Ember.computed.or(
|
currentCategoryId: or(
|
||||||
"router.currentRoute.attributes.category.id",
|
"router.currentRoute.attributes.category.id",
|
||||||
"router.currentRoute.parent.attributes.category_id"
|
"router.currentRoute.parent.attributes.category_id"
|
||||||
),
|
),
|
||||||
|
|
||||||
currentCategorySlug: Ember.computed.or(
|
currentCategorySlug: or(
|
||||||
"router.currentRoute.attributes.category.slug",
|
"router.currentRoute.attributes.category.slug",
|
||||||
"router.currentRoute.parent.attributes.category.slug"
|
"router.currentRoute.parent.attributes.category.slug"
|
||||||
),
|
),
|
||||||
|
|
||||||
// Server needs to compute this in case hidden tags are being used.
|
// Server needs to compute this in case hidden tags are being used.
|
||||||
topicTagsDisableAds: Ember.computed.alias(
|
topicTagsDisableAds: alias(
|
||||||
"router.currentRoute.parent.attributes.tags_disable_ads"
|
"router.currentRoute.parent.attributes.tags_disable_ads"
|
||||||
),
|
),
|
||||||
|
|
||||||
isRestrictedCategory: Ember.computed.or(
|
isRestrictedCategory: or(
|
||||||
"router.currentRoute.attributes.category.read_restricted",
|
"router.currentRoute.attributes.category.read_restricted",
|
||||||
"router.currentRoute.parent.attributes.category.read_restricted"
|
"router.currentRoute.parent.attributes.category.read_restricted"
|
||||||
),
|
),
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
import EmberObject from "@ember/object";
|
||||||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
||||||
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
||||||
|
import { isBlank } from "@ember/utils";
|
||||||
|
|
||||||
const adConfig = Ember.Object.create({
|
const adConfig = EmberObject.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",
|
||||||
@ -82,7 +84,7 @@ export default AdComponent.extend({
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
Object.keys(houseAds.creatives).length > 0 &&
|
Object.keys(houseAds.creatives).length > 0 &&
|
||||||
!Ember.isBlank(adsForSlot) &&
|
!isBlank(adsForSlot) &&
|
||||||
(!postNumber ||
|
(!postNumber ||
|
||||||
this.isNthPost(parseInt(houseAds.settings.after_nth_post, 10)))
|
this.isNthPost(parseInt(houseAds.settings.after_nth_post, 10)))
|
||||||
) {
|
) {
|
||||||
@ -97,7 +99,7 @@ export default AdComponent.extend({
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
((config.enabledSetting &&
|
((config.enabledSetting &&
|
||||||
!Ember.isBlank(this.siteSettings[config.enabledSetting])) ||
|
!isBlank(this.siteSettings[config.enabledSetting])) ||
|
||||||
config.enabledSetting === false) &&
|
config.enabledSetting === false) &&
|
||||||
(!postNumber ||
|
(!postNumber ||
|
||||||
!config.nthPost ||
|
!config.nthPost ||
|
||||||
@ -123,7 +125,7 @@ export default AdComponent.extend({
|
|||||||
if (
|
if (
|
||||||
name !== false &&
|
name !== false &&
|
||||||
this.siteSettings[name] !== false &&
|
this.siteSettings[name] !== false &&
|
||||||
!Ember.isBlank(this.siteSettings[name])
|
!isBlank(this.siteSettings[name])
|
||||||
) {
|
) {
|
||||||
types.push(adNetwork);
|
types.push(adNetwork);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
||||||
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
||||||
import loadScript from "discourse/lib/load-script";
|
import loadScript from "discourse/lib/load-script";
|
||||||
|
import RSVP from "rsvp";
|
||||||
|
import { scheduleOnce } from "@ember/runloop";
|
||||||
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
|
|
||||||
let _loaded = false,
|
let _loaded = false,
|
||||||
_promise = null,
|
_promise = null,
|
||||||
@ -8,7 +11,7 @@ let _loaded = false,
|
|||||||
|
|
||||||
function loadAdbutler(adserverHostname) {
|
function loadAdbutler(adserverHostname) {
|
||||||
if (_loaded) {
|
if (_loaded) {
|
||||||
return Ember.RSVP.resolve();
|
return RSVP.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_promise) {
|
if (_promise) {
|
||||||
@ -71,7 +74,7 @@ export default AdComponent.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_triggerAds() {
|
_triggerAds() {
|
||||||
if (Ember.testing) {
|
if (isTesting()) {
|
||||||
return; // Don't load external JS during tests
|
return; // Don't load external JS during tests
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +108,7 @@ export default AdComponent.extend({
|
|||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super();
|
this._super();
|
||||||
Ember.run.scheduleOnce("afterRender", this, this._triggerAds);
|
scheduleOnce("afterRender", this, this._triggerAds);
|
||||||
},
|
},
|
||||||
|
|
||||||
@observes("listLoading")
|
@observes("listLoading")
|
||||||
@ -114,7 +117,7 @@ export default AdComponent.extend({
|
|||||||
return;
|
return;
|
||||||
} // already requested that this ad unit be populated
|
} // already requested that this ad unit be populated
|
||||||
if (!this.get("listLoading")) {
|
if (!this.get("listLoading")) {
|
||||||
Ember.run.scheduleOnce("afterRender", this, this._triggerAds);
|
scheduleOnce("afterRender", this, this._triggerAds);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
|
import { and } from "@ember/object/computed";
|
||||||
|
|
||||||
export default AdComponent.extend({
|
export default AdComponent.extend({
|
||||||
classNames: ["amazon-product-links"],
|
classNames: ["amazon-product-links"],
|
||||||
|
|
||||||
showAd: Ember.computed.and(
|
showAd: and(
|
||||||
"showToTrustLevel",
|
"showToTrustLevel",
|
||||||
"showToGroups",
|
"showToGroups",
|
||||||
"showAfterPost",
|
"showAfterPost",
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
||||||
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
||||||
import loadScript from "discourse/lib/load-script";
|
import loadScript from "discourse/lib/load-script";
|
||||||
|
import RSVP from "rsvp";
|
||||||
|
import { scheduleOnce } from "@ember/runloop";
|
||||||
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
|
|
||||||
let _loaded = false,
|
let _loaded = false,
|
||||||
_promise = null,
|
_promise = null,
|
||||||
@ -38,7 +41,7 @@ function parseAdHeight(value) {
|
|||||||
|
|
||||||
function loadAdsense() {
|
function loadAdsense() {
|
||||||
if (_loaded) {
|
if (_loaded) {
|
||||||
return Ember.RSVP.resolve();
|
return RSVP.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_promise) {
|
if (_promise) {
|
||||||
@ -138,7 +141,7 @@ export default AdComponent.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_triggerAds() {
|
_triggerAds() {
|
||||||
if (Ember.testing) {
|
if (isTesting()) {
|
||||||
return; // Don't load external JS during tests
|
return; // Don't load external JS during tests
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +166,7 @@ export default AdComponent.extend({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ember.run.scheduleOnce("afterRender", this, this._triggerAds);
|
scheduleOnce("afterRender", this, this._triggerAds);
|
||||||
},
|
},
|
||||||
|
|
||||||
@observes("listLoading")
|
@observes("listLoading")
|
||||||
@ -172,7 +175,7 @@ export default AdComponent.extend({
|
|||||||
return;
|
return;
|
||||||
} // already requested that this ad unit be populated
|
} // already requested that this ad unit be populated
|
||||||
if (!this.get("listLoading")) {
|
if (!this.get("listLoading")) {
|
||||||
Ember.run.scheduleOnce("afterRender", this, this._triggerAds);
|
scheduleOnce("afterRender", this, this._triggerAds);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
||||||
import discourseComputed, { on } from "discourse-common/utils/decorators";
|
import discourseComputed, { on } from "discourse-common/utils/decorators";
|
||||||
import loadScript from "discourse/lib/load-script";
|
import loadScript from "discourse/lib/load-script";
|
||||||
|
import { alias } from "@ember/object/computed";
|
||||||
|
import RSVP from "rsvp";
|
||||||
|
import { isTesting } from "discourse-common/config/environment";
|
||||||
|
|
||||||
let _loaded = false,
|
let _loaded = false,
|
||||||
_promise = null,
|
_promise = null,
|
||||||
@ -200,7 +203,7 @@ function loadGoogle() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (_loaded) {
|
if (_loaded) {
|
||||||
return Ember.RSVP.resolve();
|
return RSVP.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_promise) {
|
if (_promise) {
|
||||||
@ -240,8 +243,8 @@ export default AdComponent.extend({
|
|||||||
loadedGoogletag: false,
|
loadedGoogletag: false,
|
||||||
refreshOnChange: null,
|
refreshOnChange: null,
|
||||||
lastAdRefresh: null,
|
lastAdRefresh: null,
|
||||||
width: Ember.computed.alias("size.width"),
|
width: alias("size.width"),
|
||||||
height: Ember.computed.alias("size.height"),
|
height: alias("size.height"),
|
||||||
|
|
||||||
@discourseComputed
|
@discourseComputed
|
||||||
size() {
|
size() {
|
||||||
@ -372,7 +375,7 @@ export default AdComponent.extend({
|
|||||||
|
|
||||||
@on("didInsertElement")
|
@on("didInsertElement")
|
||||||
_initGoogleDFP() {
|
_initGoogleDFP() {
|
||||||
if (Ember.testing) {
|
if (isTesting()) {
|
||||||
return; // Don't load external JS during tests
|
return; // Don't load external JS during tests
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
||||||
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
||||||
|
import { isBlank } from "@ember/utils";
|
||||||
|
|
||||||
const adIndex = {
|
const adIndex = {
|
||||||
topic_list_top: null,
|
topic_list_top: null,
|
||||||
@ -60,10 +61,7 @@ export default AdComponent.extend({
|
|||||||
|
|
||||||
const adsForSlot = houseAds.settings[placement];
|
const adsForSlot = houseAds.settings[placement];
|
||||||
|
|
||||||
if (
|
if (Object.keys(houseAds.creatives).length > 0 && !isBlank(adsForSlot)) {
|
||||||
Object.keys(houseAds.creatives).length > 0 &&
|
|
||||||
!Ember.isBlank(adsForSlot)
|
|
||||||
) {
|
|
||||||
return adsForSlot.split("|");
|
return adsForSlot.split("|");
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import HouseAdsSetting from "discourse/plugins/discourse-adplugin/discourse/components/house-ads-setting";
|
import HouseAdsSetting from "discourse/plugins/discourse-adplugin/discourse/components/house-ads-setting";
|
||||||
|
import { mapBy } from "@ember/object/computed";
|
||||||
|
|
||||||
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: mapBy("allAds", "name"),
|
||||||
});
|
});
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
import Component from "@ember/component";
|
||||||
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";
|
import I18n from "I18n";
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Component.extend({
|
||||||
classNames: "house-ads-setting",
|
classNames: "house-ads-setting",
|
||||||
adValue: "",
|
adValue: "",
|
||||||
saving: false,
|
saving: false,
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
export default Ember.Controller.extend({
|
import Controller, { inject as controller } from "@ember/controller";
|
||||||
adminPluginsHouseAds: Ember.inject.controller("adminPlugins.houseAds"),
|
import { alias } from "@ember/object/computed";
|
||||||
houseAds: Ember.computed.alias("adminPluginsHouseAds.model"),
|
|
||||||
adSettings: Ember.computed.alias("adminPluginsHouseAds.houseAdsSettings"),
|
export default Controller.extend({
|
||||||
|
adminPluginsHouseAds: controller("adminPlugins.houseAds"),
|
||||||
|
houseAds: alias("adminPluginsHouseAds.model"),
|
||||||
|
adSettings: alias("adminPluginsHouseAds.houseAdsSettings"),
|
||||||
});
|
});
|
||||||
|
@ -3,17 +3,20 @@ 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";
|
||||||
import { bufferedProperty } from "discourse/mixins/buffered-content";
|
import { bufferedProperty } from "discourse/mixins/buffered-content";
|
||||||
|
import bootbox from "bootbox";
|
||||||
|
import Controller, { inject as controller } from "@ember/controller";
|
||||||
|
import { not, or } from "@ember/object/computed";
|
||||||
|
|
||||||
export default Ember.Controller.extend(bufferedProperty("model"), {
|
export default Controller.extend(bufferedProperty("model"), {
|
||||||
adminPluginsHouseAds: Ember.inject.controller("adminPlugins.houseAds"),
|
adminPluginsHouseAds: controller("adminPlugins.houseAds"),
|
||||||
|
|
||||||
saving: false,
|
saving: false,
|
||||||
savingStatus: "",
|
savingStatus: "",
|
||||||
|
|
||||||
nameDirty: propertyNotEqual("buffered.name", "model.name"),
|
nameDirty: propertyNotEqual("buffered.name", "model.name"),
|
||||||
htmlDirty: propertyNotEqual("buffered.html", "model.html"),
|
htmlDirty: propertyNotEqual("buffered.html", "model.html"),
|
||||||
dirty: Ember.computed.or("nameDirty", "htmlDirty"),
|
dirty: or("nameDirty", "htmlDirty"),
|
||||||
disableSave: Ember.computed.not("dirty"),
|
disableSave: not("dirty"),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
save() {
|
save() {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
export default Ember.Controller.extend({
|
import Controller from "@ember/controller";
|
||||||
|
|
||||||
|
export default Controller.extend({
|
||||||
loadingAds: true,
|
loadingAds: true,
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import DiscourseRoute from "discourse/routes/discourse";
|
import DiscourseRoute from "discourse/routes/discourse";
|
||||||
|
import EmberObject from "@ember/object";
|
||||||
import I18n from "I18n";
|
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 EmberObject.create({
|
||||||
name: I18n.t("admin.adplugin.house_ads.new_name"),
|
name: I18n.t("admin.adplugin.house_ads.new_name"),
|
||||||
html: "",
|
html: "",
|
||||||
});
|
});
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import DiscourseRoute from "discourse/routes/discourse";
|
import DiscourseRoute from "discourse/routes/discourse";
|
||||||
|
import EmberObject from "@ember/object";
|
||||||
|
|
||||||
export default DiscourseRoute.extend({
|
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", EmberObject.create(data.settings));
|
||||||
return data.house_ads.map((ad) => Ember.Object.create(ad));
|
return data.house_ads.map((ad) => EmberObject.create(ad));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
"author": "Discourse",
|
"author": "Discourse",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint-config-discourse": "^1.1.8"
|
"eslint-config-discourse": "^2.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -498,10 +498,10 @@ escape-string-regexp@^1.0.5:
|
|||||||
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
|
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
|
||||||
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
|
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
|
||||||
|
|
||||||
eslint-config-discourse@^1.1.8:
|
eslint-config-discourse@^2.0.0:
|
||||||
version "1.1.8"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/eslint-config-discourse/-/eslint-config-discourse-1.1.8.tgz#c297831876811ea08203aa348d1ba2a963b2ae78"
|
resolved "https://registry.yarnpkg.com/eslint-config-discourse/-/eslint-config-discourse-2.0.0.tgz#811ab2cf4e32c1f0d41bd57d9736d578fe80b741"
|
||||||
integrity sha512-ZSQfhliiO5Cfa7WcKoMkN4wW/1rBJpecpMJpfjiFsElfgPj4EV4Pzksi5CvFnRbJDoZh6DYYrQfO+tW062VOUA==
|
integrity sha512-enjsLU++iibJXM64YM6Y/yUM5580wKtkti9fQdrJDFkfLJnvv8/f2j7QmNbX//MoqWfIQfY2RkHH6VTfRUg4Mw==
|
||||||
dependencies:
|
dependencies:
|
||||||
babel-eslint "^10.1.0"
|
babel-eslint "^10.1.0"
|
||||||
ember-template-lint "^2.11.0"
|
ember-template-lint "^2.11.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user