diff --git a/dosagelib/events.py b/dosagelib/events.py index 4ea2b6728..888b2e81d 100644 --- a/dosagelib/events.py +++ b/dosagelib/events.py @@ -144,6 +144,11 @@ class HtmlEventHandler(EventHandler): fn = os.path.abspath(fn) return fn + def addNavLinks(self): + if self.yesterdayUrl: + self.html.write(u'Previous Day | ' % self.yesterdayUrl) + self.html.write(u'Next Day\n' % self.tomorrowUrl) + def start(self): """Start HTML output.""" today = time.time() @@ -167,10 +172,10 @@ class HtmlEventHandler(EventHandler): try: fn_yesterday = self.fnFromDate(yesterday) fn_yesterday = util.getExistingFile(fn_yesterday) - yesterdayUrl = self.getUrlFromFilename(fn_yesterday) + self.yesterdayUrl = self.getUrlFromFilename(fn_yesterday) except ValueError: - yesterdayUrl = None - tomorrowUrl = self.getUrlFromFilename(self.fnFromDate(tomorrow)) + self.yesterdayUrl = None + self.tomorrowUrl = self.getUrlFromFilename(self.fnFromDate(tomorrow)) self.html = codecs.open(fn, 'w', self.encoding) self.html.write(u''' @@ -182,9 +187,8 @@ class HtmlEventHandler(EventHandler): ''' % (self.encoding, configuration.App, time.strftime('%Y/%m/%d', today))) - if yesterdayUrl: - self.html.write(u'Previous Day | ' % yesterdayUrl) - self.html.write(u'Next Day -Previous Day | Next Day - -''') % (yesterdayUrl, tomorrowUrl) + self.html.write(u'\n') + self.addNavLinks() self.html.close()