Commit 76e1ca64301d52fb25b0a0e8cb9d513ba7d33c46

Authored by randx
1 parent 453b2ae6

tree.readme method added

app/decorators/tree_decorator.rb
@@ -28,4 +28,8 @@ class TreeDecorator < ApplicationDecorator @@ -28,4 +28,8 @@ class TreeDecorator < ApplicationDecorator
28 file = File.join(path, "..") 28 file = File.join(path, "..")
29 h.project_tree_path(project, h.tree_join(ref, file)) 29 h.project_tree_path(project, h.tree_join(ref, file))
30 end 30 end
  31 +
  32 + def readme
  33 + @readme ||= contents.find { |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }
  34 + end
31 end 35 end
app/views/tree/_tree.html.haml
@@ -32,8 +32,8 @@ @@ -32,8 +32,8 @@
32 32
33 = render_tree(tree.contents) 33 = render_tree(tree.contents)
34 34
35 - - if readme = tree.contents.find { |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }  
36 - = render "tree/readme", readme: readme 35 + - if tree.readme
  36 + = render "tree/readme", readme: tree.readme
37 37
38 - unless tree.is_blob? 38 - unless tree.is_blob?
39 :javascript 39 :javascript