|
|
|
@@ -19,6 +19,10 @@ module RepositoriesHelper |
|
|
|
default_type.include?(str.to_s.gsub("\r", "").downcase) |
|
|
|
end |
|
|
|
|
|
|
|
def is_text_file?(entry) |
|
|
|
entry['is_text_file'] |
|
|
|
end |
|
|
|
|
|
|
|
def is_readme?(type, str) |
|
|
|
return false if type != 'file' || str.blank? |
|
|
|
readme_types = ["readme.md", "readme", "readme_en.md", "readme_zh.md", "readme_en", "readme_zh"] |
|
|
|
@@ -232,6 +236,8 @@ module RepositoriesHelper |
|
|
|
# Rails.logger.info("content===#{content}") |
|
|
|
return Base64.decode64(content).force_encoding("GBK").encode("UTF-8") unless Base64.decode64(content).force_encoding('UTF-8').valid_encoding? |
|
|
|
return Base64.decode64(content).force_encoding('UTF-8') |
|
|
|
elsif entry['is_text_file'] == true |
|
|
|
return render_decode64_content(entry['content']) |
|
|
|
else |
|
|
|
file_type = File.extname(entry['name'].to_s)[1..-1] |
|
|
|
if image_type?(file_type) |
|
|
|
|