2015-01-08 17:15:50 +00:00
|
|
|
class ExternalWikiService < Service
|
|
|
|
prop_accessor :external_wiki_url
|
2015-12-01 23:45:36 +00:00
|
|
|
|
2018-06-01 11:43:53 +00:00
|
|
|
validates :external_wiki_url, presence: true, public_url: true, if: :activated?
|
2015-01-08 17:15:50 +00: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 12:44:24 +00:00
|
|
|
def self.to_param
|
2015-01-08 17:15:50 +00:00
|
|
|
'external_wiki'
|
|
|
|
end
|
|
|
|
|
|
|
|
def fields
|
|
|
|
[
|
2017-05-22 10:07:12 +00:00
|
|
|
{ type: 'text', name: 'external_wiki_url', placeholder: 'The URL of the external Wiki', required: true }
|
2015-01-08 17:15:50 +00:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute(_data)
|
2018-03-13 22:38:25 +00:00
|
|
|
@response = Gitlab::HTTP.get(properties['external_wiki_url'], verify: true) rescue nil
|
2016-05-11 02:58:06 +00:00
|
|
|
if @response != 200
|
2015-01-08 17:15:50 +00:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
2016-12-27 12:44:24 +00:00
|
|
|
|
|
|
|
def self.supported_events
|
|
|
|
%w()
|
|
|
|
end
|
2015-01-08 17:15:50 +00:00
|
|
|
end
|