From 8dd150ad41c2a7b30acde34ded96ee18f2ae83b5 Mon Sep 17 00:00:00 2001 From: "Rob G. Healey" Date: Sat, 7 Feb 2009 20:41:27 +0000 Subject: [PATCH] cleanup and documentation work done. svn: r11903 --- src/data/Web_Visually.css | 8 +- src/plugins/webreport/WebCal.py | 218 +++++++++++++++----------------- 2 files changed, 107 insertions(+), 119 deletions(-) diff --git a/src/data/Web_Visually.css b/src/data/Web_Visually.css index 4105938a0..34e27b6d1 100644 --- a/src/data/Web_Visually.css +++ b/src/data/Web_Visually.css @@ -877,7 +877,7 @@ div#pedigree { padding:0; background:none; } -#tree #treeContainer div.boxbg span.unlinked { +#treeContainer div.boxbg span.unlinked { position:absolute; margin:0; padding:0; @@ -1096,6 +1096,12 @@ body#WebCal { color:#FFF; margin:-24px 10px 0 0; } +#CreatorInfo a { + color:#FFF; +} +#CreatorInfo a:hover { + color:#FFF; +} .calendar thead tr th.weekend, .calendar thead tr th.weekday { font-style:italic; diff --git a/src/plugins/webreport/WebCal.py b/src/plugins/webreport/WebCal.py index 8cf5b975a..b56cee21a 100644 --- a/src/plugins/webreport/WebCal.py +++ b/src/plugins/webreport/WebCal.py @@ -31,7 +31,6 @@ Refactoring. This is an ongoing job until this plugin is in a better shape. TODO list: - progress bar, rethink its usage - in year navigation, use month in link, or 'fullyear' - - use standard Gramps method to display surname, see _get_regular_surname - daylight saving not just for USA and Europe - move the close_file() from one_day() to caller """ @@ -79,6 +78,7 @@ from DateHandler import displayer as _dd from DateHandler import parser as _dp import libholiday +from libholiday import easter, dst #------------------------------------------------------------------------ # @@ -169,38 +169,6 @@ _COPY_OPTIONS = [ _('No copyright notice'), ] -# Compute the first day to display for this month. -# It can also be a day in the previous month. -def get_first_day(year, month): - current_date = datetime.date(year, month, 1) # first day of the month - - # monthinfo is filled using standard Python library - # calendar.monthcalendar. It fills a list of 7-day-lists. The first day - # of the 7-day-list is determined by calendar.firstweekday. - monthinfo = calendar.monthcalendar(year, month) - - current_ord = current_date.toordinal() - monthinfo[0].count(0) - return current_date, current_ord, monthinfo - -# get last month's last week for previous days in the month -def get_previous_day(year, month, day_col): - if month == 1: - prevmonth = calendar.monthcalendar(year - 1, 12) - else: - prevmonth = calendar.monthcalendar(year, month-1) - num_weeks = len(prevmonth) - lastweek_prevmonth = prevmonth[num_weeks - 1] - return lastweek_prevmonth[day_col] - -# get next month's first week for next days in the month -def get_next_day(year, month, day_col): - if month == 12: - nextmonth = calendar.monthcalendar(year + 1, 1) - else: - nextmonth = calendar.monthcalendar(year, month + 1) - firstweek_nextmonth = nextmonth[0] - return firstweek_nextmonth[day_col] - #------------------------------------------------------------------------ # # WebCalReport @@ -272,7 +240,6 @@ class WebCalReport(Report): self.today = datetime.date(today[0], today[1], today[2]) self.warn_dir = True # Only give warning once. - self.imgs = [] # self.calendar is a dict; key is the month number # Each entry in the dict is also a dict; key is the day number. @@ -356,10 +323,10 @@ class WebCalReport(Report): def copy_calendar_files(self): """ - Copies all the necessary files + Copies all the necessary stylesheets and images for these calendars """ - # Copy the normal stylesheet - if self.css != "": + # Copy the screen stylesheet + if self.css: fname = os.path.join(const.DATA_DIR, self.css) self.copy_file(fname, self.css, "styles") @@ -367,27 +334,40 @@ class WebCalReport(Report): fname = os.path.join(const.DATA_DIR, "Web_Print-Default.css") self.copy_file(fname, "Web_Print-Default.css", "styles") + # set imgs to empty + imgs = [] + + if self.css == "Web_Mainz.css": + # Copy Mainz Style Images + imgs += ["Web_Mainz_Bkgd.png", + "Web_Mainz_Header.png", + "Web_Mainz_Mid.png", + "Web_Mainz_MidLight.png", + ] + # Copy GRAMPS favicon - fname = os.path.join(const.IMAGE_DIR, "favicon.ico") - self.copy_file(fname, "favicon.ico", "images") + imgs += ['favicon.ico'] # copy copyright image if 0 < self.copy < len(_CC): - fname = os.path.join(const.IMAGE_DIR, 'somerights20.gif') - self.copy_file(fname, 'somerights20.gif', 'images') + imgs += ['somerights20.gif'] - for f in self.imgs: - from_path = os.path.join(const.IMAGE_DIR, f) - self.copy_file(from_path, f, "images") + for fname in imgs: + from_path = os.path.join(const.IMAGE_DIR, fname) + self.copy_file(from_path, fname, "images") - def display_month_navs(self, of, nr_up, year, currentsection, use_home=False): + def display_month_navs(self, of, nr_up, year, currentsection, use_home): """ Will create and display the navigation menu bar use_home will produce a link to wherever you specify as a home link - cal is one of these: - od = one_day(), wc = normal_cal(), yg = year_glance(), by = blank_year() + of = calendar filename being created + nr_up = number of directories up to reach root directory + year = year being created + currentsection = month name being created for proper CSS styling + use_home = if this is creating a link to home + -- a link to root directory of website """ navs = [] @@ -427,7 +407,7 @@ class WebCalReport(Report): url = url_fname if not url.startswith('http:'): url = '/'.join(subdirs + [url_fname]) - if not _has_webpage_extension(url): + if not url.endswith(self.ext): url += self.ext cs = cs and ' id="CurrentSection"' or '' @@ -439,6 +419,10 @@ class WebCalReport(Report): def display_year_navs(self, of, nr_up, currentsection): """ This will create the year navigation menu bar + + of = current calendar filename being created + nr_up = number of directories up to reach root directory + currentsection = proper styling of this navigation bar """ of.write('\n\n') - def calendar_common(self, of, nr_up, year, currsec1, title, use_home=False): + def calendar_common(self, of, nr_up, year, currentsection, title, use_home=False): """ Will create the common information for each calendar being created + + of = current filename being created, can be either web_cal(), or year_glance() + nr_up = number of directories up to reach root directory/ self.html_dir + year = year being created + currentsection = current section for proper styling of display_month_navs() + title = title for this calendar + use_home = for display_month_navs() to display a link to home + -- home directory of website """ # Header Title of.write('