Commit 81fe86b4279775b3cbed2d64529d671d6fbe49d2
1 parent
071de30f
Exists in
master
and in
4 other branches
README link from project home page
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
2 changed files
with
13 additions
and
0 deletions
Show diff stats
app/models/repository.rb
@@ -133,6 +133,7 @@ class Repository | @@ -133,6 +133,7 @@ class Repository | ||
133 | Rails.cache.delete(cache_key(:tag_names)) | 133 | Rails.cache.delete(cache_key(:tag_names)) |
134 | Rails.cache.delete(cache_key(:commit_count)) | 134 | Rails.cache.delete(cache_key(:commit_count)) |
135 | Rails.cache.delete(cache_key(:graph_log)) | 135 | Rails.cache.delete(cache_key(:graph_log)) |
136 | + Rails.cache.delete(cache_key(:readme)) | ||
136 | end | 137 | end |
137 | 138 | ||
138 | def graph_log | 139 | def graph_log |
@@ -159,4 +160,10 @@ class Repository | @@ -159,4 +160,10 @@ class Repository | ||
159 | def blob_at(sha, path) | 160 | def blob_at(sha, path) |
160 | Gitlab::Git::Blob.find(self, sha, path) | 161 | Gitlab::Git::Blob.find(self, sha, path) |
161 | end | 162 | end |
163 | + | ||
164 | + def readme | ||
165 | + Rails.cache.fetch(cache_key(:readme)) do | ||
166 | + Tree.new(self, self.root_ref).readme | ||
167 | + end | ||
168 | + end | ||
162 | end | 169 | end |
app/views/projects/show.html.haml
@@ -31,6 +31,12 @@ | @@ -31,6 +31,12 @@ | ||
31 | %span Download | 31 | %span Download |
32 | = link_to project_compare_index_path(@project, from: @repository.root_ref, to: @ref || @repository.root_ref), class: 'btn btn-block' do | 32 | = link_to project_compare_index_path(@project, from: @repository.root_ref, to: @ref || @repository.root_ref), class: 'btn btn-block' do |
33 | Compare code | 33 | Compare code |
34 | + | ||
35 | + - if @repository.readme | ||
36 | + - readme = @repository.readme | ||
37 | + = link_to project_blob_path(@project, tree_join(@repository.root_ref, readme.name)), class: 'btn btn-block' do | ||
38 | + = readme.name | ||
39 | + | ||
34 | .prepend-top-10 | 40 | .prepend-top-10 |
35 | %p | 41 | %p |
36 | %span.light Created on | 42 | %span.light Created on |