2018-08-10 02:45:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-01-08 12:15:50 -05:00
|
|
|
class ExternalWikiService < Service
|
|
|
|
prop_accessor :external_wiki_url
|
2015-12-01 18:45:36 -05:00
|
|
|
|
2018-06-01 07:43:53 -04:00
|
|
|
validates :external_wiki_url, presence: true, public_url: true, if: :activated?
|
2015-01-08 12:15:50 -05:00
|
|
|
|
|
|
|
def title
|
2019-04-12 08:28:07 -04:00
|
|
|
s_('ExternalWikiService|External Wiki')
|
2015-01-08 12:15:50 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
2019-04-12 08:28:07 -04:00
|
|
|
s_('ExternalWikiService|Replaces the link to the internal wiki with a link to an external wiki.')
|
2015-01-08 12:15:50 -05:00
|
|
|
end
|
|
|
|
|
2016-12-27 07:44:24 -05:00
|
|
|
def self.to_param
|
2015-01-08 12:15:50 -05:00
|
|
|
'external_wiki'
|
|
|
|
end
|
|
|
|
|
|
|
|
def fields
|
|
|
|
[
|
2019-04-12 08:28:07 -04:00
|
|
|
{ type: 'text', name: 'external_wiki_url', placeholder: s_('ExternalWikiService|The URL of the external Wiki'), required: true }
|
2015-01-08 12:15:50 -05:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute(_data)
|
2018-03-13 18:38:25 -04:00
|
|
|
@response = Gitlab::HTTP.get(properties['external_wiki_url'], verify: true) rescue nil
|
2016-05-10 22:58:06 -04:00
|
|
|
if @response != 200
|
2015-01-08 12:15:50 -05:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
2016-12-27 07:44:24 -05:00
|
|
|
|
|
|
|
def self.supported_events
|
|
|
|
%w()
|
|
|
|
end
|
2015-01-08 12:15:50 -05:00
|
|
|
end
|