diff --git a/.gitignore b/.gitignore index 2ec70f0..6d28d54 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ auto_generated .DS_Store *.swp node_modules +yarn-error.log +.rubocop-https---raw-githubusercontent-com-discourse-* diff --git a/.template-lintrc.js b/.template-lintrc.js new file mode 100644 index 0000000..a558b8e --- /dev/null +++ b/.template-lintrc.js @@ -0,0 +1,4 @@ +module.exports = { + plugins: ["ember-template-lint-plugin-discourse"], + extends: "discourse:recommended", +}; diff --git a/assets/javascripts/discourse/adplugin-route-map.js.es6 b/assets/javascripts/discourse/adplugin-route-map.js.es6 index 5bdd864..6a45cfb 100644 --- a/assets/javascripts/discourse/adplugin-route-map.js.es6 +++ b/assets/javascripts/discourse/adplugin-route-map.js.es6 @@ -2,9 +2,9 @@ export default { resource: "admin.adminPlugins", path: "/plugins", map() { - this.route("houseAds", { path: "/pluginad/house_creatives" }, function() { + this.route("houseAds", { path: "/pluginad/house_creatives" }, function () { this.route("index", { path: "/" }); this.route("show", { path: "/:ad_id" }); }); - } + }, }; diff --git a/assets/javascripts/discourse/components/ad-component.js.es6 b/assets/javascripts/discourse/components/ad-component.js.es6 index 187f3e2..1bc40f9 100644 --- a/assets/javascripts/discourse/components/ad-component.js.es6 +++ b/assets/javascripts/discourse/components/ad-component.js.es6 @@ -54,9 +54,9 @@ export default Ember.Component.extend({ let noAdsGroups = this.siteSettings.no_ads_for_groups .split("|") .filter(Boolean); - let currentGroups = groups.map(g => g.id.toString()); + let currentGroups = groups.map((g) => g.id.toString()); - return !currentGroups.any(g => noAdsGroups.includes(g)); + return !currentGroups.any((g) => noAdsGroups.includes(g)); }, @discourseComputed( @@ -95,5 +95,5 @@ export default Ember.Component.extend({ } else { return false; } - } + }, }); diff --git a/assets/javascripts/discourse/components/ad-slot.js.es6 b/assets/javascripts/discourse/components/ad-slot.js.es6 index 608d3e3..10cf850 100644 --- a/assets/javascripts/discourse/components/ad-slot.js.es6 +++ b/assets/javascripts/discourse/components/ad-slot.js.es6 @@ -5,12 +5,12 @@ const adConfig = Ember.Object.create({ "google-adsense": { settingPrefix: "adsense", // settings follow naming convention enabledSetting: "adsense_publisher_code", - nthPost: "adsense_nth_post_code" + nthPost: "adsense_nth_post_code", }, "google-dfp-ad": { settingPrefix: "dfp", // settings follow naming convention enabledSetting: "dfp_publisher_id", - nthPost: "dfp_nth_post_code" + nthPost: "dfp_nth_post_code", }, "amazon-product-links": { settingPrefix: "amazon", @@ -20,15 +20,15 @@ const adConfig = Ember.Object.create({ "topic-list-top": "amazon_topic_list_top_src_code", "post-bottom": "amazon_post_bottom_src_code", "topic-above-post-stream": "amazon_topic_above_post_stream_src_code", - "topic-above-suggested": "amazon_topic_above_suggested_src_code" + "topic-above-suggested": "amazon_topic_above_suggested_src_code", }, mobile: { "topic-list-top": "amazon_mobile_topic_list_top_src_code", "post-bottom": "amazon_mobile_post_bottom_src_code", "topic-above-post-stream": "amazon_mobile_topic_above_post_stream_src_code", - "topic-above-suggested": "amazon_mobile_topic_above_suggested_src_code" - } + "topic-above-suggested": "amazon_mobile_topic_above_suggested_src_code", + }, }, "carbonads-ad": { settingPrefix: "carbonads", @@ -37,8 +37,8 @@ const adConfig = Ember.Object.create({ "topic-list-top": "carbonads_topic_list_top_enabled", "post-bottom": false, "topic-above-post-stream": "carbonads_above_post_stream_enabled", - "topic-above-suggested": false - } + "topic-above-suggested": false, + }, }, "adbutler-ad": { settingPrefix: "adbutler", @@ -47,21 +47,21 @@ const adConfig = Ember.Object.create({ "topic-list-top": "adbutler_topic_list_top_zone_id", "post-bottom": "adbutler_post_bottom_zone_id", "topic-above-post-stream": "adbutler_topic_above_post_stream_zone_id", - "topic-above-suggested": "adbutler_topic_above_suggested_zone_id" + "topic-above-suggested": "adbutler_topic_above_suggested_zone_id", }, mobile: { "topic-list-top": "adbutler_mobile_topic_list_top_zone_id", "post-bottom": "adbutler_mobile_post_bottom_zone_id", "topic-above-post-stream": "adbutler_mobile_topic_above_post_stream_zone_id", - "topic-above-suggested": "adbutler_mobile_topic_above_suggested_zone_id" - } - } + "topic-above-suggested": "adbutler_mobile_topic_above_suggested_zone_id", + }, + }, }); const displayCounts = { houseAds: 0, - allAds: 0 + allAds: 0, }; export default AdComponent.extend({ @@ -90,7 +90,7 @@ export default AdComponent.extend({ } } - Object.keys(adConfig).forEach(adNetwork => { + Object.keys(adConfig).forEach((adNetwork) => { const config = adConfig[adNetwork]; let settingNames = null, name; @@ -185,12 +185,12 @@ export default AdComponent.extend({ } } - const networkNames = availableAdTypes.filter(x => x !== "house-ad"); + const networkNames = availableAdTypes.filter((x) => x !== "house-ad"); if (houseAdsSkipped) { displayCounts.allAds += networkNames.length; } return networkNames; - } + }, }); diff --git a/assets/javascripts/discourse/components/adbutler-ad.js.es6 b/assets/javascripts/discourse/components/adbutler-ad.js.es6 index 5f59eeb..fd468ac 100644 --- a/assets/javascripts/discourse/components/adbutler-ad.js.es6 +++ b/assets/javascripts/discourse/components/adbutler-ad.js.es6 @@ -19,8 +19,8 @@ function loadAdbutler() { } _promise = loadScript("https://" + adserverHostname + "/app.js", { - scriptTag: true - }).then(function() { + scriptTag: true, + }).then(function () { _loaded = true; }); @@ -61,7 +61,7 @@ export default AdComponent.extend({ divId: divId, publisherId: publisherId, zoneId: zoneId, - dimensions: dimensions + dimensions: dimensions, }); this.set("publisherId", publisherId); @@ -74,11 +74,11 @@ export default AdComponent.extend({ } loadAdbutler().then( - function() { + function () { if (this.divs.length > 0) { let abkw = window.abkw || ""; window.AdButler.ads.push({ - handler: function(opt) { + handler: function (opt) { window.AdButler.register( opt.place.publisherId, opt.place.zoneId, @@ -91,8 +91,8 @@ export default AdComponent.extend({ place: this.divs.pop(), keywords: abkw, domain: adserverHostname, - click: "CLICK_MACRO_PLACEHOLDER" - } + click: "CLICK_MACRO_PLACEHOLDER", + }, }); } }.bind(this) @@ -144,5 +144,5 @@ export default AdComponent.extend({ return true; } return this.isNthPost(parseInt(this.siteSettings.adbutler_nth_post, 10)); - } + }, }); diff --git a/assets/javascripts/discourse/components/amazon-product-links.js.es6 b/assets/javascripts/discourse/components/amazon-product-links.js.es6 index 4082f17..cb0ec9c 100644 --- a/assets/javascripts/discourse/components/amazon-product-links.js.es6 +++ b/assets/javascripts/discourse/components/amazon-product-links.js.es6 @@ -5,7 +5,7 @@ const data = { "topic-list-top": {}, "topic-above-post-stream": {}, "topic-above-suggested": {}, - "post-bottom": {} + "post-bottom": {}, }; let mobileView = Discourse.Site.currentProp("mobileView"); @@ -190,5 +190,5 @@ export default AdComponent.extend({ } return this.isNthPost(parseInt(this.siteSettings.amazon_nth_post_code, 10)); - } + }, }); diff --git a/assets/javascripts/discourse/components/carbonads-ad.js.es6 b/assets/javascripts/discourse/components/carbonads-ad.js.es6 index 38a6b90..38360d9 100644 --- a/assets/javascripts/discourse/components/carbonads-ad.js.es6 +++ b/assets/javascripts/discourse/components/carbonads-ad.js.es6 @@ -32,5 +32,5 @@ export default AdComponent.extend({ showToGroups && showOnCurrentPage ); - } + }, }); diff --git a/assets/javascripts/discourse/components/google-adsense.js.es6 b/assets/javascripts/discourse/components/google-adsense.js.es6 index 7c95095..ecbb6c3 100644 --- a/assets/javascripts/discourse/components/google-adsense.js.es6 +++ b/assets/javascripts/discourse/components/google-adsense.js.es6 @@ -49,7 +49,7 @@ function loadAdsense() { const adsenseSrc = ("https:" === document.location.protocol ? "https:" : "http:") + "//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"; - _promise = loadScript(adsenseSrc, { scriptTag: true }).then(function() { + _promise = loadScript(adsenseSrc, { scriptTag: true }).then(function () { _loaded = true; }); @@ -59,46 +59,46 @@ function loadAdsense() { const DESKTOP_SETTINGS = { "topic-list-top": { code: "adsense_topic_list_top_code", - sizes: "adsense_topic_list_top_ad_sizes" + sizes: "adsense_topic_list_top_ad_sizes", }, "topic-above-post-stream": { code: "adsense_topic_above_post_stream_code", - sizes: "adsense_topic_above_post_stream_ad_sizes" + sizes: "adsense_topic_above_post_stream_ad_sizes", }, "topic-above-suggested": { code: "adsense_topic_above_suggested_code", - sizes: "adsense_topic_above_suggested_ad_sizes" + sizes: "adsense_topic_above_suggested_ad_sizes", }, "post-bottom": { code: "adsense_post_bottom_code", - sizes: "adsense_post_bottom_ad_sizes" - } + sizes: "adsense_post_bottom_ad_sizes", + }, }; const MOBILE_SETTINGS = { "topic-list-top": { code: "adsense_mobile_topic_list_top_code", - sizes: "adsense_mobile_topic_list_top_ad_size" + sizes: "adsense_mobile_topic_list_top_ad_size", }, "topic-above-post-stream": { code: "adsense_mobile_topic_above_post_stream_code", - sizes: "adsense_mobile_topic_above_post_stream_ad_size" + sizes: "adsense_mobile_topic_above_post_stream_ad_size", }, "topic-above-suggested": { code: "adsense_mobile_topic_above_suggested_code", - sizes: "adsense_mobile_topic_above_suggested_ad_size" + sizes: "adsense_mobile_topic_above_suggested_ad_size", }, "post-bottom": { code: "adsense_mobile_post_bottom_code", - sizes: "adsense_mobile_post_bottom_ad_size" - } + sizes: "adsense_mobile_post_bottom_ad_size", + }, }; export default AdComponent.extend({ classNameBindings: [ ":google-adsense", "classForSlot", - "isResponsive:adsense-responsive" + "isResponsive:adsense-responsive", ], loadedGoogletag: false, @@ -143,7 +143,7 @@ export default AdComponent.extend({ } this.set("adRequested", true); - loadAdsense().then(function() { + loadAdsense().then(function () { const adsbygoogle = window.adsbygoogle || []; try { @@ -244,5 +244,5 @@ export default AdComponent.extend({ return this.isNthPost( parseInt(this.siteSettings.adsense_nth_post_code, 10) ); - } + }, }); diff --git a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 index f1571d2..21a0cea 100755 --- a/assets/javascripts/discourse/components/google-dfp-ad.js.es6 +++ b/assets/javascripts/discourse/components/google-dfp-ad.js.es6 @@ -52,26 +52,26 @@ const DESKTOP_SETTINGS = { code: "dfp_topic_list_top_code", sizes: "dfp_topic_list_top_ad_sizes", targeting_keys: "dfp_target_topic_list_top_key_code", - targeting_values: "dfp_target_topic_list_top_value_code" + targeting_values: "dfp_target_topic_list_top_value_code", }, "topic-above-post-stream": { code: "dfp_topic_above_post_stream_code", sizes: "dfp_topic_above_post_stream_ad_sizes", targeting_keys: "dfp_target_topic_above_post_stream_key_code", - targeting_values: "dfp_target_topic_above_post_stream_value_code" + targeting_values: "dfp_target_topic_above_post_stream_value_code", }, "topic-above-suggested": { code: "dfp_topic_above_suggested_code", sizes: "dfp_topic_above_suggested_ad_sizes", targeting_keys: "dfp_target_topic_above_suggested_key_code", - targeting_values: "dfp_target_topic_above_suggested_value_code" + targeting_values: "dfp_target_topic_above_suggested_value_code", }, "post-bottom": { code: "dfp_post_bottom_code", sizes: "dfp_post_bottom_ad_sizes", targeting_keys: "dfp_target_post_bottom_key_code", - targeting_values: "dfp_target_post_bottom_value_code" - } + targeting_values: "dfp_target_post_bottom_value_code", + }, }; const MOBILE_SETTINGS = { @@ -79,26 +79,26 @@ const MOBILE_SETTINGS = { code: "dfp_mobile_topic_list_top_code", sizes: "dfp_mobile_topic_list_top_ad_sizes", targeting_keys: "dfp_target_topic_list_top_key_code", - targeting_values: "dfp_target_topic_list_top_value_code" + targeting_values: "dfp_target_topic_list_top_value_code", }, "topic-above-post-stream": { code: "dfp_mobile_topic_above_post_stream_code", sizes: "dfp_mobile_topic_above_post_stream_ad_sizes", targeting_keys: "dfp_target_topic_above_post_stream_key_code", - targeting_values: "dfp_target_topic_above_post_stream_value_code" + targeting_values: "dfp_target_topic_above_post_stream_value_code", }, "topic-above-suggested": { code: "dfp_mobile_topic_above_suggested_code", sizes: "dfp_mobile_topic_above_suggested_ad_sizes", targeting_keys: "dfp_target_topic_above_suggested_key_code", - targeting_values: "dfp_target_topic_above_suggested_value_code" + targeting_values: "dfp_target_topic_above_suggested_value_code", }, "post-bottom": { code: "dfp_mobile_post_bottom_code", sizes: "dfp_mobile_post_bottom_ad_sizes", targeting_keys: "dfp_target_post_bottom_key_code", - targeting_values: "dfp_target_post_bottom_value_code" - } + targeting_values: "dfp_target_post_bottom_value_code", + }, }; function getWidthAndHeight(placement, settings, isMobile) { @@ -129,7 +129,7 @@ function getWidthAndHeight(placement, settings, isMobile) { const sizeObj = { width: parseInt(splitWidthInt(size), 10), - height: parseInt(splitHeightInt(size), 10) + height: parseInt(splitHeightInt(size), 10), }; if (!isNaN(sizeObj.width) && !isNaN(sizeObj.height)) { @@ -211,14 +211,14 @@ function loadGoogle() { var dfpSrc = ("https:" === document.location.protocol ? "https:" : "http:") + "//securepubads.g.doubleclick.net/tag/js/gpt.js"; - _promise = loadScript(dfpSrc, { scriptTag: true }).then(function() { + _promise = loadScript(dfpSrc, { scriptTag: true }).then(function () { _loaded = true; if (window.googletag === undefined) { // eslint-disable-next-line no-console console.log("googletag is undefined!"); } - window.googletag.cmd.push(function() { + window.googletag.cmd.push(function () { // Infinite scroll requires SRA: window.googletag.pubads().enableSingleRequest(); @@ -415,5 +415,5 @@ export default AdComponent.extend({ @on("willDestroyElement") cleanup() { destroySlot(this.get("divId")); - } + }, }); diff --git a/assets/javascripts/discourse/components/house-ad.js.es6 b/assets/javascripts/discourse/components/house-ad.js.es6 index 60eafa0..faa21a6 100644 --- a/assets/javascripts/discourse/components/house-ad.js.es6 +++ b/assets/javascripts/discourse/components/house-ad.js.es6 @@ -5,7 +5,7 @@ const adIndex = { topic_list_top: null, topic_above_post_stream: null, topic_above_suggested: null, - post_bottom: null + post_bottom: null, }; export default AdComponent.extend({ @@ -92,12 +92,12 @@ export default AdComponent.extend({ if (adIndex.topic_list_top === null) { // start at a random spot in the ad inventory - Object.keys(adIndex).forEach(placement => { + Object.keys(adIndex).forEach((placement) => { const adNames = this.adsNamesForSlot(placement); adIndex[placement] = Math.floor(Math.random() * adNames.length); }); } this.refreshAd(); - } + }, }); diff --git a/assets/javascripts/discourse/components/house-ads-chooser.js.es6 b/assets/javascripts/discourse/components/house-ads-chooser.js.es6 index d51ecc3..c6aeaad 100644 --- a/assets/javascripts/discourse/components/house-ads-chooser.js.es6 +++ b/assets/javascripts/discourse/components/house-ads-chooser.js.es6 @@ -13,7 +13,7 @@ export default MultiSelectComponent.extend({ valueAttribute: null, nameProperty: null, - value: computed("settingValue", function() { + value: computed("settingValue", function () { return this.settingValue .toString() .split(this.tokenSeparator) @@ -28,7 +28,7 @@ export default MultiSelectComponent.extend({ return this.settingValue.split(this.tokenSeparator).filter(Boolean); }, - content: computed("choices", function() { + content: computed("choices", function () { return makeArray(this.choices); }), @@ -36,6 +36,6 @@ export default MultiSelectComponent.extend({ onChange(value) { const settingValue = makeArray(value).join(this.tokenSeparator); this.attrs.onChange && this.attrs.onChange(settingValue); - } - } + }, + }, }); diff --git a/assets/javascripts/discourse/components/house-ads-list-setting.js.es6 b/assets/javascripts/discourse/components/house-ads-list-setting.js.es6 index 145d974..96ddaa6 100644 --- a/assets/javascripts/discourse/components/house-ads-list-setting.js.es6 +++ b/assets/javascripts/discourse/components/house-ads-list-setting.js.es6 @@ -2,5 +2,5 @@ import HouseAdsSetting from "discourse/plugins/discourse-adplugin/discourse/comp export default HouseAdsSetting.extend({ classNames: "house-ads-setting house-ads-list-setting", - adNames: Ember.computed.mapBy("allAds", "name") + adNames: Ember.computed.mapBy("allAds", "name"), }); diff --git a/assets/javascripts/discourse/components/house-ads-setting.js.es6 b/assets/javascripts/discourse/components/house-ads-setting.js.es6 index 7689d01..7951d45 100644 --- a/assets/javascripts/discourse/components/house-ads-setting.js.es6 +++ b/assets/javascripts/discourse/components/house-ads-setting.js.es6 @@ -1,6 +1,7 @@ import { ajax } from "discourse/lib/ajax"; import { popupAjaxError } from "discourse/lib/ajax-error"; import { i18n, propertyNotEqual } from "discourse/lib/computed"; +import I18n from "I18n"; export default Ember.Component.extend({ classNames: "house-ads-setting", @@ -21,14 +22,14 @@ export default Ember.Component.extend({ if (!this.get("saving")) { this.setProperties({ saving: true, - savingStatus: I18n.t("saving") + savingStatus: I18n.t("saving"), }); ajax( `/admin/plugins/pluginad/house_settings/${this.get("name")}.json`, { type: "PUT", - data: { value: this.get("adValue") } + data: { value: this.get("adValue") }, } ) .then(() => { @@ -36,14 +37,14 @@ export default Ember.Component.extend({ adSettings.set(this.get("name"), this.get("adValue")); this.setProperties({ value: this.get("adValue"), - savingStatus: I18n.t("saved") + savingStatus: I18n.t("saved"), }); }) .catch(popupAjaxError) .finally(() => { this.setProperties({ saving: false, - savingStatus: "" + savingStatus: "", }); }); } @@ -51,6 +52,6 @@ export default Ember.Component.extend({ cancel() { this.set("adValue", this.get("value")); - } - } + }, + }, }); diff --git a/assets/javascripts/discourse/controllers/admin-plugins-house-ads-index.js.es6 b/assets/javascripts/discourse/controllers/admin-plugins-house-ads-index.js.es6 index 9322e96..271eea8 100644 --- a/assets/javascripts/discourse/controllers/admin-plugins-house-ads-index.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-plugins-house-ads-index.js.es6 @@ -1,5 +1,5 @@ export default Ember.Controller.extend({ adminPluginsHouseAds: Ember.inject.controller("adminPlugins.houseAds"), houseAds: Ember.computed.alias("adminPluginsHouseAds.model"), - adSettings: Ember.computed.alias("adminPluginsHouseAds.houseAdsSettings") + adSettings: Ember.computed.alias("adminPluginsHouseAds.houseAdsSettings"), }); diff --git a/assets/javascripts/discourse/controllers/admin-plugins-house-ads-show.js.es6 b/assets/javascripts/discourse/controllers/admin-plugins-house-ads-show.js.es6 index 4326762..293cf15 100644 --- a/assets/javascripts/discourse/controllers/admin-plugins-house-ads-show.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-plugins-house-ads-show.js.es6 @@ -1,3 +1,4 @@ +import I18n from "I18n"; import { ajax } from "discourse/lib/ajax"; import { popupAjaxError } from "discourse/lib/ajax-error"; import { propertyNotEqual } from "discourse/lib/computed"; @@ -19,7 +20,7 @@ export default Ember.Controller.extend(bufferedProperty("model"), { if (!this.get("saving")) { this.setProperties({ saving: true, - savingStatus: I18n.t("saving") + savingStatus: I18n.t("saving"), }); const data = {}, @@ -38,10 +39,10 @@ export default Ember.Controller.extend(bufferedProperty("model"), { : `/admin/plugins/pluginad/house_creatives/${buffered.get("id")}`, { type: newRecord ? "POST" : "PUT", - data + data, } ) - .then(ajaxData => { + .then((ajaxData) => { this.commitBuffer(); this.set("savingStatus", I18n.t("saved")); if (newRecord) { @@ -61,7 +62,7 @@ export default Ember.Controller.extend(bufferedProperty("model"), { .finally(() => { this.setProperties({ saving: false, - savingStatus: "" + savingStatus: "", }); }); } @@ -81,13 +82,13 @@ export default Ember.Controller.extend(bufferedProperty("model"), { } ajax(`/admin/plugins/pluginad/house_creatives/${model.get("id")}`, { - type: "DELETE" + type: "DELETE", }) .then(() => { houseAds.removeObject(model); this.transitionToRoute("adminPlugins.houseAds.index"); }) .catch(() => bootbox.alert(I18n.t("generic_error"))); - } - } + }, + }, }); diff --git a/assets/javascripts/discourse/controllers/admin-plugins-house-ads.js.es6 b/assets/javascripts/discourse/controllers/admin-plugins-house-ads.js.es6 index 8b22942..35eb48e 100644 --- a/assets/javascripts/discourse/controllers/admin-plugins-house-ads.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-plugins-house-ads.js.es6 @@ -1,3 +1,3 @@ export default Ember.Controller.extend({ - loadingAds: true + loadingAds: true, }); diff --git a/assets/javascripts/discourse/routes/admin-plugins-house-ads-index.js.es6 b/assets/javascripts/discourse/routes/admin-plugins-house-ads-index.js.es6 index 9017184..db33d67 100644 --- a/assets/javascripts/discourse/routes/admin-plugins-house-ads-index.js.es6 +++ b/assets/javascripts/discourse/routes/admin-plugins-house-ads-index.js.es6 @@ -4,6 +4,6 @@ export default DiscourseRoute.extend({ actions: { moreSettings() { this.transitionTo("adminSiteSettingsCategory", "ad_plugin"); - } - } + }, + }, }); diff --git a/assets/javascripts/discourse/routes/admin-plugins-house-ads-show.js.es6 b/assets/javascripts/discourse/routes/admin-plugins-house-ads-show.js.es6 index 1ee6061..e2ab9a9 100644 --- a/assets/javascripts/discourse/routes/admin-plugins-house-ads-show.js.es6 +++ b/assets/javascripts/discourse/routes/admin-plugins-house-ads-show.js.es6 @@ -1,11 +1,12 @@ import DiscourseRoute from "discourse/routes/discourse"; +import I18n from "I18n"; export default DiscourseRoute.extend({ model(params) { if (params.ad_id === "new") { return Ember.Object.create({ name: I18n.t("admin.adplugin.house_ads.new_name"), - html: "" + html: "", }); } else { return this.modelFor("adminPlugins.houseAds").findBy( @@ -13,5 +14,5 @@ export default DiscourseRoute.extend({ parseInt(params.ad_id, 10) ); } - } + }, }); diff --git a/assets/javascripts/discourse/routes/admin-plugins-house-ads.js.es6 b/assets/javascripts/discourse/routes/admin-plugins-house-ads.js.es6 index b4145e1..00c806d 100644 --- a/assets/javascripts/discourse/routes/admin-plugins-house-ads.js.es6 +++ b/assets/javascripts/discourse/routes/admin-plugins-house-ads.js.es6 @@ -5,9 +5,9 @@ export default DiscourseRoute.extend({ settings: null, model() { - return ajax("/admin/plugins/pluginad/house_creatives.json").then(data => { + return ajax("/admin/plugins/pluginad/house_creatives.json").then((data) => { this.set("settings", Ember.Object.create(data.settings)); - return data.house_ads.map(ad => Ember.Object.create(ad)); + return data.house_ads.map((ad) => Ember.Object.create(ad)); }); }, @@ -15,7 +15,7 @@ export default DiscourseRoute.extend({ controller.setProperties({ model, houseAdsSettings: this.get("settings"), - loadingAds: false + loadingAds: false, }); - } + }, }); diff --git a/assets/javascripts/discourse/templates/admin/plugins-house-ads-index.hbs b/assets/javascripts/discourse/templates/admin/plugins-house-ads-index.hbs index 3284a0c..5b72559 100644 --- a/assets/javascripts/discourse/templates/admin/plugins-house-ads-index.hbs +++ b/assets/javascripts/discourse/templates/admin/plugins-house-ads-index.hbs @@ -1,13 +1,7 @@ {{#d-section class="house-ads-settings content-body"}} -
{{i18n 'admin.adplugin.house_ads.description'}}
+
{{i18n "admin.adplugin.house_ads.description"}}
- {{#unless houseAds.length}} -

- {{#link-to 'adminPlugins.houseAds.show' 'new'}} - {{i18n 'admin.adplugin.house_ads.get_started'}} - {{/link-to}} -

- {{else}} + {{#if houseAds.length}}
{{house-ads-list-setting name="topic_list_top" value=adSettings.topic_list_top allAds=houseAds adSettings=adSettings}} {{house-ads-list-setting name="topic_above_post_stream" value=adSettings.topic_above_post_stream allAds=houseAds adSettings=adSettings}} @@ -17,7 +11,14 @@ {{d-button label="admin.adplugin.house_ads.more_settings" icon="cog" class="btn-default" - action=(route-action "moreSettings")}} + action=(route-action "moreSettings") + }}
- {{/unless}} + {{else}} +

+ {{#link-to "adminPlugins.houseAds.show" "new"}} + {{i18n "admin.adplugin.house_ads.get_started"}} + {{/link-to}} +

+ {{/if}} {{/d-section}} diff --git a/assets/javascripts/discourse/templates/admin/plugins-house-ads-show.hbs b/assets/javascripts/discourse/templates/admin/plugins-house-ads-show.hbs index 10b553e..b5244d3 100644 --- a/assets/javascripts/discourse/templates/admin/plugins-house-ads-show.hbs +++ b/assets/javascripts/discourse/templates/admin/plugins-house-ads-show.hbs @@ -14,7 +14,7 @@ {{savingStatus}} {{else}} {{#if dirty}} - {{i18n 'cancel'}} + {{i18n "cancel"}} {{/if}} {{/if}} diff --git a/assets/javascripts/discourse/templates/admin/plugins-house-ads.hbs b/assets/javascripts/discourse/templates/admin/plugins-house-ads.hbs index 75e2c70..fd39a6b 100644 --- a/assets/javascripts/discourse/templates/admin/plugins-house-ads.hbs +++ b/assets/javascripts/discourse/templates/admin/plugins-house-ads.hbs @@ -1,21 +1,21 @@
-

{{i18n 'admin.adplugin.house_ads.title'}}

+

{{i18n "admin.adplugin.house_ads.title"}}

{{#if model.length}}
- {{#link-to 'adminPlugins.houseAds.show' 'new' class="btn btn-primary"}} + {{#link-to "adminPlugins.houseAds.show" "new" class="btn btn-primary"}} {{d-icon "plus"}} - {{i18n 'admin.adplugin.house_ads.new'}} + {{i18n "admin.adplugin.house_ads.new"}} {{/link-to}} - {{#link-to 'adminPlugins.houseAds.index' class="btn btn-default"}} + {{#link-to "adminPlugins.houseAds.index" class="btn btn-default"}} {{d-icon "cog"}} - {{i18n 'admin.adplugin.house_ads.settings'}} + {{i18n "admin.adplugin.house_ads.settings"}} {{/link-to}}