Commit 76e1ca64301d52fb25b0a0e8cb9d513ba7d33c46
1 parent
453b2ae6
Exists in
master
and in
4 other branches
tree.readme method added
Showing
2 changed files
with
6 additions
and
2 deletions
Show diff stats
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 | ... | ... |