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#!/usr/local/bin/python
2# encoding: utf-8
3"""
4*The webpage scaffolding for the pessto marshall*
6:Author:
7 David Young
8"""
11def defaultpagetemplate(
12 log,
13 request,
14 bodyId=False,
15 pageTitle="ePESSTO+ Marshall",
16 topNavBar=False,
17 sideBar=False,
18 mainContent=False,
19 relativePathFromDocRoot=False,
20 thisPageName=""
21):
22 """Generate the webpage to be displayed
24 **Key Arguments**
26 - ``log`` -- logger
27 - ``bodyId`` -- the bodyId of the page
28 - ``pageTitle`` -- the title for the page (shows in browser tab)
29 - ``topNavBar`` -- topNavBar
30 - ``sideBar`` -- sideBar
31 - ``mainContent`` -- mainContent
32 - ``relativePathFromDocRoot`` -- the path to the assets folder relative to the document root
33 - ``thisPageName`` -- the name of the page currently displayed
34 - ``params`` -- dictionary of parameters passed to via the url of webpage
37 **Return**
39 - ``webpage`` -- the webpage to be displayed
41 """
42 log.debug('starting the ``webpage`` function')
44 import sys
45 import os
46 import khufu
47 from marshall_webapp.templates.commonelements import sidebar, topnavbar
49 # SET DEFAULT VARIABLES
50 if not bodyId:
51 bodyId = "inbox"
52 if not relativePathFromDocRoot:
53 relativePathFromDocRoot = ""
55 # SELECT THE SIDEBAR FLAVOUR
56 if not sideBar or sideBar == "marshall":
57 sideBar = sidebar.marshall_sidebar(
58 log=log,
59 request=request,
60 thisPageName=thisPageName
61 )
62 elif sideBar == "stats":
63 sideBar = sidebar.stats_sidebar(
64 log=log,
65 request=request,
66 thisPageName=thisPageName
67 )
68 elif sideBar == "xmatches":
69 sideBar = sidebar.xmatches_sidebar(
70 log=log,
71 request=request,
72 thisPageName=thisPageName
73 )
75 # SET DEFAULT TOP NAVBAR
76 if not topNavBar:
77 topNavBar = topnavbar.topnavbar(
78 log=log,
79 request=request
80 )
81 if not mainContent:
82 mainContent = khufu.image(
83 src='holder.js/900x700/auto/industrial/text:mainContent',
84 )
86 head = khufu.head(
87 relativeUrlBase=relativePathFromDocRoot,
88 mainCssFilePath=request.static_path(
89 'marshall_webapp:static/styles/css/main_marshall.css'),
90 pageTitle=pageTitle,
91 extras=''
92 )
94 sideBar = """<div id="leftSidebar">%(sideBar)s</div>""" % locals()
96 sideBarContainer = khufu.grid_column(
97 span=2, # 1-12
98 offset=0, # 1-12
99 content=sideBar,
100 )
102 pageContent = khufu.grid_column(
103 span=9, # 1-12
104 offset=0, # 1-12
105 content=mainContent
106 )
108 content = khufu.grid_row(
109 responsive=True,
110 columns="%(sideBarContainer)s %(pageContent)s" % locals(),
111 htmlId=False,
112 htmlClass=False,
113 onPhone=True,
114 onTablet=True,
115 onDesktop=True
116 )
118 body = khufu.body(
119 navBar=topNavBar,
120 content=content,
121 htmlId='',
122 extraAttr='',
123 relativeUrlBase=relativePathFromDocRoot,
124 responsive=True,
125 googleAnalyticsCode=False,
126 jsFilePath=request.static_path(
127 'marshall_webapp:static/js/main-ck.js')
128 )
130 webpage = khufu.htmlDocument(
131 contentType=False,
132 content="%(head)s %(body)s" % locals()
133 )
135 log.debug('completed the ``webpage`` function')
136 return webpage