|
3 | 3 | These reports should be usable as email attachments, offline. |
4 | 4 | This means we need to embed *all* our assets. |
5 | 5 |
|
6 | | -TODO: #11 optimize the filesize |
| 6 | +We make an exception for zepto; it's (relatively) big, and the behaviors |
| 7 | +it adds are non-essential to reading the report. |
7 | 8 | """ |
8 | 9 | from __future__ import print_function |
9 | 10 | from __future__ import unicode_literals |
@@ -79,13 +80,16 @@ def head(self): |
79 | 80 | ) |
80 | 81 | for css in ('extlib/reset-20110126.min', 'pygments_c', 'style') |
81 | 82 | ) |
| 83 | + head.append(E.SCRIPT( |
| 84 | + src='http://cdnjs.cloudflare.com/ajax/libs/zepto/1.1.3/zepto.js', |
| 85 | + type='text/javascript', |
| 86 | + )) |
82 | 87 | head.extend( |
83 | 88 | E.SCRIPT( |
84 | 89 | file_contents(js + '.js'), |
85 | 90 | type='text/javascript', |
86 | 91 | ) |
87 | 92 | for js in ( |
88 | | - 'extlib/zepto-1.1.3.min', |
89 | 93 | 'extlib/prefixfree-1.0.4.min', |
90 | 94 | 'script' |
91 | 95 | ) |
@@ -263,12 +267,14 @@ def body(self): |
263 | 267 | ) |
264 | 268 |
|
265 | 269 | def data_uri(mimetype, filename): |
266 | | - "represent a file as a data uri" |
267 | | - data = open(join(HERE, filename), 'rb').read().encode('base64').replace('\n', '') |
| 270 | + """represent a file as a data uri""" |
| 271 | + data = open(join(HERE, filename), 'rb').read() |
| 272 | + data = data.encode('base64').replace('\n', '') |
268 | 273 | return 'data:%s;base64,%s' % (mimetype, data) |
269 | 274 |
|
270 | 275 | def file_contents(filename): |
271 | | - # The leading newline makes the first line show up in the right spot. |
| 276 | + """Add a leading newline to make the first line show up in the right spot. |
| 277 | + """ |
272 | 278 | return '\n' + open(join(HERE, filename)).read() |
273 | 279 |
|
274 | 280 |
|
|
0 commit comments