Skip to content

Inline html resources #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 20, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
inline or cdn all html resources
  • Loading branch information
bukzor committed May 19, 2014
commit d4b2b3a90e4aa2e1041369ecd31b28ce01160f59
60 changes: 37 additions & 23 deletions libcpychecker_html/make_html.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python
"""Make our data into HTML!"""
"""Make our data into HTML!
These reports should be usable as email attachments, so either inline or cdn *everything*.
"""
from __future__ import print_function

# Copyright 2012 Buck Golemon <buck@yelp.com>
Expand All @@ -17,6 +19,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
from os.path import realpath, dirname, join
HERE = dirname(realpath(__file__))

from . import capi

Expand Down Expand Up @@ -53,16 +57,30 @@ def head(self):
}),
E.TITLE('%s -- GCC Python Plugin' % self.data['filename']),
)
head.append(E.LINK(
rel='stylesheet',
href='http://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css',
type='text/css'
))
head.extend(
E.LINK(rel='stylesheet', href=css + '.css', type='text/css')
for css in ('extlib/reset-20110126', 'pygments_c', 'style')
E.STYLE(
file_contents(css + '.css'),
media='screen',
type='text/css'
)
for css in ('pygments_c', 'style')
)
head.extend(
E.SCRIPT(src=js + '.js')
E.SCRIPT(src=js)
for js in (
'extlib/prefixfree-1.0.4.min',
'extlib/jquery-1.7.1.min',
'script'
'http://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js',
'http://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.2/jquery.min.js',
)
)
head.append(
E.SCRIPT(
file_contents('script.js'),
type='text/javascript',
)
)
return head
Expand Down Expand Up @@ -136,38 +154,26 @@ def header(self):
E.DIV(
E.ATTR(id='bug-toggle'),
E.IMG(
src='images/bug.png',
src=data_uri('image/png', 'images/bug.png'),
),
E.H3('Bug'),
' [count]',
),
E.DIV(
E.ATTR(id='prev'),
E.IMG(
src='images/arrow-180.png',
src=data_uri('image/png', 'images/arrow-180.png'),
),
),
E.DIV(
E.ATTR(id='next'),
E.IMG(
src='images/arrow.png',
src=data_uri('image/png', 'images/arrow.png'),
),
),
),
)

@staticmethod
def footer():
"""make the footer"""
return E.E.footer(
E.ATTR(id='footer'),
E.P(' &nbsp;|&nbsp; '.join((
'Hackathon 7.0',
'Buck G, Alex M, Jason M',
'Yelp HQ 2012',
)))
)

def states(self):
"""Return an ordered-list of states, for each report."""
for report in self.data['reports']:
Expand Down Expand Up @@ -247,9 +253,17 @@ def body(self):
return E.BODY(
self.header(),
reports,
self.footer(),
)

def data_uri(mimetype, filename):
data = open(join(HERE, filename)).read().encode('base64').replace('\n', '')
return 'data:%s;base64,%s' % (mimetype, data)

def file_contents(filename):
# The leading newline makes the first line show up in the right spot.
return '\n' + open(join(HERE, filename)).read()


class CodeHtmlFormatter(HtmlFormatter):
"""Format our HTML!"""

Expand Down
15 changes: 6 additions & 9 deletions libcpychecker_html/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ img {
box-flex: 1;
overflow-y: auto;
}
#footer {
background: hsl(0, 0%, 30%);
box-shadow: inset 0 3px 3px -3px black;
color: white;
padding: 0.83em;
text-shadow: 0px 1px 0px black;
background-color: #09f;
}


/* Header */
Expand Down Expand Up @@ -395,6 +387,11 @@ td.selected .flow-dot {
}

.note:first-of-type::before {
content: url('images/exclamation.png');
/* content: url('images/exclamation.png');
* to regenerate:
* from libcpychecker_html.make_html import data_uri
* data_uri('image/png', 'images/exclamation.png')
*/
content: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAjBJREFUeNqkk0trE1EUx8/cO49OfGTSRNJMYsA0aVonoYh13YW71uJCKFQhKqibfgFLwYULsR/AhY+VG1d+C124kJiFIGipmoIZNUXtZDKTycz1njGpaRNU8MJv7txzzv/c5xEYY/A/TRQEAW5c5KwM+aKcR73/a5zvg84HT371wv07Apwuj0x+PZW/vArA4NO7x/f4+OGoIHLKAAiC/fBdHadSbCGZPTeTzC7OUElbQNvBOISMMnIqeqFSYs57mTkfZD1/qYS2f0rAZ5pVDmXnY/FSbn3jM6xvfAEtfjKnRDLz6BtK4PPPADi+ms6vGK71lti2DUintUVSJ84b6OvF7GlI4PNMPVgAZ49oxpyqRnXf+wGWZYX4ngWRiKYfPpqfw5hBjej7eweqCkSo6JOLhmd/hI7vQLVaBdM0YXt1FgK2CeJ40fCbmxUWsGc8vh3egtcFQPhyLsQnzpQJcbVmuw5mawtqtRo0Gg3wJQeY7ALIrqZEM2WM7esIPkROAgR5OZEpTTV3X4IXNEGiLnw1b4fItBNCBQuiqeQUA7qMGtSSLt8C38aVRLo47QVvVJFYoFAnJJG8FdIfI6rSVWMTx6ZRg1rS7UKeSspSMj2Wk+AbjPGZ+vTboA1JZbQcEcUl1Iq2zdZyxURBpruUMTzR38Vl79wM+9bO0/3vlwLVs+OF16/MNdFug/vi+Xadm+vDL/3uHyuR16Er4E3gKvEaOTLa/1LBuEQPF8hxfgowAINnMqTBUH7hAAAAAElFTkSuQmCC');
padding: 5px;
}