Skip to content

Commit

Permalink
Using github's linguist to better detect filetypes and to do syntax h…
Browse files Browse the repository at this point in the history
…ighlighting.
  • Loading branch information
arthurschreiber committed Apr 20, 2012
1 parent 9ee3457 commit 5b6019f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 56 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -18,6 +18,7 @@ gem "six"
gem "therubyracer"
gem "faker"
gem "seed-fu"
gem "linguist", "~> 1.0.0", :git => "https://github.com/github/linguist.git"
gem "pygments.rb", "0.2.7"
gem "thin"
gem "unicorn"
Expand Down
12 changes: 12 additions & 0 deletions Gemfile.lock
Expand Up @@ -4,6 +4,16 @@ GIT
specs:
annotate (2.4.1.beta1)

GIT
remote: https://github.com/github/linguist.git
revision: c444c25b27131cd2aca6017f2a9ce5eae60dfcd3
specs:
linguist (1.0.0)
charlock_holmes (~> 0.6.6)
escape_utils (~> 0.2.3)
mime-types (~> 1.18)
pygments.rb (~> 0.2.11)

GIT
remote: https://github.com/gitlabhq/gitolite-client.git
revision: 36dabd226caa40ff052677719adaacbfe667b36c
Expand Down Expand Up @@ -104,6 +114,7 @@ GEM
diff-lcs (1.1.3)
drapper (0.8.4)
erubis (2.7.0)
escape_utils (0.2.4)
eventmachine (0.12.10)
execjs (1.3.0)
multi_json (~> 1.0)
Expand Down Expand Up @@ -326,6 +337,7 @@ DEPENDENCIES
kaminari
launchy
letter_opener
linguist (~> 1.0.0)!
modularity
mysql2
omniauth-ldap
Expand Down
8 changes: 4 additions & 4 deletions app/views/refs/_tree_file.html.haml
Expand Up @@ -11,10 +11,10 @@
- if file.text?
.view_file_content
- unless file.empty?
%div{:class => current_user.dark_scheme ? "black" : "white"}
= preserve do
= raw file.colorize
- else
%div{:class => current_user.dark_scheme ? "black" : "white"}
= preserve do
= raw file.colorize(options: { linenos: 'True'})
- else
%h3
%center Empty file
- elsif file.image?
Expand Down
5 changes: 2 additions & 3 deletions app/views/snippets/show.html.haml
Expand Up @@ -13,8 +13,7 @@
.view_file_header
%strong= @snippet.file_name
.view_file_content
%div{:class => current_user.dark_scheme ? "black" : ""}
:erb
<%= raw @snippet.colorize %>
%div{:class => current_user.dark_scheme ? "black" : ""}
= raw @snippet.colorize(options: { linenos: 'True'})

= render "notes/notes", :tid => @snippet.id, :tt => "snippet"
7 changes: 2 additions & 5 deletions config/initializers/gitlabhq/20_grit_ext.rb
@@ -1,10 +1,7 @@
require 'grit'
require 'pygments'
require "utils"

Grit::Blob.class_eval do
include Utils::FileHelper
include Utils::Colorize
include Linguist::BlobHelper
end

#monkey patch raw_object from string
Expand All @@ -15,7 +12,7 @@ def content
end


Grit::Diff.class_eval do
Grit::Diff.class_eval do
def old_path
Gitlabhq::Encode.utf8 a_path
end
Expand Down
44 changes: 0 additions & 44 deletions lib/utils.rb

This file was deleted.

0 comments on commit 5b6019f

Please sign in to comment.