From 54f86078f527a493910e90d9dbbe6cb2c1f07909 Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Sat, 20 Sep 2025 18:06:18 -0500 Subject: [PATCH] More accessible, still not good environment based settings --- app/controllers/supplier_controller.rb | 6 +----- app/helpers/application_helper.rb | 5 +---- app/views/dashboard/demo_both.html.slim | 5 +---- config/initializers/mozo_settings.rb | 8 ++++++-- lib/mozo.rb | 5 +++++ 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/app/controllers/supplier_controller.rb b/app/controllers/supplier_controller.rb index a17d86a9..9e8f7a8d 100644 --- a/app/controllers/supplier_controller.rb +++ b/app/controllers/supplier_controller.rb @@ -1,10 +1,6 @@ class SupplierController < Suppliers::ApplicationController def home - if Rails.env.development? - redirect_to "https://localhost:4202/supplier/#{params[:other]}" - else - redirect_to "https://supplier.mozo.bar/supplier/#{params[:other]}" - end + redirect_to "#{Mozo.supplier_url}/#{params[:other]}" end =begin # GET /suppliers/1/active_orders diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a99b9821..07ce1bc1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -6,10 +6,7 @@ module ApplicationHelper end def user_root_path - case Rails.env - when 'development' then 'https://localhost:4201/' - else 'https://user.mozo.bar/' - end + Mozo.user_url end def user_dynamic_data_host diff --git a/app/views/dashboard/demo_both.html.slim b/app/views/dashboard/demo_both.html.slim index 33daa855..ff8f9645 100644 --- a/app/views/dashboard/demo_both.html.slim +++ b/app/views/dashboard/demo_both.html.slim @@ -2,7 +2,4 @@ iframe.phone-content-frame src=user_root_path .tablet-wrapper -- if Rails.env.development? - iframe.tablet-content-frame src="https://localhost:4202/supplier/" -- else - iframe.tablet-content-frame src="https://supplier.mozo.bar/supplier/" +iframe.tablet-content-frame src=Mozo.supplier_url diff --git a/config/initializers/mozo_settings.rb b/config/initializers/mozo_settings.rb index 8c2fda09..9319b046 100644 --- a/config/initializers/mozo_settings.rb +++ b/config/initializers/mozo_settings.rb @@ -1,7 +1,11 @@ if Rails.env.development? - Mozo.event_host = "http://localhost:9296/faye" + Mozo.event_host = 'http://localhost:9296/faye' + Mozo.supplier_url = 'https://localhost:4202/supplier' + Mozo.user_url = 'https://localhost:4201' else - Mozo.event_host = "https://events.mozo.bar/faye" + Mozo.event_host = "https://events.mozo.bar/faye" + Mozo.supplier_url = "https://supplier.mozo.bar/supplier" + Mozo.user_url = 'https://user.mozo.bar' end Mozo.broadcaster = Mozo::Broadcaster::Faye.new diff --git a/lib/mozo.rb b/lib/mozo.rb index 391fe77b..af986779 100644 --- a/lib/mozo.rb +++ b/lib/mozo.rb @@ -1,6 +1,11 @@ module Mozo + # Settings handled in config/initializers/mozo_settings.rb mattr_accessor :event_host mattr_accessor :broadcaster + mattr_accessor :supplier_url + mattr_accessor :user_url + + # Autoloading extend ActiveSupport::Autoload autoload :Distribution autoload :Serializer