From 9fcf8280fa05feafe7e8f7ffb76006c013c96f78 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Tue, 24 Jan 2012 11:36:24 +0800 Subject: [PATCH] Change "_filename" to "_identifier" for carrierwave --- app/controllers/admin/designs_controller.rb | 8 ++++---- app/controllers/admin/purchases_controller.rb | 2 +- app/models/design/design.rb | 6 +++--- app/models/design/stylesheet.rb | 4 ++-- app/models/design/theme.rb | 2 +- app/views/admin/assets/_asset.html.erb | 2 +- app/views/admin/designs/_design_file.html.erb | 4 ++-- lib/parsers/parser_layout.rb | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/controllers/admin/designs_controller.rb b/app/controllers/admin/designs_controller.rb index 5930d1bf..68fbb243 100644 --- a/app/controllers/admin/designs_controller.rb +++ b/app/controllers/admin/designs_controller.rb @@ -46,7 +46,7 @@ class Admin::DesignsController < ApplicationController filename = params[:filename] files = @design.themes + @design.javascripts + @design.images file_to_removed = files.find{ |obj| - obj.file_filename == filename + obj.file_identifier == filename } type = file_to_removed._type new_file = "" @@ -103,7 +103,7 @@ class Admin::DesignsController < ApplicationController temp_file.write (zip_file.read entry ).force_encoding('UTF-8') default_css = design.build_default_css default_css.file = temp_file - default_css.file_filename = filename + default_css.file_identifier = filename default_css.to_save = true when /\A(#{zip_name})\/(reset\.css)\z/ #for reset css filename = File.basename(entry.to_s) @@ -111,7 +111,7 @@ class Admin::DesignsController < ApplicationController temp_file.write (zip_file.read entry ).force_encoding('UTF-8') reset_css = design.build_reset_css reset_css.file = temp_file - reset_css.file_filename = filename + reset_css.file_identifier = filename reset_css.to_save = true when /\A(#{zip_name})\/(layout\.html)\z/ #for layout html filename = File.basename(entry.to_s) @@ -135,7 +135,7 @@ class Admin::DesignsController < ApplicationController temp_file.write (zip_file.read entry).force_encoding('UTF-8') build_and_store = eval("design.#{type}").build build_and_store.file = temp_file - build_and_store.file_filename = filename + build_and_store.file_identifier = filename build_and_store.to_save = true end end diff --git a/app/controllers/admin/purchases_controller.rb b/app/controllers/admin/purchases_controller.rb index 40a042f4..00980cec 100644 --- a/app/controllers/admin/purchases_controller.rb +++ b/app/controllers/admin/purchases_controller.rb @@ -172,7 +172,7 @@ class Admin::PurchasesController < ApplicationController def build_file(orig_zip, zip_name, dir, object, type = nil) - title = object.file_filename + title = object.file_identifier temp = File.new(dir + '/' + title, 'w+') temp.write orig_zip.read(zip_name + '/' + (type ? (type + '/') : '') + title) object.file = temp diff --git a/app/models/design/design.rb b/app/models/design/design.rb index e77f7f0f..eb1f5e64 100644 --- a/app/models/design/design.rb +++ b/app/models/design/design.rb @@ -31,7 +31,7 @@ class Design def files_with_duplicate? [self.javascripts, self.images,self.themes].each do |objects_hash| - ary = objects_hash.collect{ |k| k.file_filename} + ary = objects_hash.collect{ |k| k.file_identifier} ary.compact! # debugger return true if(ary.count!=ary.uniq.count) @@ -42,7 +42,7 @@ class Design def files_with_noname? [self.javascripts, self.images,self.themes].each do |objects_hash| objects_hash.each{ |k| - return true if(k.file_filename.nil? && !k.to_save?) + return true if(k.file_identifier.nil? && !k.to_save?) } end false @@ -121,7 +121,7 @@ class Design def process_object(object) if object.to_save - if object.file_filename.nil? + if object.file_identifier.nil? new_object = self.send(object._type.downcase.pluralize).build(object.attributes) new_object.file = object.file object.destroy diff --git a/app/models/design/stylesheet.rb b/app/models/design/stylesheet.rb index f26f1558..13fb154d 100644 --- a/app/models/design/stylesheet.rb +++ b/app/models/design/stylesheet.rb @@ -11,14 +11,14 @@ class Stylesheet < DesignFile 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 + file_name = images.detect{ |i| i.file_identifier.eql?(name) }.file_url rescue nil names << [css_name, file_name] } names.each do |name| content.gsub!(name[0], name[1]) if name[1] end Dir.mktmpdir('f_path') { |dir| - orig_file_name = self.file_filename + orig_file_name = self.file_identifier temp_file = File.new(dir + '/' + orig_file_name, 'w+') temp_file.write orig_content.force_encoding("UTF-8") diff --git a/app/models/design/theme.rb b/app/models/design/theme.rb index e6974181..dd4a6b01 100644 --- a/app/models/design/theme.rb +++ b/app/models/design/theme.rb @@ -7,7 +7,7 @@ class Theme < Stylesheet protected def set_name - self.name = File.basename(self.file_filename,".css") + self.name = File.basename(self.file_identifier,".css") end end diff --git a/app/views/admin/assets/_asset.html.erb b/app/views/admin/assets/_asset.html.erb index 7aad2ef8..ea71dc6c 100644 --- a/app/views/admin/assets/_asset.html.erb +++ b/app/views/admin/assets/_asset.html.erb @@ -5,7 +5,7 @@ <%= asset.description %> <%= asset.data.file.content_type %> - <%= asset.data_filename %> + <%= asset.data_identifier %> <%= number_to_human_size(asset.data.file.file_length) %> <%= link_to t(:edit), edit_admin_asset_path(asset), :remote => true, :class => 'edit' %> diff --git a/app/views/admin/designs/_design_file.html.erb b/app/views/admin/designs/_design_file.html.erb index c2945069..9e494552 100644 --- a/app/views/admin/designs/_design_file.html.erb +++ b/app/views/admin/designs/_design_file.html.erb @@ -1,8 +1,8 @@ <%= f.label "field_name", t('admin.' + field_name) %>