Commit e18aa9eb8354775bd1e89ab9d9819f115b5c2bdb

Added full path to tree+blob uris

- added missing specs for BrowseHelper
- added future breadcrumbs (commented out for a reason still)

Commit diff

app/helpers/browse_helper.rb

 
88 project_repository_log_path(@project, @repository, args)
99 end
1010
11 def tree_path(sha1=nil)
12 project_repository_tree_path(@project, @repository, sha1)
11 def tree_path(sha1=nil, path=[])
12 project_repository_tree_path(@project, @repository, sha1, path)
1313 end
1414
1515 def commit_path(sha1)
1616 project_repository_commit_path(@project, @repository, sha1)
1717 end
1818
19 def blob_path(sha1, filename)
20 project_repository_blob_path(@project, @repository, sha1, filename)
19 def blob_path(sha1, path)
20 project_repository_blob_path(@project, @repository, sha1, path)
2121 end
2222
23 def raw_blob_path(sha1, filename)
24 project_repository_raw_blob_path(@project, @repository, sha1, filename)
23 def raw_blob_path(sha1, path)
24 project_repository_raw_blob_path(@project, @repository, sha1, path)
2525 end
2626
2727 def diff_path(sha1, other_sha1)
2828 project_repository_diff_path(@project, @repository, sha1, other_sha1)
2929 end
30
31 def current_path
32 params[:path].dup
33 end
34
35 def build_tree_path(path)
36 current_path << path
37 end
38
39 # def breadcrumb_path
40 # out = %Q{<ul class="path_breadcrumbs">\n}
41 # visited_path = []
42 # out << %Q{ <li>/ #{link_to("root", tree_path(params[:sha], []))}</li>\n}
43 # current_path.each_with_index do |path, index|
44 # visited_path << path
45 # out << %Q{ <li>/ #{link_to(path, tree_path(params[:sha], path))}</li>\n}
46 # end
47 # out << "</ul>"
48 # out
49 # end
3050
3151 def render_tag_box_if_match(sha, tags_per_sha)
3252 tags = tags_per_sha[sha]
toggle raw diff

app/views/browse/blob.html.erb

 
11<h1>
2 Blob of <code><%= params[:filename] -%></code>
3 <small>(<%= link_to "raw blob data", raw_blob_path(@blob.sha, params[:filename]) -%>)</small>
2 Blob of <code><%= current_path.join("/") -%></code>
3 <small>(<%= link_to "raw blob data", raw_blob_path(@blob.sha, current_path) -%>)</small>
44</h1>
55<pre><%=h @blob.contents -%></pre>
66
toggle raw diff

app/views/browse/tree.html.erb

 
88 <tr class="<%= cycle("odd", "even") -%>">
99 <!-- <td><%#= h(node.mode) -%></td> -->
1010 <% if node.type == "tree" -%>
11 <td class="node tree"><%= link_to h(file + "/"), tree_path(node.sha) -%></td>
12 <td class="link"><%= link_to node.type, tree_path(node.sha) -%></td>
11 <td class="node tree"><%= link_to h(file + "/"), tree_path(node.sha, build_tree_path(file)) -%></td>
12 <td class="link"><%= link_to node.type, tree_path(node.sha, build_tree_path(file)) -%></td>
1313 <!-- TODO: archive -->
1414 <% else -%>
15 <td class="node file"><%= link_to h(file), blob_path(node.sha, file) -%></td>
16 <td class="link"><%= link_to node.type, blob_path(node.sha, file) -%></td>
15 <td class="node file"><%= link_to h(file), blob_path(node.sha, build_tree_path(file)) -%></td>
16 <td class="link"><%= link_to node.type, blob_path(node.sha, build_tree_path(file)) -%></td>
1717 <% end -%>
1818 <td class="sha1"><%= h(node.sha[0..16]) -%></td>
1919 </tr>
toggle raw diff

public/stylesheets/base.css

 
445445 margin-bottom: 3em;
446446}
447447
448ul.path_breadcrumbs li {
449 display: inline;
450 margin:0;
451}
452
448453/* tags */
449454
450455ul.tag_list li {
toggle raw diff

spec/helpers/browse_helper_spec.rb

 
22
33describe BrowseHelper do
44
5 #Delete this example and add some real ones or delete this file
6 it "should include the BrowseHelper" do
7 included_modules = self.metaclass.send :included_modules
8 included_modules.should include(BrowseHelper)
5 before(:each) do
6 @project = projects(:johans)
7 @repository = @project.repositories.first
8 end
9
10 it "has a browse_path shortcut" do
11 browse_path.should == project_repository_browse_path(@project, @repository)
12 end
13
14 it "has a log_path shortcut" do
15 log_path.should == project_repository_log_path(@project, @repository)
16 end
17
18 it "has a log_path shortcut that takes args" do
19 log_path(:page => 2).should == project_repository_log_path(@project,
20 @repository, {:page => 2})
21 end
22
23 it "has a tree_path shortcut" do
24 tree_path.should == project_repository_tree_path(@project, @repository)
25 end
26
27 it "has a tree_path shortcut that takes an sha1" do
28 tree_path("abc123").should == project_repository_tree_path(@project,
29 @repository, "abc123")
30 end
31
32 it "has a tree_path shortcut that takes an sha1 and a path glob" do
33 tree_path("abc123", ["a", "b"]).should == project_repository_tree_path(@project,
34 @repository, "abc123", ["a", "b"])
35 end
36
37 it "has a commit_path shortcut" do
38 commit_path("abc123").should == project_repository_commit_path(@project,
39 @repository, "abc123")
40 end
41
42 it "has a blob_path shortcut" do
43 blob_path("sha", ["a","b"]).should == project_repository_blob_path(@project,
44 @repository, "sha", ["a","b"])
45 end
46
47 it "has a raw_blob_path shortcut" do
48 raw_blob_path("sha", ["a","b"]).should == project_repository_raw_blob_path(
49 @project, @repository, "sha", ["a","b"])
50 end
51
52 it "has a diff_path shortcut" do
53 diff_path("old", "new").should == project_repository_diff_path(@project,
54 @repository, "old", "new")
55 end
56
57 it "has a current_path based on the *path glob" do
58 params[:path] = ["one", "two"]
59 current_path.should == ["one", "two"]
60 end
61
62 it "builds a tree from current_path" do
63 params[:path] = ["one", "two"]
64 build_tree_path("three").should == ["one", "two", "three"]
65 end
66
67 it "builds breadcrumbs of the current_path" do
68 stub!(:current_path).and_return(["one", "two", "tree"])
69 breadcrumb_path.should include(%Q{<ul class="path_breadcrumbs">})
70 breadcrumb_path.should include("<li> / ")
971 end
1072
1173end
toggle raw diff