Merge branch 'master' of github.com:evilmartians/rosa-build

This commit is contained in:
Alexey Nayden 2011-03-10 14:36:10 +03:00
commit d3fa2ef8bc
2 changed files with 80 additions and 2 deletions

View File

@ -9,7 +9,8 @@ Bundler.require(:default, Rails.env) if defined?(Bundler)
module Rosa
class Application < Rails::Application
config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
config.autoload_paths += %W(#{config.root}/lib)
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
@ -33,7 +34,7 @@ config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.action_view.javascript_expansions[:defaults] = %w()
config.action_view.javascript_expansions[:defaults] = %w()
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"

View File

@ -0,0 +1,77 @@
module Git
module Diff
class InlineCallback < ::Diff::Renderer::Base
def addline(line)
"<tr class='changes'>
<td></td>
<td class='line_numbers'></td>
<td class='line_numbers'>#{line.new_number}</td>
<td class='code ins'>#{render_line(line)}</td>
</tr>"
end
def remline(line)
"<tr class='changes'>
<td></td>
<td class='line_numbers'>#{line.old_number}</td>
<td class='line_numbers'></td>
<td class='code del'>#{render_line(line)}</td>
</tr>"
end
def modline(line)
"<tr clas='chanes line'>
<td></td>
<td class='line_numbers'>#{line.old_number}</td>
<td class='line_numbers'>#{line.new_number}</td>
<td class='code unchanged modline'>#{render_line(line)}</td>
</tr>"
end
def unmodline(line)
"<tr class='changes unmodline'>
<td></td>
<td class='line_numbers'>#{line.old_number}</td>
<td class='line_numbers'>#{line.new_number}</td>
<td class='code unchanged unmodline'>#{render_line(line)}</td>
</tr>"
end
def sepline(line)
"<tr class='changes hunk-sep'>
<td></td>
<td class='line_numbers line_num_cut'>&hellip;</td>
<td class='line_numbers line_num_cut'>&hellip;</td>
<td class='code cut-line'></td>
</tr>"
end
def nonewlineline(line)
"<tr class='changes'>
<td></td>
<td class='line_numbers'>#{line.old_number}</td>
<td class='line_numbers'>#{line.new_number}</td>
<td class='code modline unmodline'>#{render_line(line)}</td>
</tr>"
end
protected
def escape(str)
str.to_s.gsub('&', '&amp;').gsub('<', '&lt;').gsub('>', '&gt;').gsub('"', '&#34;')
end
def render_line(line)
res = '<span class="diff-content">'
if line.inline_changes?
prefix, changed, postfix = line.segments.map{|segment| escape(segment) }
res += "#{prefix}<span class='idiff'>#{changed}</span>#{postfix}"
else
res += escape(line)
end
res += '</span>'
res
end
end
end
end