Changesets can be listed by changeset number.
The Git repository is here.
Changeset 47
A few include paths in the syntax library were still wrong, at least for
the installation on Alpha. Some spurious white space changes to files in
the 'app' tree. Fixes bug described by Ticket #37.
- Comitted by: adh
- Date: Wednesday August 02 21:45:12 2006 (over 18 years ago)
Affected files:
- rool/rails/collaboa/trunk/app/controllers/repository_controller.rb (diff)
- rool/rails/collaboa/trunk/app/helpers/repository_helper.rb (diff)
- rool/rails/collaboa/trunk/vendor/syntax/lib/syntax.rb (diff)
- rool/rails/collaboa/trunk/vendor/syntax/lib/syntax/lang/ruby.rb (diff)
- rool/rails/collaboa/trunk/vendor/syntax/lib/syntax/lang/xml.rb (diff)
- rool/rails/collaboa/trunk/vendor/syntax/lib/syntax/lang/yaml.rb (diff)
rool/rails/collaboa/trunk/app/controllers/repository_controller.rb:
prev. | current | |
class RepositoryController < ApplicationController | ||
2 | | |
2 | before_filter :login_required | |
layout 'application', :except => ['send_data_to_browser'] | ||
4 | | |
4 | ||
def index | ||
redirect_to :action => 'browse' | ||
end | ||
8 | | |
8 | ||
def browse | ||
path = params[:path].to_s | ||
@rev = params[:rev] | ||
if Repository.is_dir?(path) | ||
@current_entry = Repository.get_node_entry(path, @rev) | ||
14 | | |
14 | @node_entries = @current_entry.entries#Repository.get_node_entries(path, @rev) | |
@node_entries.sort!{ |x,y| x.name.downcase <=> y.name.downcase } | ||
16 | | |
16 | @node_entries.sort!{ |x,y| x.type <=> y.type } | |
GC.start | ||
18 | | |
18 | else | |
redirect_to :action => 'view_file', :path => params[:path] | ||
end | ||
end | ||
22 | | |
22 | ||
# TODO: check so that filesize is reasonable, before doing anything | ||
def view_file | ||
path = params[:path].to_s | ||
... | ... | |
send_data @file.contents, :name => path | ||
elsif @params[:format] == 'txt' | ||
send_data @file.contents, :type => "text/plain", :disposition => 'inline' | ||
35 | | |
36 | | |
35 | else | |
36 | if @file.is_textual? | |
render :action => 'showfile' | ||
elsif @file.is_image? | ||
render :action => 'showimage' | ||
... | ... | |
end | ||
end | ||
end | ||
46 | | |
46 | ||
def changesets | ||
@changeset_pages, @changesets = | ||
paginate :changesets, :order_by => 'revision DESC', :per_page => 15 | ||
end | ||
51 | | |
51 | ||
def show_changeset | ||
53 | | |
54 | | |
53 | @changeset = Changeset.find_by_revision(params[:revision]) | |
54 | ||
if @changeset.nil? | ||
redirect_to :action => 'changesets' | ||
else | ||
... | ... | |
@files_to_diff.reject! {|f| !f.diffable? } | ||
end | ||
end | ||
62 | | |
62 | ||
def revisions | ||
path = params[:path].to_s | ||
logger.debug "** PATH: #{path}" | ||
... | ... | |
file = Repository.get_node_entry(path, @rev) | ||
send_data file.contents, :type => file.mime_type, :disposition => 'inline' | ||
end | ||
76 | | |
76 | ||
private | ||
def authorize?(user) | ||
if %w'changesets show_changeset'.include?(action_name) |
rool/rails/collaboa/trunk/app/helpers/repository_helper.rb:
prev. | current | |
end | ||
out << "</ul>" | ||
end | ||
30 | | |
30 | ||
# Takes a unified diff as input and renders it as html | ||
def render_diff(udiff) | ||
return if udiff.blank? | ||
out = "<table class=\"codediff\">\n" | ||
35 | | |
35 | ||
lines = udiff.split("\n") | ||
37 | | |
37 | ||
lines_that_differs = /@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@/ | ||
39 | | |
39 | ||
out << "<thead>\n" | ||
out << "\t<tr><td class=\"line-numbers\">prev.</td><td class=\"line-numbers\">current</td><td> </td></tr>\n" | ||
out << "</thead>\n" | ||
... | ... | |
cur_counter = 0 | ||
change_num = 0 | ||
48 | | |
49 | | |
48 | lines[2..lines.length].each do |line| | |
49 | if line_nums = line.match(lines_that_differs) | |
prev_line_numbers = line_nums[1].to_i...(line_nums[1].to_i + (line_nums[2]).to_i) | ||
cur_line_numbers = line_nums[3].to_i...(line_nums[3].to_i + (line_nums[4]).to_i) | ||
prev_counter = prev_line_numbers.first - 1 | ||
cur_counter = cur_line_numbers.first - 1 | ||
54 | | |
54 | change_num += 1 | |
end | ||
56 | | |
56 | ||
line = h(line) | ||
line.gsub!(/^(\+{1}(\s+|\t+)?(.*))/, '\2<ins>\3</ins>') | ||
line.gsub!(/^(-{1}(\s+|\t+)?(.*))/, '\2<del>\3</del>') | ||
line.gsub!('', '') | ||
out << "<tr class=\"changes\">\n" | ||
63 | | |
64 | | |
63 | ||
64 | if line.match(/^(\s+|\t+)?<del>/) | |
out << "\t<td class=\"line-numbers\">" + prev_counter.to_s + "</td>\n" | ||
out << "\t<td class=\"line-numbers\"> </td>\n" | ||
prev_counter += 1 | ||
... | ... | |
elsif line.match(/^(\s+|\t+)?<ins>/) | ||
out << "\t<td class=\"line-numbers\"> </td>\n" | ||
out << "\t<td class=\"line-numbers\">" + cur_counter.to_s + "</td>\n" | ||
72 | | |
72 | cur_counter += 1 | |
action_class = 'ins' | ||
else | ||
if line.match(lines_that_differs) | ||
... | ... | |
out << "\t<td class=\"line-numbers line-num-cut\">...</td>\n" | ||
out << "\t<td class=\"line-numbers line-num-cut\">...</td>\n" | ||
action_class = 'cut-line' | ||
81 | | |
81 | else | |
out << "\t<td class=\"line-numbers\"></td>\n" | ||
out << "\t<td class=\"line-numbers\"></td>\n" | ||
action_class = 'unchanged' | ||
... | ... | |
out << "\t<td class=\"line-numbers\"></td>\n" | ||
action_class = 'unchanged' | ||
end | ||
91 | | |
92 | | |
91 | prev_counter += 1 | |
92 | cur_counter += 1 | |
end | ||
94 | | |
95 | | |
94 | ||
95 | out << "\t<td class=\"code #{action_class}\">" + line + "</td></tr>\n" | |
end | ||
out << "\n</table>\n" | ||
end | ||
99 | | |
99 | ||
def highlight(content, mime_type) | ||
# prepare the hash of mime_types to tokenizer types | ||
# TODO: Create more Syntax defs, and/or fix the xml highlighter to be more forgiving | ||
103 | | |
103 | mime_tokenizers = { 'text/xml' => 'xml', | |
#'text/x-html+ruby' => 'xml', # .rhtml | ||
#'text/html' => 'xml', | ||
'text/x-ruby' => 'ruby', | ||
... | ... | |
} | ||
type = mime_tokenizers[mime_type] | ||
return make_line_nums(h(content)) unless Syntax::SYNTAX.has_key? type | ||
112 | | |
112 | ||
converted = Syntax::Convertors::HTML.for_syntax(type).convert(content,false) | ||
make_line_nums(converted, type) | ||
end | ||
116 | | |
116 | ||
def make_line_nums(contents, css_class="") | ||
line_num = 1 | ||
html = "<table class=\"#{css_class}\">\n" | ||
... | ... | |
html << "</tr>\n" | ||
line_num += 1 | ||
end | ||
127 | | |
127 | html << '</table>' | |
end | ||
end |
rool/rails/collaboa/trunk/vendor/syntax/lib/syntax.rb:
prev. | current | |
# handler will be returned. | ||
def load( syntax ) | ||
begin | ||
24 | | |
24 | require "syntax/lib/syntax/lang/#{syntax}" | |
rescue LoadError | ||
end | ||
SYNTAX[ syntax ].new |
rool/rails/collaboa/trunk/vendor/syntax/lib/syntax/lang/ruby.rb:
prev. | current | |
1 | ||
1 | require 'syntax/lib/syntax' | |
module Syntax | ||
rool/rails/collaboa/trunk/vendor/syntax/lib/syntax/lang/xml.rb:
prev. | current | |
1 | ||
1 | require 'syntax/lib/syntax' | |
module Syntax | ||
rool/rails/collaboa/trunk/vendor/syntax/lib/syntax/lang/yaml.rb:
prev. | current | |
1 | ||
1 | require 'syntax/lib/syntax' | |
module Syntax | ||