debian-mirror-gitlab/app/models/project_services/external_wiki_service.rb

42 lines
841 B
Ruby
Raw Normal View History

2018-11-20 20:47:30 +05:30
# frozen_string_literal: true
2015-04-26 12:48:37 +05:30
class ExternalWikiService < Service
prop_accessor :external_wiki_url
2015-12-23 02:04:40 +05:30
2018-11-08 19:23:39 +05:30
validates :external_wiki_url, presence: true, public_url: true, if: :activated?
2015-04-26 12:48:37 +05:30
def title
2019-07-31 22:56:46 +05:30
s_('ExternalWikiService|External Wiki')
2015-04-26 12:48:37 +05:30
end
def description
2019-07-31 22:56:46 +05:30
s_('ExternalWikiService|Replaces the link to the internal wiki with a link to an external wiki.')
2015-04-26 12:48:37 +05:30
end
2017-08-17 22:00:37 +05:30
def self.to_param
2015-04-26 12:48:37 +05:30
'external_wiki'
end
def fields
[
2020-03-13 15:44:24 +05:30
{
type: 'text',
name: 'external_wiki_url',
placeholder: s_('ExternalWikiService|The URL of the external Wiki'),
required: true
}
2015-04-26 12:48:37 +05:30
]
end
def execute(_data)
2020-03-13 15:44:24 +05:30
response = Gitlab::HTTP.get(properties['external_wiki_url'], verify: true)
response.body if response.code == 200
rescue
nil
2015-04-26 12:48:37 +05:30
end
2017-08-17 22:00:37 +05:30
def self.supported_events
%w()
end
2015-04-26 12:48:37 +05:30
end