diff --git a/app/views/locomotive/pages/edit.html.haml b/app/views/locomotive/pages/edit.html.haml
index abb0f89a..15f23196 100644
--- a/app/views/locomotive/pages/edit.html.haml
+++ b/app/views/locomotive/pages/edit.html.haml
@@ -7,7 +7,7 @@
= render 'locomotive/shared/actions/contents'
- content_for :buttons do
- = local_action_button :show, "/#{@page.fullpath}", :class => 'show'
+ = local_action_button :show, current_site_public_url + '/' + @page.fullpath, :class => 'show'
%p!= t('.help')
@@ -15,4 +15,4 @@
= render 'form', :f => form
- = render 'locomotive/shared/form_actions', :back_url => pages_url, :button_label => :update
\ No newline at end of file
+ = render 'locomotive/shared/form_actions', :back_url => pages_url, :button_label => :update
diff --git a/lib/locomotive.rb b/lib/locomotive.rb
index efe3674d..1dfc4925 100644
--- a/lib/locomotive.rb
+++ b/lib/locomotive.rb
@@ -126,6 +126,15 @@ module Locomotive
Rails.application.routes.named_routes[:locomotive].path.spec.to_s
end
+ def self.url_for(path)
+ result = path
+ if config.base_uri
+ result = "#{config.base_uri}/#{path.gsub(%r{^/}, '')}"
+ end
+ result = "/#{result}" if result[0..0] != '/'
+ result
+ end
+
protected
def self.app_middleware
diff --git a/lib/locomotive/action_controller/url_helpers.rb b/lib/locomotive/action_controller/url_helpers.rb
index 03707b43..866bf020 100644
--- a/lib/locomotive/action_controller/url_helpers.rb
+++ b/lib/locomotive/action_controller/url_helpers.rb
@@ -9,7 +9,7 @@ module Locomotive
end
def current_site_public_url
- request.protocol + request.host_with_port
+ request.protocol + request.host_with_port + (Locomotive.config.base_uri || '')
end
def switch_to_site_url(site, options = {})
@@ -34,4 +34,4 @@ module Locomotive
end
end
-end
\ No newline at end of file
+end
diff --git a/lib/locomotive/configuration.rb b/lib/locomotive/configuration.rb
index 9d7fbf76..392adc5a 100644
--- a/lib/locomotive/configuration.rb
+++ b/lib/locomotive/configuration.rb
@@ -13,6 +13,7 @@ module Locomotive
:enable_logs => false,
:delayed_job => false,
:default_locale => :en,
+ :base_uri => nil,
:mailer_sender => 'support@example.com',
:manage_subdomain => false,
:manage_manage_domains => false,