nmbug-status: Factor out header/footer context into a shared dict

Rather than splitting this context into header-only and footer-only
groups, just dump it all in a shared dict.  This will make it easier
to eventually split the header/footer templates out of this script
(e.g. if we want to load them from the config file).
This commit is contained in:
W. Trevor King 2014-05-31 15:20:25 -07:00 committed by David Bremner
parent b70386a4cb
commit 7832258468

View file

@ -275,6 +275,14 @@ parser.add_argument('--get-query', help='get query for view',
args = parser.parse_args() args = parser.parse_args()
config = read_config(path=args.config) config = read_config(path=args.config)
context = {
'date': datetime.datetime.utcnow(),
'title': config['meta']['title'],
'blurb': config['meta']['blurb'],
'encoding': _ENCODING,
'inter_message_padding': '0.25em',
'border_radius': '0.5em',
}
_PAGES['text'] = Page() _PAGES['text'] = Page()
_PAGES['html'] = HtmlPage( _PAGES['html'] = HtmlPage(
@ -328,17 +336,13 @@ _PAGES['html'] = HtmlPage(
{blurb} {blurb}
</p> </p>
<h3>Views</h3> <h3>Views</h3>
'''.format(title=config['meta']['title'], '''.format(**context),
blurb=config['meta']['blurb'],
encoding=_ENCODING,
inter_message_padding='0.25em',
border_radius='0.5em'),
footer=''' footer='''
<hr> <hr>
<p>Generated: {date} <p>Generated: {date}
</body> </body>
</html> </html>
'''.format(date=datetime.datetime.utcnow().date()) '''.format(**context),
) )
if args.list_views: if args.list_views: