More refactoring ... Help from Gerald Britton.
svn: r12123
This commit is contained in:
		| @@ -101,6 +101,10 @@ from gen.lib.eventroletype import EventRoleType | ||||
| # constants | ||||
| # | ||||
| #------------------------------------------------------------------------ | ||||
| # Names for stylesheets | ||||
| _NARRATIVESCREEN = 'narrative-screen.css' | ||||
| _NARRATIVEPRINT = 'narrative-print.css' | ||||
|  | ||||
| # variables for alphabet_navigation | ||||
| _PERSON = 0 | ||||
| _PLACE = 1 | ||||
| @@ -394,33 +398,34 @@ class BasePage: | ||||
|             (const.PROGRAM_NAME, const.VERSION, const.URL_HOMEPAGE)) | ||||
|         of.write('\t<meta name="author" content="%s" />\n' % self.author) | ||||
|  | ||||
|         # Link to css behaviours | ||||
|         # Link to media reference regions behaviour stylesheet | ||||
|         fname = os.path.join("styles", "behaviour.css") | ||||
|         url = self.report.build_url_fname(fname, None, self.up) | ||||
|         of.write('\t<link href="%s" rel="stylesheet" ' | ||||
|             'type="text/css" media="screen">\n' % url) | ||||
|         of.write('\t<link href="%s" rel="stylesheet" \n' | ||||
|             '\t\ttype="text/css" media="screen" />\n' % url) | ||||
|  | ||||
|         # Link to screen stylesheet | ||||
|         fname = os.path.join("styles", self.report.css) | ||||
|         fname = os.path.join("styles", _NARRATIVESCREEN) | ||||
|         url = self.report.build_url_fname(fname, None, self.up) | ||||
|         of.write('\t<link href="%s" rel="stylesheet" ' | ||||
|             'type="text/css" media="screen" />\n' % url) | ||||
|         of.write('\t<link href="%s" rel="stylesheet" \n' | ||||
|             '\t\ttype="text/css" media="screen" />\n' % url) | ||||
|  | ||||
|         # Link to printer stylesheet | ||||
|         fname = os.path.join("styles", "Web_Print-Default.css") | ||||
|         fname = os.path.join("styles", _NARRATIVEPRINT) | ||||
|         url = self.report.build_url_fname(fname, None, self.up) | ||||
|         of.write('\t<link href="%s" rel="stylesheet" ' | ||||
|             'type="text/css" media="print" />\n' % url) | ||||
|         of.write('\t<link href="%s" rel="stylesheet" \n' | ||||
|             '\t\ttype="text/css" media="print" />\n' % url) | ||||
|  | ||||
|         # Link to GRAMPS favicon | ||||
|         url = self.report.build_url_image('favicon.ico', 'images', self.up) | ||||
|         of.write('\t<link href="%s" rel="Shortcut Icon" ' | ||||
|             'type="image/icon">\n' % url) | ||||
|         of.write('\t<link href="%s" rel="Shortcut Icon" \n' | ||||
|             '\t\ttype="image/icon" />\n' % url) | ||||
|         of.write('</head>\n\n') | ||||
|  | ||||
|         of.write('<body id="NarrativeWeb">\n')        # Terminated in write_footer() | ||||
|         of.write('<div id="header">\n') | ||||
|  | ||||
|         # begin header section | ||||
|         of.write('<div id="header">\n') | ||||
|         of.write('\t<h1 id="SiteTitle">%s</h1>\n' % html_escape(self.title_str)) | ||||
|         header = self.report.options['headernote'] | ||||
|         if header: | ||||
| @@ -2973,11 +2978,11 @@ class NavWebReport(Report): | ||||
|         # copy screen stylesheet | ||||
|         if self.css: | ||||
|             fname = os.path.join(const.DATA_DIR, self.css) | ||||
|             self.copy_file(fname, self.css, "styles") | ||||
|             self.copy_file(fname, _NARRATIVESCREEN, "styles") | ||||
|  | ||||
|         # copy printer stylesheet | ||||
|         fname = os.path.join(const.DATA_DIR, "Web_Print-Default.css") | ||||
|         self.copy_file(fname, "Web_Print-Default.css", "styles") | ||||
|         self.copy_file(fname, _NARRATIVEPRINT, "styles") | ||||
|  | ||||
|         imgs = [] | ||||
|  | ||||
| @@ -3630,4 +3635,4 @@ pmgr.register_report( | ||||
|     author_email = "don@gramps-project.org", | ||||
|     description = _("Produces web (HTML) pages for individuals, or a set of " | ||||
|                     "individuals"), | ||||
|     ) | ||||
|   ) | ||||
|   | ||||
| @@ -74,6 +74,10 @@ import libholiday | ||||
| # constants | ||||
| # | ||||
| #------------------------------------------------------------------------ | ||||
| # Calendar stylesheet names | ||||
| _CALENDARSCREEN = 'calendar-screen.css' | ||||
| _CALENDARPRINT = 'calendar-print.css' | ||||
|  | ||||
| # Mainz stylesheet graphics | ||||
| # will only be used if Mainz is slected as the stylesheet | ||||
| _WEBBKGD = "Web_Mainz_Bkgd.png" | ||||
| @@ -205,23 +209,13 @@ class WebCalReport(Report): | ||||
|         self.alive = mgobn('alive').get_value() | ||||
|         self.birthday = mgobn('birthdays').get_value() | ||||
|         self.anniv = mgobn('anniversaries').get_value() | ||||
|         self.home_link = mgobn('home_link').get_value().strip() | ||||
|         self.home_link = mgobn('home_link').get_value() | ||||
|  | ||||
|         self.month_notes  = [mgobn('note_jan').get_value(), | ||||
|                              mgobn('note_feb').get_value(), | ||||
|                              mgobn('note_mar').get_value(), | ||||
|                              mgobn('note_apr').get_value(), | ||||
|                              mgobn('note_may').get_value(), | ||||
|                              mgobn('note_jun').get_value(), | ||||
|                              mgobn('note_jul').get_value(), | ||||
|                              mgobn('note_aug').get_value(), | ||||
|                              mgobn('note_sep').get_value(), | ||||
|                              mgobn('note_oct').get_value(), | ||||
|                              mgobn('note_nov').get_value(), | ||||
|                              mgobn('note_dec').get_value()] | ||||
|         self.month_notes = [mgobn('note_' + month).get_value() \ | ||||
|             for month in ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']] | ||||
|  | ||||
|         # identify researcher name and e-mail address | ||||
|         # as Narrated WebSite already does | ||||
|         # as NarrativeWeb already does | ||||
|         researcher = get_researcher() | ||||
|         self.author = researcher.name | ||||
|         if self.author: | ||||
| @@ -328,11 +322,11 @@ class WebCalReport(Report): | ||||
|         # Copy the screen stylesheet | ||||
|         if self.css: | ||||
|             fname = os.path.join(const.DATA_DIR, self.css) | ||||
|             self.copy_file(fname, self.css, "styles") | ||||
|             self.copy_file(fname, _CALENDARSCREEN, "styles") | ||||
|  | ||||
|         # copy print stylesheet | ||||
|         fname = os.path.join(const.DATA_DIR, "Web_Print-Default.css") | ||||
|         self.copy_file(fname, "Web_Print-Default.css", "styles") | ||||
|         self.copy_file(fname, _CALENDARPRINT, "styles") | ||||
|  | ||||
|         # set imgs to empty | ||||
|         imgs = [] | ||||
| @@ -682,21 +676,19 @@ class WebCalReport(Report): | ||||
|             (const.PROGRAM_NAME, const.VERSION, const.URL_HOMEPAGE)) | ||||
|         of.write('\t<meta name="author" content="%s" />\n\n' % self.author) | ||||
|  | ||||
|         subdirs = ['..'] * nr_up | ||||
|  | ||||
|         # link to screen stylesheet | ||||
|         fname = '/'.join(subdirs + ['styles'] + [self.css]) | ||||
|         fname = '../'*nr_up + 'styles/' + _CALENDARSCREEN | ||||
|         of.write('\t<link rel="stylesheet" href="%s"\n' % fname) | ||||
|         of.write('\t\ttype="text/css" media="screen">\n') | ||||
|         of.write('\t\ttype="text/css" media="screen" />\n') | ||||
|  | ||||
|         # link to print stylesheet | ||||
|         if add_print: | ||||
|             fname = '/'.join(subdirs + ['styles'] + ["Web_Print-Default.css"]) | ||||
|             fname = '../'*nr_up + 'styles/' + _CALENDARPRINT | ||||
|             of.write('\t<link rel="stylesheet" href="%s"\n' % fname) | ||||
|             of.write('\t\ttype="text/css" media="print">\n') | ||||
|             of.write('\t\ttype="text/css" media="print" />\n') | ||||
|  | ||||
|         # link to GRAMPS favicon | ||||
|         fname = '/'.join(subdirs + ['images'] + ['favicon.ico']) | ||||
|         fname = '../'*nr_up + 'images/' + 'favicon.ico' | ||||
|         of.write('\t<link rel="shortcut icon" href="%s" \n' % fname) | ||||
|         of.write('\t\ttype="image/icon" />\n') | ||||
|  | ||||
| @@ -948,8 +940,7 @@ class WebCalReport(Report): | ||||
|         # do some error correcting if needed | ||||
|         if self.multiyear: | ||||
|             if self.end_year < self.start_year: | ||||
|                 # Huh? Why start_year+1? | ||||
|                 self.end_year = self.start_year + 1 | ||||
|                 self.end_year = self.start_year | ||||
|  | ||||
|         nr_up = 1                   # Number of directory levels up to get to self.html_dir / root | ||||
|  | ||||
| @@ -1350,8 +1341,8 @@ def _get_short_name(person, maiden_name=None): | ||||
|     """ Return person's name, unless maiden_name given,  | ||||
|     unless married_name listed. """ | ||||
|     # Get all of a person's names: | ||||
|     primary_name = person.get_primary_name() | ||||
|     sex = person.get_gender() | ||||
|     primary_name = person.primary_name | ||||
|     sex = person.gender | ||||
|  | ||||
|     married_name = None | ||||
|     names = [primary_name] + person.get_alternate_names() | ||||
| @@ -1362,20 +1353,17 @@ def _get_short_name(person, maiden_name=None): | ||||
|     # Now, decide which to use: | ||||
|     if maiden_name is not None: | ||||
|         if married_name is not None: | ||||
|             first_name, family_name = married_name.get_first_name(), \ | ||||
|                 _get_regular_surname(sex, married_name) | ||||
|             first_name, family_name = married_name.get_first_name(), _get_regular_surname(sex, married_name) | ||||
|             call_name = married_name.get_call_name() | ||||
|         else: | ||||
|             first_name, family_name = primary_name.get_first_name(), \ | ||||
|                 maiden_name | ||||
|             first_name, family_name = primary_name.get_first_name(), maiden_name | ||||
|             call_name = primary_name.get_call_name() | ||||
|     else: | ||||
|         first_name, family_name = primary_name.get_first_name(), \ | ||||
|             _get_regular_surname(sex, primary_name) | ||||
|         first_name, family_name = primary_name.get_first_name(), _get_regular_surname(sex, primary_name) | ||||
|         call_name = primary_name.get_call_name() | ||||
|  | ||||
|     # If they have a nickname use it | ||||
|     if call_name is not None and call_name.strip() != "": | ||||
|     if call_name is not None and call_name.strip() is not "": | ||||
|         first_name = call_name.strip() | ||||
|     else: # else just get the first name: | ||||
|         first_name = first_name.strip() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user