Skip to content

Commit d2e5672

Browse files
committed
finish embedding all resources. small style fixes.
1 parent d4b2b3a commit d2e5672

File tree

2 files changed

+33
-18
lines changed

2 files changed

+33
-18
lines changed

libcpychecker_html/make_html.py

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#!/usr/bin/env python
22
"""Make our data into HTML!
3-
These reports should be usable as email attachments, so either inline or cdn *everything*.
3+
These reports should be usable as email attachments, offline.
4+
This means we need to embed *all* our assets.
5+
6+
TODO: #11 optimize the filesize
47
"""
58
from __future__ import print_function
9+
from __future__ import unicode_literals
610

711
# Copyright 2012 Buck Golemon <buck@yelp.com>
812
#
@@ -35,6 +39,16 @@
3539
from copy import deepcopy
3640
from itertools import islice
3741

42+
43+
def open(filename, mode='r'):
44+
"""All files are treated as UTF-8, unless explicitly binary."""
45+
from io import open
46+
if 'b' in mode:
47+
return open(filename, mode)
48+
else:
49+
return open(filename, mode, encoding='UTF-8')
50+
51+
3852
class HtmlPage(object):
3953
"""Represent one html page."""
4054
def __init__(self, codefile, data):
@@ -57,31 +71,24 @@ def head(self):
5771
}),
5872
E.TITLE('%s -- GCC Python Plugin' % self.data['filename']),
5973
)
60-
head.append(E.LINK(
61-
rel='stylesheet',
62-
href='http://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css',
63-
type='text/css'
64-
))
6574
head.extend(
6675
E.STYLE(
6776
file_contents(css + '.css'),
6877
media='screen',
6978
type='text/css'
7079
)
71-
for css in ('pygments_c', 'style')
80+
for css in ('extlib/reset-20110126', 'pygments_c', 'style')
7281
)
7382
head.extend(
74-
E.SCRIPT(src=js)
75-
for js in (
76-
'http://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js',
77-
'http://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.2/jquery.min.js',
78-
)
79-
)
80-
head.append(
8183
E.SCRIPT(
82-
file_contents('script.js'),
84+
file_contents(js + '.js'),
8385
type='text/javascript',
8486
)
87+
for js in (
88+
'extlib/prefixfree-1.0.4.min',
89+
'extlib/jquery-1.7.1.min',
90+
'script'
91+
)
8592
)
8693
return head
8794

@@ -256,7 +263,8 @@ def body(self):
256263
)
257264

258265
def data_uri(mimetype, filename):
259-
data = open(join(HERE, filename)).read().encode('base64').replace('\n', '')
266+
"represent a file as a data uri"
267+
data = open(join(HERE, filename), 'rb').read().encode('base64').replace('\n', '')
260268
return 'data:%s;base64,%s' % (mimetype, data)
261269

262270
def file_contents(filename):

libcpychecker_html/style.css

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ img {
5656
#reports {
5757
box-flex: 1;
5858
overflow-y: auto;
59+
overflow-x: hidden;
5960
}
6061

6162

@@ -64,7 +65,7 @@ img {
6465
display: box;
6566
box-orient: horizontal;
6667
width: 100%;
67-
padding: 1em;
68+
padding: 0.5em;
6869
box-sizing: border-box;
6970
color: white;
7071
}
@@ -182,6 +183,8 @@ img {
182183
line-height: 1.33;
183184
min-width: 40em;
184185
box-flex: 3;
186+
overflow-x: auto;
187+
border-right: 1px solid hsl(0, 0%, 70%);
185188
}
186189
.source > header {
187190
display: box;
@@ -277,9 +280,10 @@ img {
277280
text-align: right;
278281
user-select: none;
279282
color: hsl(0, 0%, 60%);
283+
vertical-align: middle;
280284
}
281285
.source .code {
282-
white-space: pre-wrap;
286+
white-space: pre;
283287
}
284288

285289

@@ -386,6 +390,9 @@ td.selected .flow-dot {
386390
min-width: 200px;
387391
}
388392

393+
.note {
394+
font-weight: bolder;
395+
}
389396
.note:first-of-type::before {
390397
/* content: url('images/exclamation.png');
391398
* to regenerate:

0 commit comments

Comments
 (0)