From 4e1b72ab60bb056f5901185534c531aa9ab271c2 Mon Sep 17 00:00:00 2001 From: SNoiraud Date: Fri, 11 Dec 2015 20:50:42 +0100 Subject: [PATCH] 8947 : Webcal: make it possible to easily move to the next day page having a birthday --- gramps/plugins/webreport/webcal.py | 54 +++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/gramps/plugins/webreport/webcal.py b/gramps/plugins/webreport/webcal.py index 61ed897f8..38c177dc3 100644 --- a/gramps/plugins/webreport/webcal.py +++ b/gramps/plugins/webreport/webcal.py @@ -94,6 +94,15 @@ _CALENDARPRINT = 'calendar-print.css' PLUGMAN = GuiPluginManager.get_instance() CSS = PLUGMAN.process_plugin_data('WEBSTUFF') +def _escape(string): + """ replace character in text that html shows correctly + special characters: & < and > + """ + string = string.replace('&', '&') # must be the first + string = string.replace('<', '<') + string = string.replace('>', '>') + return string + #------------------------------------------------------------------------ # # WebCalReport @@ -902,6 +911,28 @@ class WebCalReport(Report): year -- year being created """ + self.event_list = [] + prv = None + nxt = None + evdte = None + for month in sorted(self.calendar): + vals = sorted(self.calendar.get(month, {})) + if month == 0: # why ? + continue + for day in vals: + event_date = "%04d%02d%02d" % (year, month, day) + if evdte == None: + evdte = event_date + elif nxt == None: + nxt = event_date + self.event_list.append((evdte, prv, nxt)) + else: + prv = evdte + evdte = nxt + nxt = event_date + self.event_list.append((evdte, prv, nxt)) + self.event_list.append((nxt, evdte, None)) + nr_up = 1 # Number of directory levels up to get to root # generate progress pass for "Year At A Glance" @@ -993,7 +1024,28 @@ class WebCalReport(Report): # set date display as in user prevferences content = Html("div", class_="content", id = "OneDay") body += content - content += Html("h3", date_displayer.display(event_date), inline = True) + evt = fname_date[:8] + found = (evt, None, None) + for event in self.event_list: + if event[0] == evt: + found = event + break + my_title = Html() + url = "#" + if found[1] is not None: + url = event[1] + ".html" + my_title = Html("a", _escape("<"), href = url, title = _("Previous")) + else: + my_title = Html('  ') + my_title += Html("") + my_title += Html("span", " ") + my_title += date_displayer.display(event_date) + my_title += Html("span", " ") + if found[2] is not None: + url = event[2] + ".html" + my_title += Html("a", _escape(">"), href = url, title = _("Next")) + my_title += Html("") + content += Html("h3", my_title, inline = True) # list the events ordered = Html("ol")