fix some bug and delete unuse code
This commit is contained in:
parent
44188cb614
commit
c47f65def8
|
@ -111,7 +111,7 @@ class Admin::PatchfilesController < OrbitAdminController
|
|||
end
|
||||
redirect_to admin_patchfiles_editckeditor_path and return
|
||||
else
|
||||
params["patchfilefield"]["new_add_font"] = params["patchfilefield"]["new_add_font"].gsub('\"','').gsub("\'",'').gsub(";",'')
|
||||
params["patchfilefield"]["new_add_font"] = params["patchfilefield"]["new_add_font"].gsub('\"','').gsub("\'",'').gsub(";",'').gsub('\\','')
|
||||
@field.new_add_font = params["patchfilefield"]["new_add_font"] rescue (redirect_to admin_patchfiles_showckeditor_path and return)
|
||||
@key_arr = @field.font_array.keys
|
||||
params["patchfilefield"]["font_array"] = {} if params["patchfilefield"]["font_array"].nil? == true
|
||||
|
|
|
@ -10,7 +10,6 @@ class Fontfile
|
|||
field :title ,type:String ,default:""
|
||||
field :is_delete_font_file, type:String,default: 'false'
|
||||
field :old_title ,type:String ,default:""
|
||||
#field :font_file ,type:String ,default:""
|
||||
field :font_link ,type:String ,default:""
|
||||
field :old_font_link ,type:String ,default:""
|
||||
mount_uploader :font_file, AssetUploader
|
||||
|
@ -20,14 +19,7 @@ class Fontfile
|
|||
field :old_font_dir, type:String ,default:""
|
||||
scope :can_display, ->{where(:is_hidden=>false,:is_preview => false).any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}).order_by([:is_top, :desc],[:postdate, :desc])}
|
||||
scope :is_approved, ->{where(:approved => true)}
|
||||
#has_many :filefields, :autosave => true, :dependent => :destroy
|
||||
# accepts_nested_attributes_for :filefields, :allow_destroy => true
|
||||
# before_create
|
||||
#before_update :set_old_link#,:set_old_title
|
||||
#before_save :set_old_title
|
||||
#before_create :set_expire
|
||||
after_update :change_font_name,:set_css_link,:change_font_settings
|
||||
#after_save :change_font_name
|
||||
def change_font_settings
|
||||
if self.old_font_file_name == self.font_file_name && self.is_delete_font_file =='true'
|
||||
self.font_file_name = ""
|
||||
|
@ -63,7 +55,8 @@ class Fontfile
|
|||
@filetowrite.write(@file_content)
|
||||
@filetowrite.close
|
||||
end
|
||||
elsif self.old_font_link != ""&& self.old_font_link != self.font_link
|
||||
end
|
||||
if self.old_font_link != ""&& self.old_font_link != self.font_link
|
||||
@font_link_str = "<link href=\'"+"#{self.old_font_link}"+"\' rel=\'stylesheet\'>"
|
||||
if @file_content.include? @font_link_str
|
||||
@file_content = @file_content.gsub(@font_link_str,'')
|
||||
|
@ -127,7 +120,8 @@ class Fontfile
|
|||
f.puts @font_link_str
|
||||
}
|
||||
end
|
||||
elsif self.font_link != ""
|
||||
end
|
||||
if self.font_link != ""
|
||||
@font_link_str = "<link href=\'"+"#{self.font_link}"+"\' rel=\'stylesheet\'>"
|
||||
@str_to_search = self.font_link.to_s
|
||||
if @file_content.include? @str_to_search
|
||||
|
|
|
@ -186,6 +186,7 @@ class Patchfilefield
|
|||
@ckeditor_path = ENV['PWD'] + '/app/assets/javascripts/ckeditor'
|
||||
Dir.chdir(@ckeditor_path)
|
||||
if !File.file?("config_back.js.erb")
|
||||
if @str_end != nil
|
||||
@filetowrite = File.new("config_back.js.erb","w")
|
||||
if @add_font_array != []
|
||||
@add_font_array.each do |new_add_font|
|
||||
|
@ -194,7 +195,7 @@ class Patchfilefield
|
|||
end
|
||||
@delete_font_array.each do |font_to_delete|
|
||||
if @filedata.index(font_to_delete) != nil
|
||||
@str_above_end = @filedata.index(font_to_delete) - 1
|
||||
@str_above_end = @filedata.index(font_to_delete).to_i - 1
|
||||
@str_above_start
|
||||
for @str_above_start in (0..@str_above_end).to_a.reverse
|
||||
if @filedata[@str_above_start] =="\'" || @filedata[@str_above_start] =="\""
|
||||
|
@ -202,8 +203,13 @@ class Patchfilefield
|
|||
end
|
||||
break if @filedata[@str_above_start] == "\;"
|
||||
end
|
||||
@str_above_start = @str_above_end - 1 if @str_above_start == nil
|
||||
@str_to_delete = (( @filedata[@str_above_start..@str_above_end].include? "\;") ? @filedata[@str_above_start..@str_above_end] : "")+font_to_delete
|
||||
@filedata =@filedata.sub(@str_to_delete,"")
|
||||
@name_to_search ="config.font_names"
|
||||
@index_of_font = @filedata.index(@name_to_search)
|
||||
@datachange = @filedata[@index_of_font...@str_end]
|
||||
@new_datachange = @datachange.sub(@str_to_delete,'')
|
||||
@filedata =@filedata.sub(@datachange,@new_datachange)
|
||||
for @i in @str_start+1...@str_end
|
||||
next if @filedata[@i] == " "
|
||||
break if @filedata[@i] != "\;"
|
||||
|
@ -219,6 +225,7 @@ class Patchfilefield
|
|||
@filetocover.write(@filedata)
|
||||
@filetocover.close
|
||||
File.delete("config_back.js.erb")
|
||||
end
|
||||
else
|
||||
@filedata1 = File.read("config.js.erb")
|
||||
@filedata2 = File.read("config_back.js.erb")
|
||||
|
|
Loading…
Reference in New Issue