2015-01-08 12:15:50 -05:00
|
|
|
class ExternalWikiService < Service
|
|
|
|
prop_accessor :external_wiki_url
|
2015-12-01 18:45:36 -05:00
|
|
|
|
|
|
|
validates :external_wiki_url, presence: true, url: true, if: :activated?
|
2015-01-08 12:15:50 -05:00
|
|
|
|
|
|
|
def title
|
|
|
|
'External Wiki'
|
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
|
|
|
'Replaces the link to the internal wiki with a link to an external wiki.'
|
|
|
|
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
|
|
|
|
[
|
2017-05-22 06:07:12 -04:00
|
|
|
{ type: 'text', name: 'external_wiki_url', placeholder: '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
|