Commit 66de4ca183078200398e28ea12b47579a51b4eeb

paginated repos log views

Commit diff

TODO.txt

 
1[ ] Paginated log view (like git log --skip=100 --max-count=100)
21[ ] Nag project owners with no commits to the mainline repos after a week or two
32[ ] gitk-style branch view
43[ ] project homepage is an editable wiki-ish page
toggle raw diff

app/controllers/browse_controller.rb

 
5353 render :text => @blob.contents, :content_type => "text/plain"
5454 end
5555
56 @@per_page = 30
57
5658 def log
5759 @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
5974 end
6075
6176 def archive
toggle raw diff

app/helpers/browse_helper.rb

 
44 project_repository_browse_path(@project, @repository)
55 end
66
7 def log_path(args={})
8 project_repository_log_path(@project, @repository, args)
9 end
10
711 def tree_path(sha1=nil)
812 project_repository_tree_path(@project, @repository, sha1)
913 end
toggle raw diff

app/views/browse/_log.html.erb

 
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 "&#x2190; previous", log_path(:page => params[:page].to_i-1) -%> |
20 <% end -%>
21 <%= link_to "next &#x2192;", log_path(:page => (params[:page].blank? ? 2 : params[:page].to_i+1)) -%>
22 </span>
23 </td>
24 </tr>
25</table>
toggle raw diff

app/views/browse/_submenu.html.erb

 
11<% content_for :submenu do -%>
22 <ul>
3 <li><%= link_to "&#x2190; shortlog index", project_repository_browse_path(@project, @repository) -%></li>
3 <li><%= link_to "&#x2190; Browse repository", project_repository_browse_path(@project, @repository) -%></li>
44 <li><%= link_to "&#x2190; repository page",
55 project_repository_path(@project, @repository) -%></li>
66 <li><%= link_to "&#x2190; project page",
toggle raw diff

app/views/browse/index.html.erb

 
1111</ul>
1212
1313<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} -%>
2915
3016<% content_for :submenu do -%>
3117<ul>
toggle raw diff

app/views/browse/log.html.erb

 
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

config/routes.rb

 
4242 repo.with_options(:controller => "browse") do |r|
4343 r.browse "browse", :action => "index"
4444 r.formatted_browse "browse.:format", :action => "index"
45 r.log "log", :action => "log"
4546 r.tree "tree/:sha", :action => "tree", :sha => nil
4647 r.blob "blob/:sha/:filename", :action => "blob", :requirements => {:filename => /.*/}
4748 r.raw_blob "raw/:sha/:filename", :action => "raw", :requirements => {:filename => /.*/}
toggle raw diff

public/stylesheets/base.css

 
517517table.shortlog tr td, table.tree tr td {
518518 padding: 2px 5px 4px 5px;
519519}
520table.shortlog tr td.link_to_more {
521 border-top: 1px solid #aaa;
522 padding: 2px;
523}
524table.shortlog tr td.link_to_more span {
525 float:right;
526}
520527
521528table.tree tr td.node {
522529 width: 75%;
toggle raw diff