Module: Shipit::ShipitHelper

Defined in:
app/helpers/shipit/shipit_helper.rb

Instance Method Summary collapse

Instance Method Details

#emojify(content) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/helpers/shipit/shipit_helper.rb', line 14

def emojify(content)
  return unless content.present?

  h(content).to_str.gsub(/:([\w+-]+):/) do |match|
    if emoji = Emoji.find_by_alias($1)
      %(
          <img
            alt="##{$1}"
            src="#{image_path("emoji/#{emoji.image_filename}")}"
            style="vertical-align:middle"
            width="20"
            height="20"
          />
        )
    else
      match
    end
  end.html_safe
end

#include_plugins(stack) ⇒ Object



34
35
36
# File 'app/helpers/shipit/shipit_helper.rb', line 34

def include_plugins(stack)
  safe_join(stack.plugins.flat_map { |plugin, config| plugin_tags(plugin, config) })
end

#missing_github_app_messageObject



46
47
48
49
50
# File 'app/helpers/shipit/shipit_helper.rb', line 46

def missing_github_app_message
  <<-MESSAGE.html_safe
    Shipit requires a GitHub App to authenticate users and perform API calls.
  MESSAGE
end

#missing_host_messageObject



59
60
61
62
63
64
# File 'app/helpers/shipit/shipit_helper.rb', line 59

def missing_host_message
  <<-MESSAGE.html_safe
    Shipit needs the host of the application before generating links in background jobs.
    Add the host name to the secrets.yml file, under the <code>host</code> key.
  MESSAGE
end

#missing_redis_url_messageObject



52
53
54
55
56
57
# File 'app/helpers/shipit/shipit_helper.rb', line 52

def missing_redis_url_message
  <<-MESSAGE.html_safe
    Shipit needs a Redis server. Please configure the Redis URL in the secrets.yml file of your app,
    under the key <code>redis_url</code>.
  MESSAGE
end

#plugin_tags(plugin, config) ⇒ Object



38
39
40
41
42
43
44
# File 'app/helpers/shipit/shipit_helper.rb', line 38

def plugin_tags(plugin, config)
  tags = []
  tags << tag('meta', name: "#{plugin}-config", content: config.to_json) if config
  tags << javascript_include_tag("plugins/#{plugin}")
  tags << stylesheet_link_tag("plugins/#{plugin}")
  tags
end

#subscribe(url, *selectors) ⇒ Object



5
6
7
8
9
10
11
12
# File 'app/helpers/shipit/shipit_helper.rb', line 5

def subscribe(url, *selectors)
  content_for(:update_subscription) do
    [
      tag('meta', name: 'subscription-channel', content: url),
      *selectors.map { |s| tag('meta', name: 'subscription-selector', content: s) }
    ].join("\n").html_safe
  end
end