Modification in parse_urls in both layout.rb and theme.rb

This commit is contained in:
chris2tof 2011-09-02 19:19:34 +08:00
parent 25355e9c7f
commit b2c0047d0f
2 changed files with 9 additions and 6 deletions

View File

@ -29,9 +29,12 @@ class Layout < DesignFile
self.remove_file_orig! self.remove_file_orig!
names = [] names = []
images = self.design.images images = self.design.images
content.scan(/(?<=\<img src=)(.*?)(?=[ \t]|\/\>)/){ html_name = nil
html_name = $1 content.scan(/(?<=\<img)(.*?)(?=\/\>)/){
name = File.basename(html_name).gsub(/[\\\"]/, '').strip $1.gsub(' ','').scan(/(?<=src=\")(.*?)(?=\")/){
html_name = $1
}
name = File.basename(html_name).gsub(/[\\\"]/, '')
file_name = images.detect{ |i| i.file_filename.eql?(name) }.file_url rescue nil file_name = images.detect{ |i| i.file_filename.eql?(name) }.file_url rescue nil
names << [html_name, file_name] names << [html_name, file_name]
} }

View File

@ -11,9 +11,9 @@ class Theme < Stylesheet
self.remove_file_orig! self.remove_file_orig!
names = [] names = []
images = self.design.images images = self.design.images
content.scan(/(?<=url\()(.*?)(?=\))/){ content.scan(/(?<=url)(.*?)(?=\))/){
css_name = $1 css_name = $1.gsub(' ','').gsub('(','')
name = File.basename(css_name).gsub(/[\\\"]/, '').strip name = File.basename(css_name).gsub(/[\\\"]/, '')
file_name = images.detect{ |i| i.file_filename.eql?(name) }.file_url rescue nil file_name = images.detect{ |i| i.file_filename.eql?(name) }.file_url rescue nil
names << [css_name, file_name] names << [css_name, file_name]
} }