+try:
+ config = read_config(path=args.config)
+except ConfigError as e:
+ print(e)
+ sys.exit(1)
+
+header_template = config['meta'].get('header', '''<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset={encoding}" />
+ <title>{title}</title>
+ <style media="screen" type="text/css">
+ table {{
+ border-spacing: 0;
+ }}
+ tr.message-first td {{
+ padding-top: {inter_message_padding};
+ }}
+ tr.message-last td {{
+ padding-bottom: {inter_message_padding};
+ }}
+ td {{
+ padding-left: {border_radius};
+ padding-right: {border_radius};
+ }}
+ tr:first-child td:first-child {{
+ border-top-left-radius: {border_radius};
+ }}
+ tr:first-child td:last-child {{
+ border-top-right-radius: {border_radius};
+ }}
+ tr:last-child td:first-child {{
+ border-bottom-left-radius: {border_radius};
+ }}
+ tr:last-child td:last-child {{
+ border-bottom-right-radius: {border_radius};
+ }}
+ tbody:nth-child(4n+1) tr td {{
+ background-color: #ffd96e;
+ }}
+ tbody:nth-child(4n+3) tr td {{
+ background-color: #bce;
+ }}
+ hr {{
+ border: 0;
+ height: 1px;
+ color: #ccc;
+ background-color: #ccc;
+ }}
+ </style>
+</head>
+<body>
+<h2>{title}</h2>
+{blurb}
+</p>
+<h3>Views</h3>
+''')
+
+footer_template = config['meta'].get('footer', '''
+<hr>
+<p>Generated: {datetime}
+</body>
+</html>
+''')
+
+now = datetime.datetime.utcnow()
+context = {
+ 'date': now,
+ 'datetime': now.strftime('%Y-%m-%d %H:%M:%SZ'),
+ 'title': config['meta']['title'],
+ 'blurb': config['meta']['blurb'],
+ 'encoding': _ENCODING,
+ 'inter_message_padding': '0.25em',
+ 'border_radius': '0.5em',
+ }
+
+_PAGES['text'] = Page()
+_PAGES['html'] = HtmlPage(
+ header=header_template.format(**context),
+ footer=footer_template.format(**context),
+ )