2016-08-11 12:08:27 +00:00
|
|
|
module Gitlab
|
|
|
|
module Badge
|
|
|
|
##
|
|
|
|
# Abstract class for badge metadata
|
|
|
|
#
|
|
|
|
class Metadata
|
2017-06-29 17:06:35 +00:00
|
|
|
include Gitlab::Routing.url_helpers
|
2016-08-11 12:08:27 +00:00
|
|
|
include ActionView::Helpers::AssetTagHelper
|
|
|
|
include ActionView::Helpers::UrlHelper
|
|
|
|
|
|
|
|
def initialize(badge)
|
|
|
|
@badge = badge
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_html
|
|
|
|
link_to(image_tag(image_url, alt: title), link_url)
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_markdown
|
|
|
|
"[![#{title}](#{image_url})](#{link_url})"
|
|
|
|
end
|
|
|
|
|
2017-02-11 19:15:01 +00:00
|
|
|
def to_asciidoc
|
|
|
|
"image:#{image_url}[link=\"#{link_url}\",title=\"#{title}\"]"
|
|
|
|
end
|
|
|
|
|
2016-08-11 12:08:27 +00:00
|
|
|
def title
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
def image_url
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
def link_url
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|