Commit 14023c4e5a3241d06a8a021bab1183e4a9742b28

Authored by Saito
1 parent 7279e8c1

remove charencode.

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