Fix bug that update orbit kernel will delete the fonts change in ckeditor.

This commit is contained in:
bohung committed 2021-06-23 23:00:04 +08:00
1 parent f1df8a5329
commit 20ef6e26d3
2 files changed
+25 -100

No files matched your search

+19 -43
View File
@@ -116,16 +116,16 @@ class Admin::PatchfilesController < OrbitAdminController
@file_name = @file.original_filename
@file_content = @file.read
@file_content.force_encoding('UTF-8')
Dir.chdir(@file_path)
@filetowrite
if !File.file?(@file_name)
@filetowrite = File.new(@file_name,"w")
else
@filetowrite = File.open(@file_name,"w")
Dir.chdir(@file_path) do
@filetowrite
if !File.file?(@file_name)
@filetowrite = File.new(@file_name,"w")
else
@filetowrite = File.open(@file_name,"w")
end
@filetowrite.write(@file_content)
@filetowrite.close
end
@filetowrite.write(@file_content)
@filetowrite.close
Dir.chdir(Rails.root.to_s)
else
@file_name = @font_settings.font_file_name
end
@@ -196,42 +196,18 @@ class Admin::PatchfilesController < OrbitAdminController
def getfont
@font_array = []
@ckeditor_path = ENV['PWD'] + '/app/assets/javascripts/ckeditor'
@filedata = File.read(@ckeditor_path+"/config.js.erb") rescue return
@name_to_search ="config.font_names"
@index_of_font = @filedata.index(@name_to_search)
custom_fonts_file = "#{@ckeditor_path}/custom_fonts.txt"
@font_str = ""
@end_character
@str_start
@str_end
if @index_of_font != nil
@inex_start_to_search = @index_of_font + @name_to_search.length
@str_start = @inex_start_to_search
if (@filedata[@inex_start_to_search] != "\'" && @filedata[@inex_start_to_search] != "\"")
for @str_start in @inex_start_to_search..@filedata.length
break if (@filedata[@str_start] == "\'" || @filedata[@str_start] == "\"")
end
end
@end_character = @filedata[@str_start]
@str_end = @str_start+1
if @str_start+1 < @filedata.length
@str_end = @str_start+1
for @str_end in @str_start+1..@filedata.length
break if @filedata[@str_end] == @end_character || @str_end == @str_start
if @filedata[@str_end] == "="
@str_end = @str_start
break
end
end
if @str_end != @str_start
@font_str = @filedata[@str_start+1...@str_end]
else
@font_str = ""
end
end
@font_array = @font_str.split("\;")
@font_array.map!{|i| i.strip}
@font_array.delete("")
if File.exist?(custom_fonts_file)
@font_str = File.read(custom_fonts_file).strip rescue ""
else
@filedata = File.read(@ckeditor_path+"/config.js.erb") rescue return
@font_str = @filedata.scan(/(config.font_names\s*=\s*(\"([^"]*)\"|\'([^']*)\'))/m).map{|a| (a[3] rescue nil)}.compact[-1]
end
@font_array = @font_str.split("\;")
@font_array.map!{|i| i.strip}
@font_array.delete("")
@font_array
end
def create_first_field
@app_title = "patchfile"