From d22d53075ecb940fdb59cd980ab8f86e40498c35 Mon Sep 17 00:00:00 2001 From: Marc Florisson Date: Thu, 6 Sep 2012 12:39:32 +0200 Subject: fix style_map polymorphic_path --- app/maps/style_map/connection_link_style_map.rb | 2 +- app/maps/style_map/generic_style_map.rb | 6 ++++++ app/maps/style_map/journey_pattern_style_map.rb | 4 ++-- app/maps/style_map/route_style_map.rb | 4 ++-- app/maps/style_map/stop_areas_style_map.rb | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/maps/style_map/connection_link_style_map.rb b/app/maps/style_map/connection_link_style_map.rb index 39a8c7fd8..9a0abfebc 100644 --- a/app/maps/style_map/connection_link_style_map.rb +++ b/app/maps/style_map/connection_link_style_map.rb @@ -18,7 +18,7 @@ class StyleMap::ConnectionLinkStyleMap < StyleMap::GenericStyleMap :strokeWidth => 3, :strokeLineCap => "round", :strokeDashstyle => "solid", - :externalGraphic => "/assets/map/${positionType}.png", + :externalGraphic => self.class.polymorphic_path_patch( "map/${positionType}.png"), :graphicWidth => 36, :graphicHeight => 36, :graphicOpacity => 1, diff --git a/app/maps/style_map/generic_style_map.rb b/app/maps/style_map/generic_style_map.rb index c905cd00d..88819650a 100644 --- a/app/maps/style_map/generic_style_map.rb +++ b/app/maps/style_map/generic_style_map.rb @@ -2,4 +2,10 @@ class StyleMap::GenericStyleMap include MapLayers include MapLayers::ViewHelpers + def self.polymorphic_path_patch( source) + + relative_url_root = Rails.application.config.relative_url_root + return "/assets/#{source}" unless relative_url_root + "#{relative_url_root}/assets/#{source}" + end end diff --git a/app/maps/style_map/journey_pattern_style_map.rb b/app/maps/style_map/journey_pattern_style_map.rb index c0d08ba77..9e2550232 100644 --- a/app/maps/style_map/journey_pattern_style_map.rb +++ b/app/maps/style_map/journey_pattern_style_map.rb @@ -6,7 +6,7 @@ class StyleMap::JourneyPatternStyleMap < StyleMap::GenericStyleMap end def select_style - default_style.merge :externalGraphic => "/assets/icons/stop_area_hover.png" + default_style.merge :externalGraphic => self.class.polymorphic_path_patch( "icons/stop_area_hover.png") end def default_style { @@ -22,7 +22,7 @@ class StyleMap::JourneyPatternStyleMap < StyleMap::GenericStyleMap :strokeWidth => 3, :strokeLineCap => "round", :strokeDashstyle => "solid", - :externalGraphic => "/assets/icons/${positionType}.png", + :externalGraphic => self.class.polymorphic_path_patch( "icons/${positionType}.png"), :graphicWidth => 12, :graphicHeight => 12, :graphicOpacity => 1, diff --git a/app/maps/style_map/route_style_map.rb b/app/maps/style_map/route_style_map.rb index 81ed483fb..c791441f4 100644 --- a/app/maps/style_map/route_style_map.rb +++ b/app/maps/style_map/route_style_map.rb @@ -6,7 +6,7 @@ class StyleMap::RouteStyleMap < StyleMap::GenericStyleMap end def select_style - default_style.merge :externalGraphic => "/assets/icons/stop_area_hover.png" + default_style.merge :externalGraphic => self.class.polymorphic_path_patch( "icons/stop_area_hover.png") end def default_style { @@ -22,7 +22,7 @@ class StyleMap::RouteStyleMap < StyleMap::GenericStyleMap :strokeWidth => 3, :strokeLineCap => "round", :strokeDashstyle => "solid", - :externalGraphic => "/assets/icons/${positionType}.png", + :externalGraphic => self.class.polymorphic_path_patch( "icons/${positionType}.png"), :graphicWidth => 12, :graphicHeight => 12, :graphicOpacity => 1, diff --git a/app/maps/style_map/stop_areas_style_map.rb b/app/maps/style_map/stop_areas_style_map.rb index 0b481738c..5bb16af35 100644 --- a/app/maps/style_map/stop_areas_style_map.rb +++ b/app/maps/style_map/stop_areas_style_map.rb @@ -10,7 +10,7 @@ class StyleMap::StopAreasStyleMap < StyleMap::GenericStyleMap :labelXOffset => 0, :labelYOffset => -40, :pointRadius => 1, - :externalGraphic => "/assets/map/${areaType}.png", + :externalGraphic => polymorphic_path_patch( "map/${areaType}.png"), :graphicWidth => 25, :graphicHeight => 25, :graphicOpacity => 1, -- cgit v1.2.3