fix bundle_fu to handle relative roots

applied pending patches from bundle_fu issues 3 and 6
reverted previous workaround in standard.css for relative roots
This commit is contained in:
Reinier Balt 2009-02-07 20:09:09 +01:00
parent d41c369f09
commit 48fb00b24e
3 changed files with 38 additions and 31 deletions

View file

@ -76,31 +76,31 @@ h3 {
/* Rules for the icon links */ /* Rules for the icon links */
img.edit_item {background-image: url(../images/edit_off.png); background-repeat: no-repeat; border: none;} img.edit_item {background-image: url(/images/edit_off.png); background-repeat: no-repeat; border: none;}
a:hover img.edit_item {background-image: url(../images/edit_on.png); background-color: transparent; background-repeat: no-repeat; border: none;} a:hover img.edit_item {background-image: url(/images/edit_on.png); background-color: transparent; background-repeat: no-repeat; border: none;}
img.delete_item {background-image: url(../images/delete_off.png); background-repeat: no-repeat; border: none;} img.delete_item {background-image: url(/images/delete_off.png); background-repeat: no-repeat; border: none;}
a:hover img.delete_item {background-image: url(../images/delete_on.png);background-color: transparent;background-repeat: no-repeat; border: none;} a:hover img.delete_item {background-image: url(/images/delete_on.png);background-color: transparent;background-repeat: no-repeat; border: none;}
img.starred_todo {background-image: url(../images/staricons.png); background-repeat: no-repeat; border:none; background-position: 0px 0px;} img.starred_todo {background-image: url(/images/staricons.png); background-repeat: no-repeat; border:none; background-position: 0px 0px;}
a:hover img.starred_todo {background-image: url(../images/staricons.png); background-repeat: no-repeat; border:none; background-position: -16px 0px;} a:hover img.starred_todo {background-image: url(/images/staricons.png); background-repeat: no-repeat; border:none; background-position: -16px 0px;}
img.unstarred_todo {background-image: url(../images/staricons.png); background-repeat: no-repeat; border:none; background-position: -32px 0px;} img.unstarred_todo {background-image: url(/images/staricons.png); background-repeat: no-repeat; border:none; background-position: -32px 0px;}
a:hover img.unstarred_todo {background-image: url(../images/staricons.png); background-repeat: no-repeat; border:none; background-position: -48px 0px;} a:hover img.unstarred_todo {background-image: url(/images/staricons.png); background-repeat: no-repeat; border:none; background-position: -48px 0px;}
a.to_top {background: transparent url(../images/top_off.png) no-repeat;} a.to_top {background: transparent url(/images/top_off.png) no-repeat;}
a.to_top:hover {background: transparent url(../images/top_on.png) no-repeat;} a.to_top:hover {background: transparent url(/images/top_on.png) no-repeat;}
a.up {background: transparent url(../images/up_off.png) no-repeat;} a.up {background: transparent url(/images/up_off.png) no-repeat;}
a.up:hover {background: transparent url(../images/up_on.png) no-repeat;} a.up:hover {background: transparent url(/images/up_on.png) no-repeat;}
a.down {background: transparent url(../images/down_off.png) no-repeat;} a.down {background: transparent url(/images/down_off.png) no-repeat;}
a.down:hover {background: transparent url(../images/down_on.png) no-repeat;} a.down:hover {background: transparent url(/images/down_on.png) no-repeat;}
a.to_bottom {background: transparent url(../images/bottom_off.png) no-repeat;} a.to_bottom {background: transparent url(/images/bottom_off.png) no-repeat;}
a.to_bottom:hover {background: transparent url(../images/bottom_on.png) no-repeat;} a.to_bottom:hover {background: transparent url(/images/bottom_on.png) no-repeat;}
a.show_notes, a.link_to_notes {background-image: url(../images/notes_off.png); background-repeat: no-repeat; padding: 1px; background-color: transparent;} a.show_notes, a.link_to_notes {background-image: url(/images/notes_off.png); background-repeat: no-repeat; padding: 1px; background-color: transparent;}
a.show_notes:hover, a.link_to_notes:hover {background-image: url(../images/notes_on.png); background-repeat: no-repeat; padding: 1px; background-color: transparent;} a.show_notes:hover, a.link_to_notes:hover {background-image: url(/images/notes_on.png); background-repeat: no-repeat; padding: 1px; background-color: transparent;}
/* Structural divs */ /* Structural divs */
@ -180,7 +180,7 @@ a.show_notes:hover, a.link_to_notes:hover {background-image: url(../images/notes
height: 100%; height: 100%;
z-index: 102; z-index: 102;
text-align: center; text-align: center;
background-image:url("../images/trans70.png"); background-image:url("/images/trans70.png");
} }
#overlay #new-recurring-todo, #overlay #edit-recurring-todo { #overlay #new-recurring-todo, #overlay #edit-recurring-todo {
@ -997,7 +997,7 @@ ul#prefs {list-style-type: disc; margin-left: 15px;}
font-style:oblique; font-style:oblique;
} }
input.open_id { input.open_id {
background: url(../images/open-id-login-bg.gif) no-repeat; background: url(/images/open-id-login-bg.gif) no-repeat;
background-color: #fff; background-color: #fff;
background-position: 0 50%; background-position: 0 50%;
color: #000; color: #000;
@ -1146,28 +1146,28 @@ button.positive, .widgets a.positive{
color:#fff; color:#fff;
} }
.tracks__waiting { .tracks__waiting {
background-image:url('../images/waiting.gif'); background-image:url('/images/waiting.gif');
background-repeat:no-repeat; background-repeat:no-repeat;
background-position:center center; background-position:center center;
background-color:white; background-color:white;
} }
.bigWaiting { .bigWaiting {
background-image:url('../images/bigWaiting.gif'); background-image:url('/images/bigWaiting.gif');
background-repeat:no-repeat; background-repeat:no-repeat;
background-position:center 20%; background-position:center 20%;
background-color:white; background-color:white;
} }
.blackWaiting { .blackWaiting {
background-image:url('../images/blackWaiting.gif'); background-image:url('/images/blackWaiting.gif');
background-repeat:no-repeat; background-repeat:no-repeat;
background-position:center center; background-position:center center;
background-color:black; background-color:black;
} }
.bigBlackWaiting { .bigBlackWaiting {
background-image:url('../images/bigBlackWaiting.gif'); background-image:url('/images/bigBlackWaiting.gif');
background-repeat:no-repeat; background-repeat:no-repeat;
background-position:center center; background-position:center center;
background-color:black; background-color:black;

View file

@ -9,10 +9,11 @@ class BundleFu
def bundle_files(filenames=[]) def bundle_files(filenames=[])
output = "" output = ""
filenames.each{ |filename| filenames.each{ |filename|
output << "/* --------- #{filename} --------- */ " filename_no_root = filename.sub(/^#{ActionController::Base.relative_url_root}/, '')
output << "/* --------- #{filename} - #{filename_no_root} --- ------ */ "
output << "\n" output << "\n"
begin begin
content = (File.read(File.join(RAILS_ROOT, "public", filename))) content = (File.read(File.join(RAILS_ROOT, "public", filename_no_root)))
rescue rescue
output << "/* FILE READ ERROR! */" output << "/* FILE READ ERROR! */"
next next

View file

@ -1,11 +1,15 @@
class BundleFu::CSSUrlRewriter class BundleFu::CSSUrlRewriter
class << self class << self
# rewrites a relative path to an absolute path, removing excess "../" and "./" # rewrites a relative path to an absolute path, removing excess "../" and "./"
# rewrite_relative_path("stylesheets/default/global.css", "../image.gif") => "/stylesheets/image.gif" # rewrite_relative_path("stylesheets/default/global.css", "../image.gif") => "#{rails_relative_root}/stylesheets/image.gif"
def rewrite_relative_path(source_filename, relative_url) def rewrite_relative_path(source_filename, relative_url)
relative_url = relative_url.to_s.strip.gsub(/["']/, "") relative_url = relative_url.to_s.strip.gsub(/["']/, "")
return relative_url if relative_url.first == "/" || relative_url.include?("://") return relative_url if relative_url.include?("://")
if ( relative_url.first == "/" )
return relative_url unless ActionController::Base.relative_url_root
return "#{ActionController::Base.relative_url_root}#{relative_url}"
end
elements = File.join("/", File.dirname(source_filename)).gsub(/\/+/, '/').split("/") elements = File.join("/", File.dirname(source_filename)).gsub(/\/+/, '/').split("/")
elements += relative_url.gsub(/\/+/, '/').split("/") elements += relative_url.gsub(/\/+/, '/').split("/")
@ -24,7 +28,9 @@ class BundleFu::CSSUrlRewriter
end end
end end
elements * "/" path = elements * "/"
return path unless ActionController::Base.relative_url_root
"#{ActionController::Base.relative_url_root}#{path}"
end end
# rewrite the URL reference paths # rewrite the URL reference paths