From 8d4df6df9151f4af61a7e8f3ed2812998b0e854e Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Tue, 8 Oct 2019 17:41:13 -0400 Subject: [PATCH] Rename house ad routes so ad blockers don't detect them adplugin, house_ads, house_ad_settings become pluginad, house_creatives, and house_settings. --- assets/javascripts/discourse/adplugin-route-map.js.es6 | 2 +- .../discourse/components/house-ads-setting.js.es6 | 2 +- .../controllers/admin-plugins-house-ads-show.js.es6 | 6 +++--- .../discourse/routes/admin-plugins-house-ads.js.es6 | 2 +- plugin.rb | 6 +++--- spec/requests/house_ad_settings_controller_spec.rb | 10 +++++----- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/assets/javascripts/discourse/adplugin-route-map.js.es6 b/assets/javascripts/discourse/adplugin-route-map.js.es6 index e68edbc..5bdd864 100644 --- a/assets/javascripts/discourse/adplugin-route-map.js.es6 +++ b/assets/javascripts/discourse/adplugin-route-map.js.es6 @@ -2,7 +2,7 @@ export default { resource: "admin.adminPlugins", path: "/plugins", map() { - this.route("houseAds", { path: "/adplugin/house_ads" }, 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/house-ads-setting.js.es6 b/assets/javascripts/discourse/components/house-ads-setting.js.es6 index fdf81f6..7689d01 100644 --- a/assets/javascripts/discourse/components/house-ads-setting.js.es6 +++ b/assets/javascripts/discourse/components/house-ads-setting.js.es6 @@ -25,7 +25,7 @@ export default Ember.Component.extend({ }); ajax( - `/admin/plugins/adplugin/house_ad_settings/${this.get("name")}.json`, + `/admin/plugins/pluginad/house_settings/${this.get("name")}.json`, { type: "PUT", data: { value: this.get("adValue") } 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 eccf86a..4326762 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 @@ -34,8 +34,8 @@ export default Ember.Controller.extend(bufferedProperty("model"), { ajax( newRecord - ? `/admin/plugins/adplugin/house_ads` - : `/admin/plugins/adplugin/house_ads/${buffered.get("id")}`, + ? `/admin/plugins/pluginad/house_creatives` + : `/admin/plugins/pluginad/house_creatives/${buffered.get("id")}`, { type: newRecord ? "POST" : "PUT", data @@ -80,7 +80,7 @@ export default Ember.Controller.extend(bufferedProperty("model"), { return; } - ajax(`/admin/plugins/adplugin/house_ads/${model.get("id")}`, { + ajax(`/admin/plugins/pluginad/house_creatives/${model.get("id")}`, { type: "DELETE" }) .then(() => { 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 bc03d17..1c0cda6 100644 --- a/assets/javascripts/discourse/routes/admin-plugins-house-ads.js.es6 +++ b/assets/javascripts/discourse/routes/admin-plugins-house-ads.js.es6 @@ -4,7 +4,7 @@ export default Discourse.Route.extend({ settings: null, model() { - return ajax("/admin/plugins/adplugin/house_ads.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)); }); diff --git a/plugin.rb b/plugin.rb index 73d892f..05f119e 100755 --- a/plugin.rb +++ b/plugin.rb @@ -71,12 +71,12 @@ after_initialize do AdPlugin::Engine.routes.draw do root to: 'house_ads#index' - resources :house_ads, only: [:index, :show, :create, :update, :destroy] - resources :house_ad_settings, only: [:update] + resources :house_creatives, only: [:index, :show, :create, :update, :destroy], controller: 'house_ads' + resources :house_settings, only: [:update], controller: 'house_ad_settings' end Discourse::Application.routes.append do get '/ads.txt' => "adstxt#index" - mount ::AdPlugin::Engine, at: '/admin/plugins/adplugin', constraints: AdminConstraint.new + mount ::AdPlugin::Engine, at: '/admin/plugins/pluginad', constraints: AdminConstraint.new end end diff --git a/spec/requests/house_ad_settings_controller_spec.rb b/spec/requests/house_ad_settings_controller_spec.rb index 76f652e..19ec0b1 100644 --- a/spec/requests/house_ad_settings_controller_spec.rb +++ b/spec/requests/house_ad_settings_controller_spec.rb @@ -13,13 +13,13 @@ describe AdPlugin::HouseAdSettingsController do let(:valid_params) { { value: 'Banner' } } it "error if not logged in" do - put '/admin/plugins/adplugin/house_ad_settings/topic_list_top.json', params: valid_params + put '/admin/plugins/pluginad/house_settings/topic_list_top.json', params: valid_params expect(response.status).to eq(404) end it "error if not staff" do sign_in(Fabricate(:user)) - put '/admin/plugins/adplugin/house_ad_settings/topic_list_top.json', params: valid_params + put '/admin/plugins/pluginad/house_settings/topic_list_top.json', params: valid_params expect(response.status).to eq(404) end @@ -29,18 +29,18 @@ describe AdPlugin::HouseAdSettingsController do end it "changes the setting" do - put '/admin/plugins/adplugin/house_ad_settings/topic_list_top.json', params: valid_params + put '/admin/plugins/pluginad/house_settings/topic_list_top.json', params: valid_params expect(response.status).to eq(200) expect(AdPlugin::HouseAdSetting.all[:topic_list_top]).to eq(valid_params[:value]) end it "errors on invalid setting name" do - put '/admin/plugins/adplugin/house_ad_settings/nope-nope.json', params: valid_params + put '/admin/plugins/pluginad/house_settings/nope-nope.json', params: valid_params expect(response.status).to eq(404) end it "errors on invalid setting value" do - put '/admin/plugins/adplugin/house_ad_settings/topic_list_top.json', params: valid_params.merge(value: "Banner|