diff --git a/assets/javascripts/discourse/controllers/patrons-index.js.es6 b/assets/javascripts/discourse/controllers/s-index.js.es6 similarity index 93% rename from assets/javascripts/discourse/controllers/patrons-index.js.es6 rename to assets/javascripts/discourse/controllers/s-index.js.es6 index 70bbf49..9027ae2 100644 --- a/assets/javascripts/discourse/controllers/patrons-index.js.es6 +++ b/assets/javascripts/discourse/controllers/s-index.js.es6 @@ -3,7 +3,7 @@ import { ajax } from "discourse/lib/ajax"; export default Ember.Controller.extend({ actions: { stripePaymentHandler(data) { - return ajax("/patrons/patrons", { + return ajax("/s/patrons", { data, method: "post" }).catch(() => { diff --git a/assets/javascripts/discourse/controllers/patrons-subscribe-show.js.es6 b/assets/javascripts/discourse/controllers/s-subscribe-show.js.es6 similarity index 97% rename from assets/javascripts/discourse/controllers/patrons-subscribe-show.js.es6 rename to assets/javascripts/discourse/controllers/s-subscribe-show.js.es6 index 50af763..08d1483 100644 --- a/assets/javascripts/discourse/controllers/patrons-subscribe-show.js.es6 +++ b/assets/javascripts/discourse/controllers/s-subscribe-show.js.es6 @@ -25,7 +25,7 @@ export default Ember.Controller.extend({ source: result.token.id }; - return ajax("/patrons/customers", { + return ajax("/s/customers", { method: "post", data: customerData }).then(customer => { diff --git a/assets/javascripts/discourse/controllers/patrons.js.es6 b/assets/javascripts/discourse/controllers/s.js.es6 similarity index 100% rename from assets/javascripts/discourse/controllers/patrons.js.es6 rename to assets/javascripts/discourse/controllers/s.js.es6 diff --git a/assets/javascripts/discourse/models/admin-plan.js.es6 b/assets/javascripts/discourse/models/admin-plan.js.es6 index c76c753..72fd1e2 100644 --- a/assets/javascripts/discourse/models/admin-plan.js.es6 +++ b/assets/javascripts/discourse/models/admin-plan.js.es6 @@ -20,7 +20,7 @@ const AdminPlan = Plan.extend({ }, destroy() { - return ajax(`/patrons/admin/plans/${this.id}`, { method: "delete" }); + return ajax(`/s/admin/plans/${this.id}`, { method: "delete" }); }, save() { @@ -35,7 +35,7 @@ const AdminPlan = Plan.extend({ active: this.active }; - return ajax("/patrons/admin/plans", { method: "post", data }); + return ajax("/s/admin/plans", { method: "post", data }); }, update() { @@ -46,19 +46,19 @@ const AdminPlan = Plan.extend({ active: this.active }; - return ajax(`/patrons/admin/plans/${this.id}`, { method: "patch", data }); + return ajax(`/s/admin/plans/${this.id}`, { method: "patch", data }); } }); AdminPlan.reopenClass({ findAll(data) { - return ajax("/patrons/admin/plans", { method: "get", data }).then(result => + return ajax("/s/admin/plans", { method: "get", data }).then(result => result.map(plan => AdminPlan.create(plan)) ); }, find(id) { - return ajax(`/patrons/admin/plans/${id}`, { method: "get" }).then(plan => + return ajax(`/s/admin/plans/${id}`, { method: "get" }).then(plan => AdminPlan.create(plan) ); } diff --git a/assets/javascripts/discourse/models/admin-product.js.es6 b/assets/javascripts/discourse/models/admin-product.js.es6 index 8b92f03..0c00bba 100644 --- a/assets/javascripts/discourse/models/admin-product.js.es6 +++ b/assets/javascripts/discourse/models/admin-product.js.es6 @@ -5,7 +5,7 @@ const AdminProduct = Discourse.Model.extend({ metadata: {}, destroy() { - return ajax(`/patrons/admin/products/${this.id}`, { method: "delete" }); + return ajax(`/s/admin/products/${this.id}`, { method: "delete" }); }, save() { @@ -16,7 +16,7 @@ const AdminProduct = Discourse.Model.extend({ active: this.active }; - return ajax("/patrons/admin/products", { + return ajax("/s/admin/products", { method: "post", data }).then(product => AdminProduct.create(product)); @@ -30,7 +30,7 @@ const AdminProduct = Discourse.Model.extend({ active: this.active }; - return ajax(`/patrons/admin/products/${this.id}`, { + return ajax(`/s/admin/products/${this.id}`, { method: "patch", data }); @@ -39,13 +39,13 @@ const AdminProduct = Discourse.Model.extend({ AdminProduct.reopenClass({ findAll() { - return ajax("/patrons/admin/products", { method: "get" }).then(result => + return ajax("/s/admin/products", { method: "get" }).then(result => result.map(product => AdminProduct.create(product)) ); }, find(id) { - return ajax(`/patrons/admin/products/${id}`, { + return ajax(`/s/admin/products/${id}`, { method: "get" }).then(product => AdminProduct.create(product)); } diff --git a/assets/javascripts/discourse/models/admin-subscription.js.es6 b/assets/javascripts/discourse/models/admin-subscription.js.es6 index e6d196a..78e6f02 100644 --- a/assets/javascripts/discourse/models/admin-subscription.js.es6 +++ b/assets/javascripts/discourse/models/admin-subscription.js.es6 @@ -20,7 +20,7 @@ const AdminSubscription = Discourse.Model.extend({ }, destroy() { - return ajax(`/patrons/admin/subscriptions/${this.id}`, { + return ajax(`/s/admin/subscriptions/${this.id}`, { method: "delete" }).then(result => AdminSubscription.create(result)); } @@ -28,7 +28,7 @@ const AdminSubscription = Discourse.Model.extend({ AdminSubscription.reopenClass({ find() { - return ajax("/patrons/admin/subscriptions", { + return ajax("/s/admin/subscriptions", { method: "get" }).then(result => result.data.map(subscription => AdminSubscription.create(subscription)) diff --git a/assets/javascripts/discourse/models/invoice.js.es6 b/assets/javascripts/discourse/models/invoice.js.es6 index 65e017f..5b1a97f 100644 --- a/assets/javascripts/discourse/models/invoice.js.es6 +++ b/assets/javascripts/discourse/models/invoice.js.es6 @@ -4,7 +4,7 @@ const Invoice = Discourse.Model.extend({}); Invoice.reopenClass({ findAll() { - return ajax("/patrons/invoices", { method: "get" }).then(result => + return ajax("/s/invoices", { method: "get" }).then(result => result.map(invoice => Invoice.create(invoice)) ); } diff --git a/assets/javascripts/discourse/models/plan.js.es6 b/assets/javascripts/discourse/models/plan.js.es6 index dac6f16..5f94a6a 100644 --- a/assets/javascripts/discourse/models/plan.js.es6 +++ b/assets/javascripts/discourse/models/plan.js.es6 @@ -21,7 +21,7 @@ const Plan = Discourse.Model.extend({ Plan.reopenClass({ findAll(data) { - return ajax("/patrons/plans", { method: "get", data }).then(result => + return ajax("/s/plans", { method: "get", data }).then(result => result.map(plan => Plan.create(plan)) ); } diff --git a/assets/javascripts/discourse/models/product.js.es6 b/assets/javascripts/discourse/models/product.js.es6 index 6792e43..b3e8ff7 100644 --- a/assets/javascripts/discourse/models/product.js.es6 +++ b/assets/javascripts/discourse/models/product.js.es6 @@ -4,13 +4,13 @@ const Product = Discourse.Model.extend({}); Product.reopenClass({ findAll() { - return ajax("/patrons/products", { method: "get" }).then(result => + return ajax("/s/products", { method: "get" }).then(result => result.map(product => Product.create(product)) ); }, find(id) { - return ajax(`/patrons/products/${id}`, { method: "get" }).then(product => + return ajax(`/s/products/${id}`, { method: "get" }).then(product => Product.create(product) ); } diff --git a/assets/javascripts/discourse/models/subscription.js.es6 b/assets/javascripts/discourse/models/subscription.js.es6 index 41faddb..9b91645 100644 --- a/assets/javascripts/discourse/models/subscription.js.es6 +++ b/assets/javascripts/discourse/models/subscription.js.es6 @@ -13,13 +13,13 @@ const Subscription = Discourse.Model.extend({ plan: this.plan }; - return ajax("/patrons/subscriptions", { method: "post", data }); + return ajax("/s/subscriptions", { method: "post", data }); } }); Subscription.reopenClass({ findAll() { - return ajax("/patrons/subscriptions", { method: "get" }).then(result => + return ajax("/s/subscriptions", { method: "get" }).then(result => result.map(subscription => Subscription.create(subscription)) ); } diff --git a/assets/javascripts/discourse/models/user-subscription.js.es6 b/assets/javascripts/discourse/models/user-subscription.js.es6 index 936e63e..5900a6f 100644 --- a/assets/javascripts/discourse/models/user-subscription.js.es6 +++ b/assets/javascripts/discourse/models/user-subscription.js.es6 @@ -9,7 +9,7 @@ const UserSubscription = Discourse.Model.extend({ }, destroy() { - return ajax(`/patrons/user/subscriptions/${this.id}`, { + return ajax(`/s/user/subscriptions/${this.id}`, { method: "delete" }).then(result => UserSubscription.create(result)); } @@ -17,7 +17,7 @@ const UserSubscription = Discourse.Model.extend({ UserSubscription.reopenClass({ findAll() { - return ajax("/patrons/user/subscriptions", { method: "get" }).then(result => + return ajax("/s/user/subscriptions", { method: "get" }).then(result => result.map(subscription => { subscription.plan = Plan.create(subscription.plan); return UserSubscription.create(subscription); diff --git a/assets/javascripts/discourse/patrons-route-map.js.es6 b/assets/javascripts/discourse/patrons-route-map.js.es6 index 566c954..e7496fe 100644 --- a/assets/javascripts/discourse/patrons-route-map.js.es6 +++ b/assets/javascripts/discourse/patrons-route-map.js.es6 @@ -1,5 +1,5 @@ export default function() { - this.route("patrons", function() { + this.route("s", function() { this.route("subscribe", function() { this.route("show", { path: "/:subscription-id" }); }); diff --git a/assets/javascripts/discourse/routes/patrons-subscribe-show.js.es6 b/assets/javascripts/discourse/routes/s-subscribe-show.js.es6 similarity index 100% rename from assets/javascripts/discourse/routes/patrons-subscribe-show.js.es6 rename to assets/javascripts/discourse/routes/s-subscribe-show.js.es6 diff --git a/assets/javascripts/discourse/routes/patrons-subscribe.js.es6 b/assets/javascripts/discourse/routes/s-subscribe.js.es6 similarity index 100% rename from assets/javascripts/discourse/routes/patrons-subscribe.js.es6 rename to assets/javascripts/discourse/routes/s-subscribe.js.es6 diff --git a/assets/javascripts/discourse/routes/patrons.js.es6 b/assets/javascripts/discourse/routes/s.js.es6 similarity index 92% rename from assets/javascripts/discourse/routes/patrons.js.es6 rename to assets/javascripts/discourse/routes/s.js.es6 index ceadd0e..29d9224 100644 --- a/assets/javascripts/discourse/routes/patrons.js.es6 +++ b/assets/javascripts/discourse/routes/s.js.es6 @@ -8,7 +8,7 @@ export default Discourse.Route.extend({ phone: "" }); - return ajax("/patrons", { + return ajax("/s", { method: "get" }) .then(result => { diff --git a/assets/javascripts/discourse/templates/components/product-list.hbs b/assets/javascripts/discourse/templates/components/product-list.hbs index b3a1b1c..50f94c6 100644 --- a/assets/javascripts/discourse/templates/components/product-list.hbs +++ b/assets/javascripts/discourse/templates/components/product-list.hbs @@ -9,7 +9,7 @@ {{#if currentUser}}
- {{#link-to "patrons.subscribe.show" product.id disabled=product.subscribed class="btn btn-primary"}} + {{#link-to "s.subscribe.show" product.id disabled=product.subscribed class="btn btn-primary"}} {{i18n 'discourse_patrons.subscribe.title'}} {{/link-to}}
diff --git a/assets/javascripts/discourse/templates/connectors/extra-nav-item/subscribe.hbs b/assets/javascripts/discourse/templates/connectors/extra-nav-item/subscribe.hbs index b3a03e5..2709b64 100644 --- a/assets/javascripts/discourse/templates/connectors/extra-nav-item/subscribe.hbs +++ b/assets/javascripts/discourse/templates/connectors/extra-nav-item/subscribe.hbs @@ -1,5 +1,5 @@ {{#if (show-extra-nav)}} - {{#link-to 'patrons.subscribe' class='discourse-patrons-subscribe'}} + {{#link-to 's.subscribe' class='discourse-patrons-subscribe'}} {{i18n 'discourse_patrons.navigation.subscribe'}} {{/link-to}} {{/if}} diff --git a/assets/javascripts/discourse/templates/patrons/index.hbs b/assets/javascripts/discourse/templates/s/index.hbs similarity index 100% rename from assets/javascripts/discourse/templates/patrons/index.hbs rename to assets/javascripts/discourse/templates/s/index.hbs diff --git a/assets/javascripts/discourse/templates/patrons/subscribe.hbs b/assets/javascripts/discourse/templates/s/subscribe.hbs similarity index 100% rename from assets/javascripts/discourse/templates/patrons/subscribe.hbs rename to assets/javascripts/discourse/templates/s/subscribe.hbs diff --git a/assets/javascripts/discourse/templates/patrons/subscribe/index.hbs b/assets/javascripts/discourse/templates/s/subscribe/index.hbs similarity index 100% rename from assets/javascripts/discourse/templates/patrons/subscribe/index.hbs rename to assets/javascripts/discourse/templates/s/subscribe/index.hbs diff --git a/assets/javascripts/discourse/templates/patrons/subscribe/show.hbs b/assets/javascripts/discourse/templates/s/subscribe/show.hbs similarity index 100% rename from assets/javascripts/discourse/templates/patrons/subscribe/show.hbs rename to assets/javascripts/discourse/templates/s/subscribe/show.hbs diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 2fe7889..912a46b 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -16,6 +16,7 @@ en: js: discourse_patrons: title: Discourse Subscriptions + admin_navigation: Subscriptions optional: Optional transactions: payment: diff --git a/plugin.rb b/plugin.rb index 53b2e35..cb149d8 100644 --- a/plugin.rb +++ b/plugin.rb @@ -24,7 +24,7 @@ extend_content_security_policy( script_src: ['https://js.stripe.com/v3/'] ) -add_admin_route 'discourse_patrons.title', 'discourse-subscriptions.products' +add_admin_route 'discourse_patrons.admin_navigation', 'discourse-subscriptions.products' Discourse::Application.routes.append do get '/admin/plugins/discourse-subscriptions' => 'admin/plugins#index' @@ -69,6 +69,6 @@ after_initialize do ].each { |path| require File.expand_path(path, __FILE__) } Discourse::Application.routes.append do - mount ::DiscoursePatrons::Engine, at: 'patrons' + mount ::DiscoursePatrons::Engine, at: 's' end end