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
|
|
|
|
[
|
2020-01-08 16:08:08 -05: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)
|
2020-01-08 16:08:08 -05:00
|
|
|
response = Gitlab::HTTP.get(properties['external_wiki_url'], verify: true)
|
|
|
|
response.body if response.code == 200
|
|
|
|
rescue
|
|
|
|
nil
|
2015-01-08 12:15:50 -05:00
|
|
|
end
|
2016-12-27 07:44:24 -05:00
|
|
|
|
|
|
|
def self.supported_events
|
|
|
|
%w()
|
|
|
|
end
|
2015-01-08 12:15:50 -05:00
|
|
|
end
|