Coverage for khufu/scaffolding/body.py : 83%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# encoding: utf-8
2from khufu.scaffolding import _container
4def body(
5 navBar=False,
6 content="",
7 htmlId="",
8 extraAttr="",
9 relativeUrlBase=False,
10 responsive=True,
11 googleAnalyticsCode=False,
12 jsFilePath="main.js"
13):
14 """
15 *Generate an HTML body*
17 **Key Arguments**
19 - ``navBar`` -- the top navigation bar
20 - ``htmlId`` -- *id* attribute of the body
21 - ``content`` -- body content built from smaller HTML code blocks
22 - ``extraAttr`` -- an extra attributes to be added to the body definition
23 - ``relativeUrlBase`` -- how to get back to the document root
24 - ``responsive`` -- should the webpage be responsive to screen-size?
25 - ``googleAnalyticsCode`` -- google analytics code for the website
26 - ``jsFilePath`` -- the name of the main javascript file
29 **Return**
31 - ``body`` -- the body
33 """
34 if not navBar:
35 navBar = ""
37 if googleAnalyticsCode:
38 googleAnalyticsCode = """
39 <!-- Google Analytics -->
40 <script>
41 var _gaq=[['_setAccount','%(googleAnalyticsCode)s'],['_trackPageview']];
42 (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
43 g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
44 s.parentNode.insertBefore(g,s)}(document,'script'));
45 </script>
46 """ % locals()
47 else:
48 googleAnalyticsCode = ""
50 if relativeUrlBase is False:
51 relativeUrlBase = ""
53 container = _container(
54 responsive=responsive,
55 content=content,
56 htmlId=False,
57 htmlClass=False,
58 onPhone=True,
59 onTablet=True,
60 onDesktop=True,
61 )
63 body = \
64 """
65 <body id="%(htmlId)s" %(extraAttr)s>
66 <!--[if lt IE 7]>
67 <p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
68 <![endif]-->
69 %(navBar)s
70 %(container)s
71 <script src="%(jsFilePath)s"></script>
72 %(googleAnalyticsCode)s
73 </body><!-- /#%(htmlId)s-->
74 """ \
75 % locals()
77 return body