Class: Doze::Entity::HTML

Inherits:
Doze::Entity show all
Defined in:
lib/doze/serialization/html.rb

Constant Summary

Constants inherited from Doze::Entity

DEFAULT_TEXT_ENCODING

Instance Attribute Summary

Attributes inherited from Doze::Entity

#binary_data_length, #encoding, #extra_content_headers, #language, #media_type, #media_type_params

Instance Method Summary collapse

Methods inherited from Doze::Entity

#binary_data, #binary_data_stream, #etag, #initialize

Constructor Details

This class inherits a constructor from Doze::Entity

Instance Method Details

#serialize(data) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
58
59
# File 'lib/doze/serialization/html.rb', line 8

def serialize(data)
  # TODO move to a template
  html = <<END
<html>
  <head>
<style>
  body {
    font-family: Arial;
  }
  body, td {
    font-size: 13px;
  }
  body > table {
    border: 1px solid black;
  }
  table {
    border-color: black;
    border-collapse: collapse;
  }
  td {
    padding: 0;
    vertical-align: top;
  }
  td > span, td > a, td > form {
    display: block;
    padding: 0.3em;
    margin: 0;
  }
  td:first-child {
    text-align: right;
    font-weight: bold;
    width: 1%; /* force as small as possible */
  }
  td > table {
    width: 100%;
  }
  li > table {
    width: 100%;
  }
  td > ol {
    padding: 0.3em 0.3em 0.3em 2.3em;
  }
  td > ol > li > table {
  }
</style>
  </head>
  <body>
#{make_html(data)}
  </body>
</html>
END
end