fixed #2682 in NarrativeWeb.py, and fixed highlighting of currentsection in display_month_navs().

svn: r11976
This commit is contained in:
Rob G. Healey 2009-02-12 20:06:32 +00:00
parent 91b2861fc9
commit 5cc9c483ee
2 changed files with 27 additions and 42 deletions

View File

@ -78,7 +78,6 @@ import gen.lib
import const
from GrampsCfg import get_researcher
import Sort
import GrampsLocale
from gen.plug import PluginManager
from gen.plug.menu import PersonOption, NumberOption, StringOption, \
BooleanOption, EnumeratedListOption, FilterOption, \
@ -430,15 +429,6 @@ class BasePage:
Creates the navigation menu
"""
# Determine if there will be a link to WebCal or not???
use_webcal = False
webcal_link = self.report.webcal_link
if webcal_link.strip() != '':
if not webcal_link.endswith(self.ext):
webcal_link += self.ext
if os.path.isfile(webcal_link):
use_webcal = True
navs = [
(self.report.index_fname, _('Home'), self.report.use_home),
(self.report.intro_fname, _('Introduction'), self.report.use_intro),
@ -449,7 +439,6 @@ class BasePage:
('download', _('Download'), self.report.inc_download),
('contact', _('Contact'), self.report.use_contact),
('sources', _('Sources'), True),
(webcal_link, _('Web Calendar'), use_webcal),
]
of.write('\t<div id="navigation">\n')
@ -2851,8 +2840,6 @@ class NavWebReport(Report):
self.graph = self.options['graph']
self.webcal_link = self.options['webcal_link']
if self.use_home:
self.index_fname = "index"
self.surname_fname = "surnames"
@ -3427,13 +3414,6 @@ class NavWebOptions(MenuReportOptions):
nogid.set_help(_('Whether to include the Gramps ID of objects'))
menu.add_option(category_name, 'nogid', nogid)
today = time.localtime()
lng_month = GrampsLocale.long_months[today[1]]
fpath = '/'.join([const.USER_HOME] + ['WEBCAL'] + [str(today[0])] + [lng_month])
webcal_link = StringOption(_('Link to Web Calendar'), fpath)
webcal_link.set_help(_('Choose your link to Web Calendars if you want?'))
menu.add_option(category_name, 'webcal_link', webcal_link)
def __add_privacy_options(self, menu):
"""
Options on the "Privacy" tab.

View File

@ -389,43 +389,34 @@ class WebCalReport(Report):
for url_fname, nav_text, cond in navs:
url = ''
currentsection = False
cs = False
if cond:
subdirs = ['..'] * nr_up
subdirs.append(str(year))
# Note. We use '/' here because it is a URL, not a OS dependent pathname
if type(url_fname) == int:
url_fname = get_full_month_name(url_fname)
if type(nav_text) == int:
nav_text = get_short_month_name(nav_text)
# Figure out if we need stylesheet highlighting or not
highlight = ''
# Figure out if we need <li id="CurrentSection"> or just plain <li>
print url_fname, currentsection
if url_fname == currentsection:
highlight = ' id="CurrentSection"'
cs = True
# Note. We use '/' here because it is a URL, not a OS dependent pathname
url = url_fname
if not url.startswith('http:'):
url = '/'.join(subdirs + [url_fname])
# if url already ends with an extension, like home link?
# do not add subdirs
if url.endswith(self.ext):
subdirs = []
url = '/'.join(subdirs + [url_fname])
else:
url = '/'.join(subdirs + [url_fname])
if not url.endswith(self.ext):
url += self.ext
if not _has_webpage_extension(url, self.ext):
url += self.ext
if currentsection:
section = ' id="CurrentSection"'
else:
section = ''
cs = cs and ' id="CurrentSection"' or ''
of.write('\t\t<li%s><a href="%s">%s</a></li>\n'
% (section, url, nav_text))
% (cs, url, nav_text))
of.write('\t</ul>\n')
of.write('</div>\n\n')
@ -501,7 +492,7 @@ class WebCalReport(Report):
of.write('<div id="header">\n')
of.write('\t<h1 id="SiteTitle">%s</h1>\n' % title)
if self.author:
if self.email != '':
if self.email:
msg = _('Created for <a href="mailto:%(email)s?'
'subject=WebCal">%(author)s</a>\n') % {
'email' : self.email,
@ -769,11 +760,14 @@ class WebCalReport(Report):
"""
Create a file in the html_dir tree.
If the directory does not exist, create it.
fname -- filename to be created
subdir -- any subdirs to be added
"""
fname = os.path.join(self.html_dir, subdir, fname)
if not fname.endswith(self.ext):
if not _has_webpage_extension(fname, self.ext):
fname += self.ext
destdir = os.path.dirname(fname)
@ -988,7 +982,7 @@ class WebCalReport(Report):
# Add Header
self.write_header(of, nr_up, self.title_text, True)
of.write('<body id="Web Calendar">\n')
of.write('<body id="webcal">\n')
self.calendar_common(of, nr_up, year, cal_fname, self.title_text, True)
@ -1587,6 +1581,17 @@ def get_next_day(year, month, day_col):
next_month_day = firstweek_nextmonth[day_col]
return next_month_day
def _has_webpage_extension(url, ext):
"""
determine if a filename has an extension or not...
url = filename to be checked
"""
if url.endswith(ext):
return True
return False
#-------------------------------------------------------------------------
#
# Register Plugin