| |   |
| 53 | 53 | render :text => @blob.contents, :content_type => "text/plain" |
| 54 | 54 | end |
| 55 | 55 | |
| 56 | @@per_page = 30 |
| 57 | |
| 56 | 58 | def log |
| 57 | 59 | @git = Git.bare(@repository.full_repository_path) |
| 58 | | # TODO: paginated logs |
| 60 | skip = params[:page].blank? ? 0 : (params[:page].to_i-1) * @@per_page |
| 61 | @commits = @git.log(30, skip) |
| 62 | @tags_per_sha = returning({}) do |hash| |
| 63 | @git.tags.each do |tag| |
| 64 | hash[tag.sha] ||= [] |
| 65 | hash[tag.sha] << tag.name |
| 66 | end |
| 67 | end |
| 68 | # TODO: Patch rails to keep track of what it responds to so we can DRY this up |
| 69 | @atom_auto_discovery_url = project_repository_formatted_browse_path(@project, @repository, :atom) |
| 70 | respond_to do |format| |
| 71 | format.html |
| 72 | format.atom |
| 73 | end |
| 59 | 74 | end |
| 60 | 75 | |
| 61 | 76 | def archive |
| toggle raw diff |
--- a/app/controllers/browse_controller.rb
+++ b/app/controllers/browse_controller.rb
@@ -53,9 +53,24 @@ class BrowseController < ApplicationController
render :text => @blob.contents, :content_type => "text/plain"
end
+ @@per_page = 30
+
def log
@git = Git.bare(@repository.full_repository_path)
- # TODO: paginated logs
+ skip = params[:page].blank? ? 0 : (params[:page].to_i-1) * @@per_page
+ @commits = @git.log(30, skip)
+ @tags_per_sha = returning({}) do |hash|
+ @git.tags.each do |tag|
+ hash[tag.sha] ||= []
+ hash[tag.sha] << tag.name
+ end
+ end
+ # TODO: Patch rails to keep track of what it responds to so we can DRY this up
+ @atom_auto_discovery_url = project_repository_formatted_browse_path(@project, @repository, :atom)
+ respond_to do |format|
+ format.html
+ format.atom
+ end
end
def archive |
| |   |
| 4 | 4 | project_repository_browse_path(@project, @repository) |
| 5 | 5 | end |
| 6 | 6 | |
| 7 | def log_path(args={}) |
| 8 | project_repository_log_path(@project, @repository, args) |
| 9 | end |
| 10 | |
| 7 | 11 | def tree_path(sha1=nil) |
| 8 | 12 | project_repository_tree_path(@project, @repository, sha1) |
| 9 | 13 | end |
| toggle raw diff |
--- a/app/helpers/browse_helper.rb
+++ b/app/helpers/browse_helper.rb
@@ -4,6 +4,10 @@ module BrowseHelper
project_repository_browse_path(@project, @repository)
end
+ def log_path(args={})
+ project_repository_log_path(@project, @repository, args)
+ end
+
def tree_path(sha1=nil)
project_repository_tree_path(@project, @repository, sha1)
end |
| |   |
| 1 | <table class="listing shortlog"> |
| 2 | <% commits.each do |commit| -%> |
| 3 | <tr class="<%= cycle "odd", "even" -%>"> |
| 4 | <td><%=h commit.date.strftime("%Y-%m-%d %H:%M") -%></td> |
| 5 | <td><%=h truncate(commit.author.name, 15) -%></td> |
| 6 | <td> |
| 7 | <%= link_to h(truncate(commit.message, 85)), commit_path(commit.sha) -%> |
| 8 | <%= render_tag_box_if_match(commit.sha, @tags_per_sha) -%> |
| 9 | </td> |
| 10 | <td><%= link_to "commit", commit_path(commit.sha) -%></td> |
| 11 | <td><%= link_to "tree", tree_path(commit.gtree.sha) -%></td> |
| 12 | <!-- <td>archive (<%= commit.gtree.sha -%>)</td> --> |
| 13 | </tr> |
| 14 | <% end -%> |
| 15 | <tr> |
| 16 | <td colspan="5" class="link_to_more"> |
| 17 | <span> |
| 18 | <% unless params[:page].blank? || [0,1].include?(params[:page].to_i) -%> |
| 19 | <%= link_to "← previous", log_path(:page => params[:page].to_i-1) -%> | |
| 20 | <% end -%> |
| 21 | <%= link_to "next →", log_path(:page => (params[:page].blank? ? 2 : params[:page].to_i+1)) -%> |
| 22 | </span> |
| 23 | </td> |
| 24 | </tr> |
| 25 | </table> |
| toggle raw diff |
--- /dev/null
+++ b/app/views/browse/_log.html.erb
@@ -0,0 +1,25 @@
+<table class="listing shortlog">
+ <% commits.each do |commit| -%>
+ <tr class="<%= cycle "odd", "even" -%>">
+ <td><%=h commit.date.strftime("%Y-%m-%d %H:%M") -%></td>
+ <td><%=h truncate(commit.author.name, 15) -%></td>
+ <td>
+ <%= link_to h(truncate(commit.message, 85)), commit_path(commit.sha) -%>
+ <%= render_tag_box_if_match(commit.sha, @tags_per_sha) -%>
+ </td>
+ <td><%= link_to "commit", commit_path(commit.sha) -%></td>
+ <td><%= link_to "tree", tree_path(commit.gtree.sha) -%></td>
+ <!-- <td>archive (<%= commit.gtree.sha -%>)</td> -->
+ </tr>
+ <% end -%>
+ <tr>
+ <td colspan="5" class="link_to_more">
+ <span>
+ <% unless params[:page].blank? || [0,1].include?(params[:page].to_i) -%>
+ <%= link_to "← previous", log_path(:page => params[:page].to_i-1) -%> |
+ <% end -%>
+ <%= link_to "next →", log_path(:page => (params[:page].blank? ? 2 : params[:page].to_i+1)) -%>
+ </span>
+ </td>
+ </tr>
+</table>
\ No newline at end of file |
| |   |
| 1 | 1 | <% content_for :submenu do -%> |
| 2 | 2 | <ul> |
| 3 | | <li><%= link_to "← shortlog index", project_repository_browse_path(@project, @repository) -%></li> |
| 3 | <li><%= link_to "← Browse repository", project_repository_browse_path(@project, @repository) -%></li> |
| 4 | 4 | <li><%= link_to "← repository page", |
| 5 | 5 | project_repository_path(@project, @repository) -%></li> |
| 6 | 6 | <li><%= link_to "← project page", |
| toggle raw diff |
--- a/app/views/browse/_submenu.html.erb
+++ b/app/views/browse/_submenu.html.erb
@@ -1,6 +1,6 @@
<% content_for :submenu do -%>
<ul>
- <li><%= link_to "← shortlog index", project_repository_browse_path(@project, @repository) -%></li>
+ <li><%= link_to "← Browse repository", project_repository_browse_path(@project, @repository) -%></li>
<li><%= link_to "← repository page",
project_repository_path(@project, @repository) -%></li>
<li><%= link_to "← project page", |
| |   |
| 11 | 11 | </ul> |
| 12 | 12 | |
| 13 | 13 | <h2>shortlog</h2> |
| 14 | | <table class="listing shortlog"> |
| 15 | | <% @commits.each do |commit| -%> |
| 16 | | <tr class="<%= cycle "odd", "even" -%>"> |
| 17 | | <td><%=h commit.date.strftime("%Y-%m-%d %H:%M") -%></td> |
| 18 | | <td><%=h truncate(commit.author.name, 15) -%></td> |
| 19 | | <td> |
| 20 | | <%= link_to h(truncate(commit.message, 85)), commit_path(commit.sha) -%> |
| 21 | | <%= render_tag_box_if_match(commit.sha, @tags_per_sha) -%> |
| 22 | | </td> |
| 23 | | <td><%= link_to "commit", commit_path(commit.sha) -%></td> |
| 24 | | <td><%= link_to "tree", tree_path(commit.gtree.sha) -%></td> |
| 25 | | <!-- <td>archive (<%= commit.gtree.sha -%>)</td> --> |
| 26 | | </tr> |
| 27 | | <% end -%> |
| 28 | | </table> |
| 14 | <%= render :partial => "log", :locals => {:commits => @commits} -%> |
| 29 | 15 | |
| 30 | 16 | <% content_for :submenu do -%> |
| 31 | 17 | <ul> |
| toggle raw diff |
--- a/app/views/browse/index.html.erb
+++ b/app/views/browse/index.html.erb
@@ -11,21 +11,7 @@
</ul>
<h2>shortlog</h2>
-<table class="listing shortlog">
- <% @commits.each do |commit| -%>
- <tr class="<%= cycle "odd", "even" -%>">
- <td><%=h commit.date.strftime("%Y-%m-%d %H:%M") -%></td>
- <td><%=h truncate(commit.author.name, 15) -%></td>
- <td>
- <%= link_to h(truncate(commit.message, 85)), commit_path(commit.sha) -%>
- <%= render_tag_box_if_match(commit.sha, @tags_per_sha) -%>
- </td>
- <td><%= link_to "commit", commit_path(commit.sha) -%></td>
- <td><%= link_to "tree", tree_path(commit.gtree.sha) -%></td>
- <!-- <td>archive (<%= commit.gtree.sha -%>)</td> -->
- </tr>
- <% end -%>
-</table>
+<%= render :partial => "log", :locals => {:commits => @commits} -%>
<% content_for :submenu do -%>
<ul> |
| |   |
| 1 | <h1> |
| 2 | Browsing <%= link_to h(@repository.name), project_repository_path(@project, @repository) -%> |
| 3 | repository in <%= link_to h(@project.title), project_path(@project) -%> |
| 4 | </h1> |
| 5 | |
| 6 | <h2>Commit Log</h2> |
| 7 | <%= render :partial => "log", :locals => {:commits => @commits} -%> |
| 8 | |
| 9 | <%= render :partial => "submenu" -%> |
| 10 | |
| 11 | <% content_for :sidebar do -%> |
| 12 | <h5>Branches:</h5> |
| 13 | <ul class="links"> |
| 14 | <% @git.branches.each do |branch| -%> |
| 15 | <li><%= link_to h(branch.name), commit_path(branch.gcommit.sha) -%></li> |
| 16 | <% end -%> |
| 17 | </ul> |
| 18 | |
| 19 | <h5>Tags:</h5> |
| 20 | <ul class="links"> |
| 21 | <% @git.tags.each do |tag| -%> |
| 22 | <li><%= link_to h(tag.name), commit_path(tag.sha) -%></li> |
| 23 | <% end -%> |
| 24 | </ul> |
| 25 | <% end -%> |
| toggle raw diff |
--- /dev/null
+++ b/app/views/browse/log.html.erb
@@ -0,0 +1,25 @@
+<h1>
+ Browsing <%= link_to h(@repository.name), project_repository_path(@project, @repository) -%>
+ repository in <%= link_to h(@project.title), project_path(@project) -%>
+</h1>
+
+<h2>Commit Log</h2>
+<%= render :partial => "log", :locals => {:commits => @commits} -%>
+
+<%= render :partial => "submenu" -%>
+
+<% content_for :sidebar do -%>
+ <h5>Branches:</h5>
+ <ul class="links">
+ <% @git.branches.each do |branch| -%>
+ <li><%= link_to h(branch.name), commit_path(branch.gcommit.sha) -%></li>
+ <% end -%>
+ </ul>
+
+ <h5>Tags:</h5>
+ <ul class="links">
+ <% @git.tags.each do |tag| -%>
+ <li><%= link_to h(tag.name), commit_path(tag.sha) -%></li>
+ <% end -%>
+ </ul>
+<% end -%>
\ No newline at end of file |
| |   |
| 42 | 42 | repo.with_options(:controller => "browse") do |r| |
| 43 | 43 | r.browse "browse", :action => "index" |
| 44 | 44 | r.formatted_browse "browse.:format", :action => "index" |
| 45 | r.log "log", :action => "log" |
| 45 | 46 | r.tree "tree/:sha", :action => "tree", :sha => nil |
| 46 | 47 | r.blob "blob/:sha/:filename", :action => "blob", :requirements => {:filename => /.*/} |
| 47 | 48 | r.raw_blob "raw/:sha/:filename", :action => "raw", :requirements => {:filename => /.*/} |
| toggle raw diff |
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -42,6 +42,7 @@ ActionController::Routing::Routes.draw do |map|
repo.with_options(:controller => "browse") do |r|
r.browse "browse", :action => "index"
r.formatted_browse "browse.:format", :action => "index"
+ r.log "log", :action => "log"
r.tree "tree/:sha", :action => "tree", :sha => nil
r.blob "blob/:sha/:filename", :action => "blob", :requirements => {:filename => /.*/}
r.raw_blob "raw/:sha/:filename", :action => "raw", :requirements => {:filename => /.*/} |
| |   |
| 517 | 517 | table.shortlog tr td, table.tree tr td { |
| 518 | 518 | padding: 2px 5px 4px 5px; |
| 519 | 519 | } |
| 520 | table.shortlog tr td.link_to_more { |
| 521 | border-top: 1px solid #aaa; |
| 522 | padding: 2px; |
| 523 | } |
| 524 | table.shortlog tr td.link_to_more span { |
| 525 | float:right; |
| 526 | } |
| 520 | 527 | |
| 521 | 528 | table.tree tr td.node { |
| 522 | 529 | width: 75%; |
| toggle raw diff |
--- a/public/stylesheets/base.css
+++ b/public/stylesheets/base.css
@@ -517,6 +517,13 @@ span.tag {
table.shortlog tr td, table.tree tr td {
padding: 2px 5px 4px 5px;
}
+table.shortlog tr td.link_to_more {
+ border-top: 1px solid #aaa;
+ padding: 2px;
+}
+table.shortlog tr td.link_to_more span {
+ float:right;
+}
table.tree tr td.node {
width: 75%; |