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 28 file = File.join(path, "..")
29 29 h.project_tree_path(project, h.tree_join(ref, file))
30 30 end
  31 +
  32 + def readme
  33 + @readme ||= contents.find { |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }
  34 + end
31 35 end
... ...
app/views/tree/_tree.html.haml
... ... @@ -32,8 +32,8 @@
32 32  
33 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 38 - unless tree.is_blob?
39 39 :javascript
... ...