Module: OddJob::HtmlRender

Included in:
FileUpload, Info
Defined in:
lib/oddjob.rb

Overview

A very basic utility for rendering OddJob specific pages.

Instance Method Summary collapse

Instance Method Details

#page(content, title) ⇒ Object

Wrap content in the standard page layout. title is set as the HTML page’s title.



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/oddjob.rb', line 97

def page(content, title)
  [
    "<!DOCTYPE html>",
    "<head>",
    "  <title>OJ #{title}</title>",
    "  <style>",
    "  body {font:100% arial,sans-serif; margin:1.5em 5em 4em 5em;}",
    "  a {text-decoration:none; color:rgb(248,157,30)}",
    "  a:hover {color:rgb(239,131,0);}",
    "  .header {font-size:0.75em; float:right; margin-bottom: 2.0em;}",
    "  .fineprint {font-size:0.85em;}",
    "  li {margin-bottom:0.4em;}",
    "  </style>",
    "</head>",
    "<html><body>",
    "  <div class=\"header\">",
    "    <em>v#{VERSION}</em>",
    "    <a href=\"https://github.com/MCF/oddjob\">OddJob on github</a>",
    "  </div>",
    "  <div style=\"clear:both;\"></div>",
       content.kind_of?(Array) ? content.join("\n") : content,
    "</body></html>",
  ].join("\n")
end