Commit 14023c4e5a3241d06a8a021bab1183e4a9742b28

Authored by Saito
1 parent 7279e8c1

remove charencode.

app/helpers/application_helper.rb
1 require 'digest/md5' 1 require 'digest/md5'
2 module ApplicationHelper 2 module ApplicationHelper
3 - include Utils::CharEncode  
4 3
5 def gravatar_icon(user_email, size = 40) 4 def gravatar_icon(user_email, size = 40)
6 gravatar_host = request.ssl? ? "https://secure.gravatar.com" : "http://www.gravatar.com" 5 gravatar_host = request.ssl? ? "https://secure.gravatar.com" : "http://www.gravatar.com"
app/models/commit.rb
1 class Commit 1 class Commit
2 - include Utils::CharEncode  
3 2
4 attr_accessor :commit 3 attr_accessor :commit
5 attr_accessor :head 4 attr_accessor :head
@@ -22,7 +21,7 @@ class Commit @@ -22,7 +21,7 @@ class Commit
22 end 21 end
23 22
24 def safe_message 23 def safe_message
25 - encode(message) 24 + message
26 end 25 end
27 26
28 def created_at 27 def created_at
@@ -30,11 +29,11 @@ class Commit @@ -30,11 +29,11 @@ class Commit
30 end 29 end
31 30
32 def author_email 31 def author_email
33 - encode(author.email) 32 + author.email
34 end 33 end
35 34
36 def author_name 35 def author_name
37 - encode(author.name) 36 + author.name
38 end 37 end
39 38
40 def prev_commit 39 def prev_commit
app/views/commits/_text_file.html.haml
1 %table 1 %table
2 - line_old = 0 2 - line_old = 0
3 - line_new = 0 3 - line_new = 0
4 - - diff_str = encode(diff.diff) 4 + - diff_str = diff.diff
5 - lines_arr = diff_str.lines.to_a 5 - lines_arr = diff_str.lines.to_a
6 - lines_arr.each do |line| 6 - lines_arr.each do |line|
7 - next if line.match(/^--- \/dev\/null/) 7 - next if line.match(/^--- \/dev\/null/)
app/views/refs/_tree.html.haml
@@ -40,9 +40,9 @@ @@ -40,9 +40,9 @@
40 %h3= content.name 40 %h3= content.name
41 .readme 41 .readme
42 - if content.name =~ /\.(md|markdown)$/i 42 - if content.name =~ /\.(md|markdown)$/i
43 - = markdown(encode content.data) 43 + = markdown(content.data)
44 - else 44 - else
45 - = simple_format(encode content.data) 45 + = simple_format(content.data)
46 46
47 :javascript 47 :javascript
48 $(function(){ 48 $(function(){
lib/graph_commit.rb
1 require "grit" 1 require "grit"
2 2
3 class GraphCommit 3 class GraphCommit
4 - include Utils::CharEncode  
5 attr_accessor :time, :space 4 attr_accessor :time, :space
6 attr_accessor :refs 5 attr_accessor :refs
7 6
@@ -97,13 +96,13 @@ class GraphCommit @@ -97,13 +96,13 @@ class GraphCommit
97 h[:parents] = self.parents.collect do |p| 96 h[:parents] = self.parents.collect do |p|
98 [p.id,0,0] 97 [p.id,0,0]
99 end 98 end
100 - h[:author] = encode(author.name) 99 + h[:author] = author.name
101 h[:time] = time 100 h[:time] = time
102 h[:space] = space 101 h[:space] = space
103 h[:refs] = refs.collect{|r|r.name}.join(" ") unless refs.nil? 102 h[:refs] = refs.collect{|r|r.name}.join(" ") unless refs.nil?
104 h[:id] = sha 103 h[:id] = sha
105 h[:date] = date 104 h[:date] = date
106 - h[:message] = encode(message) 105 + h[:message] = message
107 h[:login] = author.email 106 h[:login] = author.email
108 h 107 h
109 end 108 end
@@ -16,28 +16,14 @@ module Utils @@ -16,28 +16,14 @@ module Utils
16 end 16 end
17 end 17 end
18 18
19 - module CharEncode  
20 - def encode(string)  
21 - return '' unless string  
22 - cd = CharDet.detect(string)  
23 - if cd.confidence > 0.6  
24 - string.force_encoding(cd.encoding)  
25 - end  
26 - string.encode("utf-8", :undef => :replace, :replace => "?", :invalid => :replace)  
27 - rescue  
28 - "Invalid Encoding"  
29 - end  
30 - end  
31 -  
32 module Colorize 19 module Colorize
33 - include CharEncode  
34 def colorize 20 def colorize
35 system_colorize(data, name) 21 system_colorize(data, name)
36 end 22 end
37 23
38 def system_colorize(data, file_name) 24 def system_colorize(data, file_name)
39 ft = handle_file_type(file_name) 25 ft = handle_file_type(file_name)
40 - Pygments.highlight(encode(data), :lexer => ft, :options => { :encoding => 'utf-8', :linenos => 'True' }) 26 + Pygments.highlight(data, :lexer => ft, :options => { :encoding => 'utf-8', :linenos => 'True' })
41 end 27 end
42 28
43 def handle_file_type(file_name, mime_type = nil) 29 def handle_file_type(file_name, mime_type = nil)