From b2c0047d0f3ec672fc571091aadf639369dd0d69 Mon Sep 17 00:00:00 2001 From: chris2tof Date: Fri, 2 Sep 2011 19:19:34 +0800 Subject: [PATCH] Modification in parse_urls in both layout.rb and theme.rb --- app/models/design/layout.rb | 9 ++++++--- app/models/design/theme.rb | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/models/design/layout.rb b/app/models/design/layout.rb index 729153df..c8436db6 100644 --- a/app/models/design/layout.rb +++ b/app/models/design/layout.rb @@ -29,9 +29,12 @@ class Layout < DesignFile self.remove_file_orig! names = [] images = self.design.images - content.scan(/(?<=\)/){ - html_name = $1 - name = File.basename(html_name).gsub(/[\\\"]/, '').strip + html_name = nil + content.scan(/(?<=\)/){ + $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 names << [html_name, file_name] } diff --git a/app/models/design/theme.rb b/app/models/design/theme.rb index 612f4fbd..756b7e12 100644 --- a/app/models/design/theme.rb +++ b/app/models/design/theme.rb @@ -11,9 +11,9 @@ class Theme < Stylesheet self.remove_file_orig! names = [] images = self.design.images - content.scan(/(?<=url\()(.*?)(?=\))/){ - css_name = $1 - name = File.basename(css_name).gsub(/[\\\"]/, '').strip + content.scan(/(?<=url)(.*?)(?=\))/){ + css_name = $1.gsub(' ','').gsub('(','') + name = File.basename(css_name).gsub(/[\\\"]/, '') file_name = images.detect{ |i| i.file_filename.eql?(name) }.file_url rescue nil names << [css_name, file_name] }