aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-03-20 22:02:22 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-03-20 22:02:22 +0000
commita61360688cd0e1f43f523866384d0d0796a4ea73 (patch)
treedfa09275f2165b1af8363642b67d85b5702cf793 /actionpack/lib/action_view/helpers
parentee8d110068e958b400987b5f224e14e292fd0558 (diff)
downloadrails-a61360688cd0e1f43f523866384d0d0796a4ea73.tar.gz
rails-a61360688cd0e1f43f523866384d0d0796a4ea73.tar.bz2
rails-a61360688cd0e1f43f523866384d0d0796a4ea73.zip
Changed .htaccess to allow dispatch.* to be called from a sub-directory as part of the push with Action Pack to make Rails work on non-vhost setups #826 [Nicholas Seckar/Tobias Luetke] Fixed routing and helpers to make Rails work on non-vhost setups #826 [Nicholas Seckar/Tobias Luetke]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@945 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb26
1 files changed, 16 insertions, 10 deletions
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index 6328ff6f71..f6159e5246 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -33,8 +33,7 @@ module ActionView
# <script language="JavaScript" type="text/javascript" src="/elsewhere/cools.js"></script>
def javascript_include_tag(*sources)
sources.collect { |source|
- source = "/javascripts/#{source}" unless source.include?("/")
- source = "#{source}.js" unless source.include?(".")
+ source = compute_public_path(source, 'javascripts', 'js')
content_tag("script", "", "language" => "JavaScript", "type" => "text/javascript", "src" => source)
}.join("\n")
end
@@ -49,8 +48,7 @@ module ActionView
# <link href="/css/stylish.css" media="screen" rel="Stylesheet" type="text/css" />
def stylesheet_link_tag(*sources)
sources.collect { |source|
- source = "/stylesheets/#{source}" unless source.include?("/")
- source = "#{source}.css" unless source.include?(".")
+ source = compute_public_path(source, 'stylesheets', 'css')
tag("link", "rel" => "Stylesheet", "type" => "text/css", "media" => "screen", "href" => source)
}.join("\n")
end
@@ -64,13 +62,11 @@ module ActionView
# * full path, like "/my_images/image.gif"
# * file name, like "rss.gif", that gets expanded to "/images/rss.gif"
# * file name without extension, like "logo", that gets expanded to "/images/logo.png"
- def image_tag(src, options = {})
+ def image_tag(source, options = {})
options.symbolize_keys
-
- options.update({ :src => src.include?("/") ? src : "/images/#{src}" })
- options[:src] += ".png" unless options[:src].include?(".")
-
- options[:alt] ||= src.split("/").last.split(".").first.capitalize
+
+ options[:src] = compute_public_path(source, 'images', 'png')
+ options[:alt] ||= source.split("/").last.split(".").first.capitalize
if options[:size]
options[:width], options[:height] = options[:size].split("x")
@@ -79,6 +75,16 @@ module ActionView
tag("img", options)
end
+
+ private
+
+ def compute_public_path(source, dir, ext)
+ source = "/#{dir}/#{source}" unless source.include?("/")
+ source = "#{source}.#{ext}" unless source.include?(".")
+ source = "#{@request.relative_url_root}#{source}"
+ source
+ end
+
end
end
end