Change "_filename" to "_identifier" for carrierwave

This commit is contained in:
Christophe Vilayphiou 2012-01-24 11:36:24 +08:00
parent 5518ae362d
commit 9fcf8280fa
8 changed files with 15 additions and 15 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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")

View File

@ -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

View File

@ -5,7 +5,7 @@
</td>
<td><%= asset.description %></td>
<td><%= asset.data.file.content_type %></td>
<td><%= asset.data_filename %></td>
<td><%= asset.data_identifier %></td>
<td><%= number_to_human_size(asset.data.file.file_length) %></td>
<td class="action">
<%= link_to t(:edit), edit_admin_asset_path(asset), :remote => true, :class => 'edit' %>

View File

@ -1,8 +1,8 @@
<%= f.label "field_name", t('admin.' + field_name) %>
<ul>
<% object.send(field_name).each do |t| %>
<li class="<%= classes %>" <%="path='#{t.file.url}' filename='#{t.file_filename}'" %> >
<%= t.file_filename %>
<li class="<%= classes %>" <%="path='#{t.file.url}' filename='#{t.file_identifier}'" %> >
<%= t.file_identifier %>
<% if classes.include?('r_destroy') %>
<%= fields_for "design[" + field_name + "][]", t, :index => nil do |f| %>
<%= f.hidden_field :id %>

View File

@ -27,7 +27,7 @@ module ParserLayout
layout.layout_parts.create(:name => tag.attr['name'], :editable => true)
end
c.define_tag 'image' do |tag|
image = layout.design.images.detect{ |i| i.file_filename.eql?(parse_html_image(tag.expand)) }
image = layout.design.images.detect{ |i| i.file_identifier.eql?(parse_html_image(tag.expand)) }
image.update_attributes(:name => tag.attr['name'], :html_id => tag.attr['id'], :html_class => tag.attr['class'])
end
end