OSDN Git Service

remove charencode.
authorSaito <saitowu@gmail.com>
Fri, 30 Dec 2011 13:41:39 +0000 (21:41 +0800)
committerSaito <saitowu@gmail.com>
Fri, 30 Dec 2011 13:41:39 +0000 (21:41 +0800)
app/helpers/application_helper.rb
app/models/commit.rb
app/views/commits/_text_file.html.haml
app/views/refs/_tree.html.haml
lib/graph_commit.rb
lib/utils.rb

index 4b00c9a..99ef30a 100644 (file)
@@ -1,6 +1,5 @@
 require 'digest/md5'
 module ApplicationHelper
-  include Utils::CharEncode
 
   def gravatar_icon(user_email, size = 40)
     gravatar_host = request.ssl? ? "https://secure.gravatar.com" :  "http://www.gravatar.com"
index c97aec2..33d3b20 100644 (file)
@@ -1,5 +1,4 @@
 class Commit
-  include Utils::CharEncode
 
   attr_accessor :commit
   attr_accessor :head
@@ -22,7 +21,7 @@ class Commit
   end
 
   def safe_message
-    encode(message)
+    message
   end
 
   def created_at
@@ -30,11 +29,11 @@ class Commit
   end
 
   def author_email
-    encode(author.email)
+    author.email
   end
 
   def author_name
-    encode(author.name)
+    author.name
   end
 
   def prev_commit
index 22fe558..954722b 100644 (file)
@@ -1,7 +1,7 @@
 %table
   - line_old = 0
   - line_new = 0
-  - diff_str = encode(diff.diff)
+  - diff_str = diff.diff
   - lines_arr = diff_str.lines.to_a
   - lines_arr.each do |line|
     - next if line.match(/^--- \/dev\/null/)
index 07bab21..b7b3fd2 100644 (file)
@@ -40,9 +40,9 @@
         %h3= content.name
         .readme
           - if content.name =~ /\.(md|markdown)$/i
-            = markdown(encode content.data)
+            = markdown(content.data)
           - else
-            = simple_format(encode content.data)
+            = simple_format(content.data)
 
 :javascript
   $(function(){
index 1fcb9e7..54550d9 100644 (file)
@@ -1,7 +1,6 @@
 require "grit"
 
 class GraphCommit
-  include Utils::CharEncode
   attr_accessor :time, :space
   attr_accessor :refs
 
@@ -97,13 +96,13 @@ class GraphCommit
     h[:parents] = self.parents.collect do |p|
       [p.id,0,0]
     end
-    h[:author]  = encode(author.name)
+    h[:author]  = author.name
     h[:time]    = time
     h[:space]   = space
     h[:refs]    = refs.collect{|r|r.name}.join(" ") unless refs.nil?
     h[:id]      = sha
     h[:date]    = date
-    h[:message] = encode(message)
+    h[:message] = message
     h[:login]   = author.email
     h
   end
index 2de1476..677322c 100644 (file)
@@ -16,28 +16,14 @@ module Utils
     end
   end
 
-  module CharEncode
-    def encode(string)
-      return '' unless string
-      cd = CharDet.detect(string)
-      if cd.confidence > 0.6
-        string.force_encoding(cd.encoding)
-      end
-      string.encode("utf-8", :undef => :replace, :replace => "?", :invalid => :replace)
-    rescue
-      "Invalid Encoding"
-    end
-  end
-
   module Colorize
-    include CharEncode
     def colorize
       system_colorize(data, name)
     end
 
     def system_colorize(data, file_name)
       ft = handle_file_type(file_name)
-      Pygments.highlight(encode(data), :lexer => ft, :options => { :encoding => 'utf-8', :linenos => 'True' })
+      Pygments.highlight(data, :lexer => ft, :options => { :encoding => 'utf-8', :linenos => 'True' })
     end
 
     def handle_file_type(file_name, mime_type = nil)