summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-05-13 12:06:51 -0500
committerDouwe Maan <douwe@selenight.nl>2017-05-16 15:51:22 -0500
commit7844fa1fc2e54de9b36f6bb2faa6d2f3385fc4f7 (patch)
tree053b42a3cce696ae37ed014f96cd3984b7a64b5a /app
parent67312fceaa69abb2bc88aa62601625e9f6a62270 (diff)
downloadgitlab-ce-7844fa1fc2e54de9b36f6bb2faa6d2f3385fc4f7.tar.gz
Add auxiliary viewer for CONTRIBUTINGdm-contributing-viewer
Diffstat (limited to 'app')
-rw-r--r--app/helpers/blob_helper.rb15
-rw-r--r--app/models/blob.rb4
-rw-r--r--app/models/blob_viewer/contributing.rb10
-rw-r--r--app/views/projects/blob/viewers/_contributing.html.haml9
4 files changed, 37 insertions, 1 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index 7eb3512378c..622e14e21ff 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -278,4 +278,19 @@ module BlobHelper
options
end
+
+ def contribution_options(project)
+ options = []
+
+ if can?(current_user, :create_issue, project)
+ options << link_to("submit an issue", new_namespace_project_issue_path(project.namespace, project))
+ end
+
+ merge_project = can?(current_user, :create_merge_request, project) ? project : (current_user && current_user.fork_of(project))
+ if merge_project
+ options << link_to("create a merge request", new_namespace_project_merge_request_path(project.namespace, project))
+ end
+
+ options
+ end
end
diff --git a/app/models/blob.rb b/app/models/blob.rb
index 63a81c0e3bd..e0c539a17cf 100644
--- a/app/models/blob.rb
+++ b/app/models/blob.rb
@@ -39,7 +39,9 @@ class Blob < SimpleDelegator
AUXILIARY_VIEWERS = [
BlobViewer::GitlabCiYml,
BlobViewer::RouteMap,
- BlobViewer::License
+
+ BlobViewer::License,
+ BlobViewer::Contributing
].freeze
attr_reader :project
diff --git a/app/models/blob_viewer/contributing.rb b/app/models/blob_viewer/contributing.rb
new file mode 100644
index 00000000000..fbd1dd48697
--- /dev/null
+++ b/app/models/blob_viewer/contributing.rb
@@ -0,0 +1,10 @@
+module BlobViewer
+ class Contributing < Base
+ include Auxiliary
+ include Static
+
+ self.partial_name = 'contributing'
+ self.file_types = %i(contributing)
+ self.binary = false
+ end
+end
diff --git a/app/views/projects/blob/viewers/_contributing.html.haml b/app/views/projects/blob/viewers/_contributing.html.haml
new file mode 100644
index 00000000000..c78f04c9c7c
--- /dev/null
+++ b/app/views/projects/blob/viewers/_contributing.html.haml
@@ -0,0 +1,9 @@
+= icon('book fw')
+After you've reviewed these contribution guidelines, you'll be all set to
+
+- options = contribution_options(viewer.project)
+- if options.any?
+ = succeed '.' do
+ = options.to_sentence(two_words_connector: ' or ', last_word_connector: ', or ').html_safe
+- else
+ contribute to this project.