From bd08ac55c7b8eb1b41862937aa4f7cc7a53e4bfe Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Wed, 8 Jul 2015 13:41:03 +0200
Subject: [PATCH] Recommend user to create README file for both empty and
 existing project

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
---
 app/helpers/projects_helper.rb     |  7 +++++++
 app/views/projects/empty.html.haml | 10 ++++++----
 app/views/projects/show.html.haml  | 17 +++++++++++++----
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 74c8d4dad06..1bcd9a49527 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -259,4 +259,11 @@ module ProjectsHelper
   def leave_project_message(project)
     "Are you sure you want to leave \"#{project.name}\" project?"
   end
+
+  def new_readme_path
+    ref = @repository.root_ref if @repository
+    ref ||= 'master'
+
+    namespace_project_new_blob_path(@project.namespace, @project, tree_join(ref), file_name: 'README.md')
+  end
 end
diff --git a/app/views/projects/empty.html.haml b/app/views/projects/empty.html.haml
index f103fba404e..dfe45a3802d 100644
--- a/app/views/projects/empty.html.haml
+++ b/app/views/projects/empty.html.haml
@@ -8,11 +8,13 @@
   %h3.page-title
     The repository for this project is empty
   %p
-    You can
-    = link_to namespace_project_new_blob_path(@project.namespace, @project, 'master'), class: 'btn btn-new' do
-      add a file
-    &nbsp;or do a push via the command line.
+    If you already have files you can push them using command line instructions below.
+    %br
+    Otherwise you can start with
+    = link_to "adding README", new_readme_path, class: 'underlined-link'
+    file to this project.
 
+.prepend-top-20
 %h3.page-title
   Command line instructions
 %div.git-empty
diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml
index ceaf6c8cab3..8fb5f25c2f6 100644
--- a/app/views/projects/show.html.haml
+++ b/app/views/projects/show.html.haml
@@ -50,10 +50,19 @@
       .wiki
         = render_readme(readme)
   - else
-    %h4
-      Please
-      = link_to "add README", namespace_project_new_blob_path(@project.namespace, @project, tree_join(@repository.root_ref), file_name: 'README.md')
-      file to this repository
+    %h3.page-title
+      This project does not have README yet :(
+    - if can?(current_user, :push_code, @project)
+      %p.slead
+        A
+        %code README
+        file contains information about other files in a repository and is commonly
+        distributed with computer software, forming part of its documentation.
+        %br
+        We recommend you to
+        = link_to "add README", new_readme_path, class: 'underlined-link'
+        file to the repository and GitLab will render it here instead of this message.
+
 
 
 - if current_user
-- 
GitLab