Text files can now be viewed online when browsing the repository.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@521 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2007-05-08 15:49:20 +00:00
parent df0a49ff14
commit 8614c00c8a
6 changed files with 97 additions and 5 deletions
+4 -4
View File
@@ -61,10 +61,10 @@ class RepositoriesController < ApplicationController
end
def entry
if 'raw' == params[:format]
content = @repository.scm.cat(@path, @rev)
show_error and return unless content
send_data content, :filename => @path.split('/').last
@content = @repository.scm.cat(@path, @rev)
show_error and return unless @content
if 'raw' == params[:format]
send_data @content, :filename => @path.split('/').last
end
end
+5
View File
@@ -174,6 +174,7 @@ module SvnRepos
cmd << " --username #{@login} --password #{@password}" if @login
cat = nil
shellout(cmd) do |io|
io.binmode
cat = io.read
end
return nil if $? && $?.exitstatus != 0
@@ -248,6 +249,10 @@ module SvnRepos
def is_dir?
'dir' == self.kind
end
def is_text?
Redmine::MimeType.is_type?('text', name)
end
end
class Revisions < Array
+23
View File
@@ -0,0 +1,23 @@
<h2><%= render :partial => 'navigation', :locals => { :path => @path, :kind => 'file', :revision => @rev } %></h2>
<table class="list">
<thead>
<tr>
<th colspan="2" class="list-filename"><%= @path %></th>
</tr>
</thead>
<tbody>
<% line_num = 1 %>
<% @content.each_line do |line| %>
<tr>
<th class="line-num"><%= line_num %></th>
<td class="line-code"><%= h(line).gsub(/\s/, '&nbsp;') %></td>
</tr>
<% line_num += 1 %>
<% end %>
<tbody>
</table>
<% content_for :header_tags do %>
<%= stylesheet_link_tag "scm" %>
<% end %>
+6 -1
View File
@@ -9,7 +9,12 @@
<% if @entry && @entry.is_file? %>
<h3><%=h @entry.name %></h3>
<p><%= link_to l(:button_download), {:action => 'entry', :id => @project, :path => @path, :rev => @rev, :format => 'raw' }, :class => "icon file" %> (<%= number_to_human_size @entry.size %>)</p>
<p>
<% if @entry.is_text? %>
<%= link_to l(:button_view), {:action => 'entry', :id => @project, :path => @path, :rev => @rev } %> |
<% end %>
<%= link_to l(:button_download), {:action => 'entry', :id => @project, :path => @path, :rev => @rev, :format => 'raw' } %>
(<%= number_to_human_size @entry.size %>)</p>
<% end %>
<h3><%= l(:label_revision_plural) %></h3>