2015-01-08 12:15:50 -05:00
|
|
|
class ExternalWikiService < Service
|
|
|
|
include HTTParty
|
|
|
|
|
|
|
|
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
|
|
|
|
[
|
|
|
|
{ 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-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
|