Commit 1477a6c8aaecbde1f2b5903cccb267d632212ee4

Authored by gitlabhq
1 parent f2808191

moved from albino -> pygments.rb

Gemfile
... ... @@ -15,7 +15,7 @@ gem 'therubyracer'
15 15 gem 'faker'
16 16 gem 'seed-fu', :git => 'git://github.com/mbleigh/seed-fu.git'
17 17 gem "inifile"
18   -gem "albino", :git => "git://github.com/gitlabhq/albino.git"
  18 +gem "pygments.rb", "0.2.3"
19 19 gem "kaminari"
20 20 gem "thin"
21 21 gem "git"
... ...
Gemfile.lock
... ... @@ -5,13 +5,6 @@ GIT
5 5 annotate (2.4.1.beta1)
6 6  
7 7 GIT
8   - remote: git://github.com/gitlabhq/albino.git
9   - revision: 118380924969f3a856659f86ea1f40c1ba7bfcb1
10   - specs:
11   - albino (1.3.3)
12   - posix-spawn (>= 0.3.6)
13   -
14   -GIT
15 8 remote: git://github.com/gitlabhq/grit.git
16 9 revision: ff015074ef35bd94cba943f9c0f98e161ab5851c
17 10 specs:
... ... @@ -72,6 +65,7 @@ GEM
72 65 ZenTest (= 4.5)
73 66 awesome_print (0.4.0)
74 67 bcrypt-ruby (3.0.1)
  68 + blankslate (2.1.2.4)
75 69 builder (3.0.0)
76 70 capybara (1.0.1)
77 71 mime-types (>= 1.16)
... ... @@ -138,6 +132,8 @@ GEM
138 132 orm_adapter (0.0.5)
139 133 polyglot (0.3.2)
140 134 posix-spawn (0.3.6)
  135 + pygments.rb (0.2.3)
  136 + rubypython (>= 0.5.1)
141 137 rack (1.3.2)
142 138 rack-cache (1.0.3)
143 139 rack (>= 0.4)
... ... @@ -189,6 +185,9 @@ GEM
189 185 ruby-debug-base19 (>= 0.11.19)
190 186 ruby_core_source (0.1.5)
191 187 archive-tar-minitar (>= 0.5.2)
  188 + rubypython (0.5.1)
  189 + blankslate (>= 2.1.2.3)
  190 + ffi (~> 1.0.7)
192 191 rubyzip (0.9.4)
193 192 sass (3.1.7)
194 193 sass-rails (3.1.1)
... ... @@ -242,7 +241,6 @@ PLATFORMS
242 241  
243 242 DEPENDENCIES
244 243 acts_as_list
245   - albino!
246 244 annotate!
247 245 autotest
248 246 autotest-rails
... ... @@ -260,6 +258,7 @@ DEPENDENCIES
260 258 jquery-rails
261 259 kaminari
262 260 launchy
  261 + pygments.rb (= 0.2.3)
263 262 rails (= 3.1.0)
264 263 rails-footnotes (>= 3.7.5.rc4)
265 264 rspec-rails
... ...
app/models/snippet.rb
... ... @@ -32,8 +32,7 @@ class Snippet < ActiveRecord::Base
32 32 end
33 33  
34 34 def colorize
35   - ft = handle_file_type(file_name)
36   - Albino.colorize(content, ft, :html, 'utf-8', "linenos=True")
  35 + system_colorize(content, file_name)
37 36 end
38 37 end
39 38 # == Schema Information
... ...
app/views/projects/_tree_file.html.haml
  1 +:css
1 2 .view_file
2 3 .view_file_header
3 4 %strong
... ...
app/views/projects/empty.html.erb
  1 +<% bash_lexer = Pygments::Lexer[:bash] %>
1 2 <div class="">
2 3 <div class="git-empty">
3 4 <h2>Git global setup:</h2>
... ... @@ -6,7 +7,7 @@ git config --global user.name &quot;#{current_user.name}&quot;
6 7 git config --global user.email "#{current_user.email}"
7 8 eos
8 9 %>
9   - <%= raw Albino.colorize(setup_str, :bash) %>
  10 + <%= raw bash_lexer.highlight(setup_str) %>
10 11 <br />
11 12 <br />
12 13 <h2>Next steps:</h2>
... ... @@ -21,7 +22,7 @@ git remote add origin #{@project.url_to_repo}
21 22 git push -u origin master
22 23 eos
23 24 %>
24   - <%= raw Albino.colorize(repo_setup_str, :bash) %>
  25 + <%= raw bash_lexer.highlight(repo_setup_str) %>
25 26  
26 27 <br /><br />
27 28 <h2>Existing Git Repo?</h2>
... ... @@ -31,7 +32,7 @@ git remote add origin #{@project.url_to_repo}
31 32 git push -u origin master
32 33 eos
33 34 %>
34   - <%= raw Albino.colorize(exist_repo_setup_str, :bash) %>
  35 + <%= raw bash_lexer.highlight(exist_repo_setup_str) %>
35 36  
36 37 <br /><br />
37 38 <h2>Remove this project?</h2>
... ...
config/initializers/grit_ext.rb
1 1 require 'grit'
2   -require 'albino'
  2 +require 'pygments'
3 3 require "utils"
4 4  
5 5 Grit::Blob.class_eval do
... ...
lib/utils.rb
... ... @@ -18,8 +18,12 @@ module Utils
18 18  
19 19 module Colorize
20 20 def colorize
21   - ft = handle_file_type(name, mime_type)
22   - Albino.colorize(data, ft, :html, 'utf-8', "linenos=True")
  21 + system_colorize(data, name)
  22 + end
  23 +
  24 + def system_colorize(data, file_name)
  25 + ft = handle_file_type(file_name)
  26 + Pygments.highlight(data, :lexer => ft, :options => { :encoding => 'utf-8', :linenos => 'True' })
23 27 end
24 28  
25 29 def handle_file_type(file_name, mime_type = nil)
... ...