Class: MarkupEmail::HTMLify

Inherits:
Object
  • Object
show all
Defined in:
lib/markup_email/meta.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ HTMLify

Returns a new instance of HTMLify.



12
13
14
# File 'lib/markup_email/meta.rb', line 12

def initialize content
  @content = content
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



11
12
13
# File 'lib/markup_email/meta.rb', line 11

def content
  @content
end

#titleObject

Returns the value of attribute title.



10
11
12
# File 'lib/markup_email/meta.rb', line 10

def title
  @title
end

Instance Method Details

#documentizeObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/markup_email/meta.rb', line 16

def documentize
  @content = <<-HTML
<!DOCTYPE html>
<html>
  <head></head>
  <body>
<article class="markdown-body">#{@content}</article>
  </body>
</html>
HTML
end

#metaObject



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
54
55
56
57
# File 'lib/markup_email/meta.rb', line 28

def meta
  document = Nokogiri::HTML(@content)
  document.css('html')[0]['xmlns'  ] = "http://www.w3.org/1999/xhtml"
  document.css('html')[0]['xmlns:v'] = "urn:schemas-microsoft-com:vml"
  document.css('html')[0]['xmlns:o'] = "urn:schemas-microsoft-com:office:office"

  document.at_css('head') << <<-HTML
<!-- NAME: 1:2:1 COLUMN -->
<!--[if gte mso 15]>
<xml>
  <o:OfficeDocumentSettings>
  <o:AllowPNG/>
  <o:PixelsPerInch>96</o:PixelsPerInch>
  </o:OfficeDocumentSettings>
</xml>
<![endif]-->
HTML
  #github_framework = Net::HTTP.get(URI.parse("https://assets-cdn.github.com/assets/frameworks-2d2d4c150f7000385741c6b992b302689ecd172246c6428904e0813be9bceca6.css"))
  #github_primercss = Net::HTTP.get(URI.parse("https://assets-cdn.github.com/assets/github-0522ae8d3b3bdc841d2f91f90efd5f1fd9040d910905674cd134ced43a6dfea6.css"))

  # Include: #{Rouge::Themes::Tulip.render(scope: '.highlight')} in a style tag for rouge font rendering
  document.at_css('head') << <<-HTML
<title>#{@title}</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
HTML

  @content = document.to_s
end