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

33 lines
640 B
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
class ExternalWikiService < Service
include HTTParty
prop_accessor :external_wiki_url
2015-12-23 02:04:40 +05:30
validates :external_wiki_url, presence: true, url: true, if: :activated?
2015-04-26 12:48:37 +05:30
def title
'External Wiki'
end
def description
'Replaces the link to the internal wiki with a link to an external wiki.'
end
def to_param
'external_wiki'
end
def fields
[
{ type: 'text', name: 'external_wiki_url', placeholder: 'The URL of the external Wiki' },
]
end
def execute(_data)
@response = HTTParty.get(properties['external_wiki_url'], verify: true) rescue nil
2016-06-02 11:05:42 +05:30
if @response != 200
2015-04-26 12:48:37 +05:30
nil
end
end
end