Class: Postmortem::Layout

Inherits:
Object
  • Object
show all
Defined in:
lib/postmortem/layout.rb

Overview

Wraps provided body in an enclosing layout for presentation purposes.

Instance Method Summary collapse

Constructor Details

#initialize(mail) ⇒ Layout

Returns a new instance of Layout.



6
7
8
# File 'lib/postmortem/layout.rb', line 6

def initialize(mail)
  @mail = mail
end

Instance Method Details

#contentObject



14
15
16
17
18
# File 'lib/postmortem/layout.rb', line 14

def content
  mail = @mail
  mail.html_body = with_inlined_images(mail.html_body) if defined?(Nokogiri)
  ERB.new(Postmortem.config.layout.read).result(binding)
end

#css_dependenciesObject



28
29
30
# File 'lib/postmortem/layout.rb', line 28

def css_dependencies
  default_layout_directory.join('dependencies.css').read
end

#favicon_b64Object



40
41
42
# File 'lib/postmortem/layout.rb', line 40

def favicon_b64
  default_layout_directory.join('favicon.b64').read
end

#format_email_array(array) ⇒ Object



10
11
12
# File 'lib/postmortem/layout.rb', line 10

def format_email_array(array)
  array&.map { |email| %(<a href="mailto:#{email}">#{email}</a>) }&.join(', ')
end

#headers_templateObject



36
37
38
# File 'lib/postmortem/layout.rb', line 36

def headers_template
  default_layout_directory.join('headers_template.html').read
end

#javascriptObject



24
25
26
# File 'lib/postmortem/layout.rb', line 24

def javascript
  default_layout_directory.join('layout.js').read
end

#javascript_dependenciesObject



32
33
34
# File 'lib/postmortem/layout.rb', line 32

def javascript_dependencies
  default_layout_directory.join('dependencies.js').read
end

#stylesObject



20
21
22
# File 'lib/postmortem/layout.rb', line 20

def styles
  default_layout_directory.join('layout.css').read
end

#upload_urlObject



44
45
46
# File 'lib/postmortem/layout.rb', line 44

def upload_url
  ENV.fetch('POSTMORTEM_DELIVERY_URL', 'https://postmortem.delivery/emails')
end