BigW Consortium Gitlab

external_wiki_service.rb 1.42 KB
Newer Older
1 2 3 4
# == Schema Information
#
# Table name: services
#
Stan Hu committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18
#  id                    :integer          not null, primary key
#  type                  :string(255)
#  title                 :string(255)
#  project_id            :integer
#  created_at            :datetime
#  updated_at            :datetime
#  active                :boolean          default(FALSE), not null
#  properties            :text
#  template              :boolean          default(FALSE)
#  push_events           :boolean          default(TRUE)
#  issues_events         :boolean          default(TRUE)
#  merge_requests_events :boolean          default(TRUE)
#  tag_push_events       :boolean          default(TRUE)
#  note_events           :boolean          default(TRUE), not null
Stan Hu committed
19
#  build_events          :boolean          default(FALSE), not null
20 21 22 23 24 25
#

class ExternalWikiService < Service
  include HTTParty

  prop_accessor :external_wiki_url
26 27

  validates :external_wiki_url, presence: true, url: true, if: :activated?
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

  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
    if @response !=200
      nil
    end
  end
end