summaryrefslogtreecommitdiff
path: root/lib/gitlab/markdown.rb
diff options
context:
space:
mode:
authorNikita Verkhovin <vernik91@gmail.com>2015-02-07 17:14:55 +0600
committerNikita Verkhovin <vernik91@gmail.com>2015-02-08 22:35:41 +0600
commit8681cb3137511e51e19f76aef9839be28f8fcd6a (patch)
treef2d5a929763d77b12c4248cc1bb50a01766bcbfe /lib/gitlab/markdown.rb
parent0a34f2dcb562098c481140246f7ac22683b38d76 (diff)
downloadgitlab-ce-8681cb3137511e51e19f76aef9839be28f8fcd6a.tar.gz
Add labels notes
Diffstat (limited to 'lib/gitlab/markdown.rb')
-rw-r--r--lib/gitlab/markdown.rb18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb
index 78627f413c2..fb0218a2778 100644
--- a/lib/gitlab/markdown.rb
+++ b/lib/gitlab/markdown.rb
@@ -92,7 +92,7 @@ module Gitlab
allowed_tags = ActionView::Base.sanitized_allowed_tags
sanitize text.html_safe,
- attributes: allowed_attributes + %w(id class),
+ attributes: allowed_attributes + %w(id class style),
tags: allowed_tags + %w(table tr td th)
end
@@ -128,6 +128,7 @@ module Gitlab
(?<prefix>\W)? # Prefix
( # Reference
@(?<user>#{NAME_STR}) # User name
+ |~(?<label>\d+) # Label ID
|(?<issue>([A-Z\-]+-)\d+) # JIRA Issue ID
|#{PROJ_STR}?\#(?<issue>([a-zA-Z\-]+-)?\d+) # Issue ID
|#{PROJ_STR}?!(?<merge_request>\d+) # MR ID
@@ -138,7 +139,7 @@ module Gitlab
(?<suffix>\W)? # Suffix
}x.freeze
- TYPES = [:user, :issue, :merge_request, :snippet, :commit].freeze
+ TYPES = [:user, :issue, :label, :merge_request, :snippet, :commit].freeze
def parse_references(text, project = @project)
# parse reference links
@@ -214,6 +215,19 @@ module Gitlab
end
end
+ def reference_label(identifier, project = @project, _ = nil)
+ if label = project.labels.find_by(id: identifier)
+ options = html_options.merge(
+ class: "gfm gfm-label #{html_options[:class]}"
+ )
+ link_to(
+ render_colored_label(label),
+ project_issues_path(project, label_name: label.name),
+ options
+ )
+ end
+ end
+
def reference_issue(identifier, project = @project, prefix_text = nil)
if project.default_issues_tracker?
if project.issue_exists? identifier