Fix scope in HTML output.
This commit is contained in:
parent
5b2ce4350e
commit
2c1ff889fa
1 changed files with 12 additions and 10 deletions
|
@ -144,6 +144,11 @@ class HtmlEventHandler(EventHandler):
|
||||||
fn = os.path.abspath(fn)
|
fn = os.path.abspath(fn)
|
||||||
return fn
|
return fn
|
||||||
|
|
||||||
|
def addNavLinks(self):
|
||||||
|
if self.yesterdayUrl:
|
||||||
|
self.html.write(u'<a href="%s">Previous Day</a> | ' % self.yesterdayUrl)
|
||||||
|
self.html.write(u'<a href="%s">Next Day</a>\n' % self.tomorrowUrl)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
"""Start HTML output."""
|
"""Start HTML output."""
|
||||||
today = time.time()
|
today = time.time()
|
||||||
|
@ -167,10 +172,10 @@ class HtmlEventHandler(EventHandler):
|
||||||
try:
|
try:
|
||||||
fn_yesterday = self.fnFromDate(yesterday)
|
fn_yesterday = self.fnFromDate(yesterday)
|
||||||
fn_yesterday = util.getExistingFile(fn_yesterday)
|
fn_yesterday = util.getExistingFile(fn_yesterday)
|
||||||
yesterdayUrl = self.getUrlFromFilename(fn_yesterday)
|
self.yesterdayUrl = self.getUrlFromFilename(fn_yesterday)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
yesterdayUrl = None
|
self.yesterdayUrl = None
|
||||||
tomorrowUrl = self.getUrlFromFilename(self.fnFromDate(tomorrow))
|
self.tomorrowUrl = self.getUrlFromFilename(self.fnFromDate(tomorrow))
|
||||||
|
|
||||||
self.html = codecs.open(fn, 'w', self.encoding)
|
self.html = codecs.open(fn, 'w', self.encoding)
|
||||||
self.html.write(u'''<!DOCTYPE html>
|
self.html.write(u'''<!DOCTYPE html>
|
||||||
|
@ -182,9 +187,8 @@ class HtmlEventHandler(EventHandler):
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
''' % (self.encoding, configuration.App, time.strftime('%Y/%m/%d', today)))
|
''' % (self.encoding, configuration.App, time.strftime('%Y/%m/%d', today)))
|
||||||
if yesterdayUrl:
|
self.addNavLinks()
|
||||||
self.html.write(u'<a href="%s">Previous Day</a> | ' % yesterdayUrl)
|
self.html.write(u'<ul>\n')
|
||||||
self.html.write(u'<a href="%s">Next Day</a><ul>' % tomorrowUrl)
|
|
||||||
# last comic name (eg. CalvinAndHobbes)
|
# last comic name (eg. CalvinAndHobbes)
|
||||||
self.lastComic = None
|
self.lastComic = None
|
||||||
# last comic strip URL (eg. http://example.com/page42)
|
# last comic strip URL (eg. http://example.com/page42)
|
||||||
|
@ -223,10 +227,8 @@ class HtmlEventHandler(EventHandler):
|
||||||
self.html.write(u'</li>\n')
|
self.html.write(u'</li>\n')
|
||||||
if self.lastComic is not None:
|
if self.lastComic is not None:
|
||||||
self.html.write(u'</ul>\n')
|
self.html.write(u'</ul>\n')
|
||||||
self.html.write(u'''</ul>
|
self.html.write(u'</ul>\n')
|
||||||
<a href="%s">Previous Day</a> | <a href="%s">Next Day</a>
|
self.addNavLinks()
|
||||||
</body>
|
|
||||||
</html>''') % (yesterdayUrl, tomorrowUrl)
|
|
||||||
self.html.close()
|
self.html.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue