diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-04-15 22:56:45 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-04-25 21:39:45 +0300 |
commit | a6defd157641b102c9ea4cabe99f0a386d661d80 (patch) | |
tree | eca298e3d42c0bb95c36492adefadb35ad64c374 /lib | |
parent | 85082de780b500a3469db7867cd938154fc0622f (diff) |
Add results to reference filters
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/markdown/commit_range_reference_filter.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/markdown/commit_reference_filter.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/markdown/issue_reference_filter.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/markdown/label_reference_filter.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/markdown/merge_request_reference_filter.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/markdown/snippet_reference_filter.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/markdown/user_reference_filter.rb | 7 |
7 files changed, 22 insertions, 2 deletions
diff --git a/lib/gitlab/markdown/commit_range_reference_filter.rb b/lib/gitlab/markdown/commit_range_reference_filter.rb index baa97bee9bf..5e5e7adc238 100644 --- a/lib/gitlab/markdown/commit_range_reference_filter.rb +++ b/lib/gitlab/markdown/commit_range_reference_filter.rb @@ -59,6 +59,8 @@ module Gitlab from_id, to_id = split_commit_range(commit_range) if valid_range?(project, from_id, to_id) + push_result(:commit_range, [commit(from_id), commit(to_id)]) + url = url_for_commit_range(project, from_id, to_id) title = "Commits #{from_id} through #{to_id}" diff --git a/lib/gitlab/markdown/commit_reference_filter.rb b/lib/gitlab/markdown/commit_reference_filter.rb index 66598127f6e..41fb03cdd41 100644 --- a/lib/gitlab/markdown/commit_reference_filter.rb +++ b/lib/gitlab/markdown/commit_reference_filter.rb @@ -48,6 +48,8 @@ module Gitlab project = self.project_from_ref(project_ref) if commit = commit_from_ref(project, commit_ref) + push_result(:commit, commit) + url = url_for_commit(project, commit) title = escape_once(commit.link_title) diff --git a/lib/gitlab/markdown/issue_reference_filter.rb b/lib/gitlab/markdown/issue_reference_filter.rb index c9267cc3e9d..4b360369d37 100644 --- a/lib/gitlab/markdown/issue_reference_filter.rb +++ b/lib/gitlab/markdown/issue_reference_filter.rb @@ -48,6 +48,9 @@ module Gitlab project = self.project_from_ref(project_ref) if project && project.issue_exists?(issue) + # FIXME (rspeicher): Law of Demeter + push_result(:issue, project.issues.where(iid: issue).first) + url = url_for_issue(issue, project, only_path: context[:only_path]) title = escape_once("Issue: #{title_for_issue(issue, project)}") diff --git a/lib/gitlab/markdown/label_reference_filter.rb b/lib/gitlab/markdown/label_reference_filter.rb index 4c21192c0d3..a357f28458d 100644 --- a/lib/gitlab/markdown/label_reference_filter.rb +++ b/lib/gitlab/markdown/label_reference_filter.rb @@ -52,11 +52,13 @@ module Gitlab params = label_params(id, name) if label = project.labels.find_by(params) - url = url_for_label(project, label) + push_result(:label, label) + url = url_for_label(project, label) klass = reference_class(:label) - %(<a href="#{url}" class="#{klass}">#{render_colored_label(label)}</a>) + %(<a href="#{url}" + class="#{klass}">#{render_colored_label(label)}</a>) else match end diff --git a/lib/gitlab/markdown/merge_request_reference_filter.rb b/lib/gitlab/markdown/merge_request_reference_filter.rb index 40239523cda..7c28fe112ef 100644 --- a/lib/gitlab/markdown/merge_request_reference_filter.rb +++ b/lib/gitlab/markdown/merge_request_reference_filter.rb @@ -48,6 +48,8 @@ module Gitlab project = self.project_from_ref(project_ref) if project && merge_request = project.merge_requests.find_by(iid: id) + push_result(:merge_request, merge_request) + title = escape_once("Merge Request: #{merge_request.title}") klass = reference_class(:merge_request) diff --git a/lib/gitlab/markdown/snippet_reference_filter.rb b/lib/gitlab/markdown/snippet_reference_filter.rb index ada67de992b..64a0a2696f7 100644 --- a/lib/gitlab/markdown/snippet_reference_filter.rb +++ b/lib/gitlab/markdown/snippet_reference_filter.rb @@ -48,6 +48,8 @@ module Gitlab project = self.project_from_ref(project_ref) if project && snippet = project.snippets.find_by(id: id) + push_result(:snippet, snippet) + title = escape_once("Snippet: #{snippet.title}") klass = reference_class(:snippet) diff --git a/lib/gitlab/markdown/user_reference_filter.rb b/lib/gitlab/markdown/user_reference_filter.rb index 5fc8ed55fe2..d3af206335d 100644 --- a/lib/gitlab/markdown/user_reference_filter.rb +++ b/lib/gitlab/markdown/user_reference_filter.rb @@ -44,18 +44,25 @@ module Gitlab klass = reference_class(:project_member) if user == 'all' + # FIXME (rspeicher): Law of Demeter + push_result(:user, project.team.members.flatten) + url = link_to_all(project) %(<a href="#{url}" class="#{klass}">@#{user}</a>) elsif namespace = Namespace.find_by(path: user) if namespace.is_a?(Group) if user_can_reference_group?(namespace) + push_result(:user, namespace.users) + url = group_url(user, only_path: context[:only_path]) %(<a href="#{url}" class="#{klass}">@#{user}</a>) else match end else + push_result(:user, namespace.owner) + url = user_url(user, only_path: context[:only_path]) %(<a href="#{url}" class="#{klass}">@#{user}</a>) end |