From 438161ad1fd37aadbfa3f5a875540730fd6d70c3 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 12 Jun 2007 20:12:05 +0000 Subject: Added basic support for CVS and Mercurial SCMs. Browsing, changesets fetching and diff viewing are implemented. Only tested with local repositories. Thanks to Ralph Vater for CVS specific code. git-svn-id: http://redmine.rubyforge.org/svn/trunk@559 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/views/repositories/_dir_list.rhtml | 14 +++++++------- app/views/repositories/_navigation.rhtml | 5 +++-- app/views/repositories/_revisions.rhtml | 9 +++++---- app/views/repositories/changes.rhtml | 13 +++++++++++++ app/views/repositories/revision.rhtml | 6 ++++-- app/views/repositories/revisions.rhtml | 18 +++--------------- app/views/repositories/show.rhtml | 8 +++++--- 7 files changed, 40 insertions(+), 33 deletions(-) create mode 100644 app/views/repositories/changes.rhtml (limited to 'app/views/repositories') diff --git a/app/views/repositories/_dir_list.rhtml b/app/views/repositories/_dir_list.rhtml index 0e5b712bf..5555ee87e 100644 --- a/app/views/repositories/_dir_list.rhtml +++ b/app/views/repositories/_dir_list.rhtml @@ -11,15 +11,15 @@ <% total_size = 0 @entries.each do |entry| %> -<%= link_to h(entry.name), { :action => (entry.is_dir? ? 'browse' : 'revisions'), :id => @project, :path => entry.path, :rev => @rev }, :class => ("icon " + (entry.is_dir? ? 'icon-folder' : 'icon-file')) %> -<%= number_to_human_size(entry.size) unless entry.is_dir? %> -<%= link_to entry.lastrev.identifier, :action => 'revision', :id => @project, :rev => entry.lastrev.identifier %> -<%= format_time(entry.lastrev.time) %> -<%=h entry.lastrev.author %> -<% changeset = @project.repository.changesets.find_by_revision(entry.lastrev.identifier) %> +<%= link_to h(entry.name), { :action => (entry.is_dir? ? 'browse' : 'changes'), :id => @project, :path => entry.path, :rev => @rev }, :class => ("icon " + (entry.is_dir? ? 'icon-folder' : 'icon-file')) %> +<%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %> +<%= link_to(entry.lastrev.name, :action => 'revision', :id => @project, :rev => entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %> +<%= format_time(entry.lastrev.time) if entry.lastrev %> +<%=h(entry.lastrev.author) if entry.lastrev %> +<% changeset = @project.repository.changesets.find_by_revision(entry.lastrev.identifier) if entry.lastrev %> <%=h truncate(changeset.comments, 100) unless changeset.nil? %> -<% total_size += entry.size +<% total_size += entry.size if entry.size end %> diff --git a/app/views/repositories/_navigation.rhtml b/app/views/repositories/_navigation.rhtml index efc0b9ff9..823b4f44f 100644 --- a/app/views/repositories/_navigation.rhtml +++ b/app/views/repositories/_navigation.rhtml @@ -5,7 +5,8 @@ if 'file' == kind filename = dirs.pop end link_path = '' -dirs.each do |dir| +dirs.each do |dir| + next if dir.blank? link_path << '/' unless link_path.empty? link_path << "#{dir}" %> @@ -15,4 +16,4 @@ dirs.each do |dir| / <%= link_to h(filename), :action => 'revisions', :id => @project, :path => "#{link_path}/#{filename}", :rev => @rev %> <% end %> -<%= "@ #{revision}" if revision %> \ No newline at end of file +<%= "@ #{revision}" if revision %> diff --git a/app/views/repositories/_revisions.rhtml b/app/views/repositories/_revisions.rhtml index faec16662..b2bdb6c7f 100644 --- a/app/views/repositories/_revisions.rhtml +++ b/app/views/repositories/_revisions.rhtml @@ -9,12 +9,13 @@ <%= l(:field_comments) %> -<% show_diff = entry && entry.is_file? && changesets.size > 1 %> +<% show_diff = entry && entry.is_file? && revisions.size > 1 %> <% line_num = 1 %> -<% changesets.each do |changeset| %> +<% revisions.each do |revision| %> +<% changeset = revision.is_a?(Change) ? revision.changeset : revision %> -<%= link_to changeset.revision, :action => 'revision', :id => project, :rev => changeset.revision %> -<%= radio_button_tag('rev', changeset.revision, (line_num==1), :id => "cb-#{line_num}", :onclick => "$('cbto-#{line_num+1}').checked=true;") if show_diff && (line_num < changesets.size) %> +<%= link_to (revision.revision || changeset.revision), :action => 'revision', :id => project, :rev => changeset.revision %> +<%= radio_button_tag('rev', changeset.revision, (line_num==1), :id => "cb-#{line_num}", :onclick => "$('cbto-#{line_num+1}').checked=true;") if show_diff && (line_num < revisions.size) %> <%= radio_button_tag('rev_to', changeset.revision, (line_num==2), :id => "cbto-#{line_num}", :onclick => "if ($('cb-#{line_num}').checked==true) {$('cb-#{line_num-1}').checked=true;}") if show_diff && (line_num > 1) %> <%= format_time(changeset.committed_on) %> <%=h changeset.committer %> diff --git a/app/views/repositories/changes.rhtml b/app/views/repositories/changes.rhtml new file mode 100644 index 000000000..35ce939fc --- /dev/null +++ b/app/views/repositories/changes.rhtml @@ -0,0 +1,13 @@ +

<%= render :partial => 'navigation', :locals => { :path => @path, :kind => (@entry ? @entry.kind : nil), :revision => @rev } %>

+ +

<%=h @entry.name %>

+ +

+<% 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)})" if @entry.size %> +

+ +<%= render :partial => 'revisions', :locals => {:project => @project, :path => @path, :revisions => @changes, :entry => @entry }%> diff --git a/app/views/repositories/revision.rhtml b/app/views/repositories/revision.rhtml index 5cf5c2e41..b484becce 100644 --- a/app/views/repositories/revision.rhtml +++ b/app/views/repositories/revision.rhtml @@ -7,7 +7,9 @@

<%= l(:label_revision) %> <%= @changeset.revision %>

-

<%= @changeset.committer %>, <%= format_time(@changeset.committed_on) %>

+

<% if @changeset.scmid %>ID: <%= @changeset.scmid %>
<% end %> +<%= @changeset.committer %>, <%= format_time(@changeset.committed_on) %>

+ <%= textilizable @changeset.comments %> <% if @changeset.issues.any? %> @@ -30,7 +32,7 @@ <% @changes.each do |change| %> -
<%= change.path %> +
<%= change.path %> <%= "(#{change.revision})" unless change.revision.blank? %> <% if change.action == "M" %> <%= link_to l(:label_view_diff), :action => 'diff', :id => @project, :path => change.path, :rev => @changeset.revision %> diff --git a/app/views/repositories/revisions.rhtml b/app/views/repositories/revisions.rhtml index 4a5b3766e..0c2655d5f 100644 --- a/app/views/repositories/revisions.rhtml +++ b/app/views/repositories/revisions.rhtml @@ -5,25 +5,13 @@ <% end %> -

<%= render :partial => 'navigation', :locals => { :path => @path, :kind => (@entry ? @entry.kind : nil), :revision => @rev } %>

+

<%= l(:label_revision_plural) %>

-<% if @entry && @entry.is_file? %> -

<%=h @entry.name %>

-

-<% 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 %>)

-<% end %> - -

<%= l(:label_revision_plural) %>

- -<%= render :partial => 'revisions', :locals => {:project => @project, :path => @path, :changesets => @changesets, :entry => @entry }%> +<%= render :partial => 'revisions', :locals => {:project => @project, :path => '', :revisions => @changesets, :entry => nil }%>

<%= pagination_links_full @changeset_pages %> [ <%= @changeset_pages.current.first_item %> - <%= @changeset_pages.current.last_item %> / <%= @changeset_count %> ]

<% content_for :header_tags do %> <%= stylesheet_link_tag "scm" %> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/repositories/show.rhtml b/app/views/repositories/show.rhtml index 04a58b4c9..fcf954473 100644 --- a/app/views/repositories/show.rhtml +++ b/app/views/repositories/show.rhtml @@ -2,17 +2,19 @@ <%= link_to l(:label_statistics), {:action => 'stats', :id => @project}, :class => 'icon icon-stats' %> -

<%= l(:label_repository) %>

+

<%= l(:label_repository) %> (<%= @repository.scm_name %>)

+<% unless @entries.nil? %>

<%= l(:label_browse) %>

<%= render :partial => 'dir_list' %> +<% end %> <% unless @changesets.empty? %>

<%= l(:label_latest_revision_plural) %>

-<%= render :partial => 'revisions', :locals => {:project => @project, :path => '', :changesets => @changesets, :entry => nil }%> +<%= render :partial => 'revisions', :locals => {:project => @project, :path => '', :revisions => @changesets, :entry => nil }%>

<%= link_to l(:label_view_revisions), :action => 'revisions', :id => @project %>

<% end %> <% content_for :header_tags do %> <%= stylesheet_link_tag "scm" %> -<% end %> \ No newline at end of file +<% end %> -- cgit v1.2.3