Improve the code in display_month_navs a little further.
Added the home link in the year pages. * src/plugins/webreport/WebCal.py svn: r11991
This commit is contained in:
parent
9e2f82b371
commit
2bbf40e609
@ -362,8 +362,6 @@ class WebCalReport(Report):
|
|||||||
"""
|
"""
|
||||||
Will create and display the navigation menu bar
|
Will create and display the navigation menu bar
|
||||||
|
|
||||||
use_home will produce a link to wherever you specify as a home link
|
|
||||||
|
|
||||||
of = calendar filename being created
|
of = calendar filename being created
|
||||||
nr_up = number of directories up to reach root directory
|
nr_up = number of directories up to reach root directory
|
||||||
year = year being created
|
year = year being created
|
||||||
@ -374,48 +372,40 @@ class WebCalReport(Report):
|
|||||||
|
|
||||||
navs = []
|
navs = []
|
||||||
|
|
||||||
# check to see if we are using a home link???
|
# An optional link to a home page
|
||||||
if use_home:
|
navs.append((self.home_link, _('Home'), use_home))
|
||||||
navs.append((self.home_link, _('Home'), True))
|
|
||||||
|
|
||||||
for month in range(1, 13):
|
for month in range(1, 13):
|
||||||
navs.append((month, month, True))
|
navs.append((month, month, True))
|
||||||
|
|
||||||
# Add a link for year_glance() if requested
|
# Add a link for year_glance() if requested
|
||||||
navs.append(('fullyear', _('Year Glance'), self.fullyear))
|
navs.append(('fullyear', _('Year Glance'), self.fullyear))
|
||||||
|
|
||||||
of.write('<div id="subnavigation">\n')
|
of.write('<div id="subnavigation">\n')
|
||||||
of.write('\t<ul>\n')
|
of.write('\t<ul>\n')
|
||||||
|
|
||||||
for url_fname, nav_text, cond in navs:
|
navs = [(u, n) for u, n, c in navs if c]
|
||||||
url = ''
|
for url_fname, nav_text in navs:
|
||||||
cs = False
|
subdirs = ['..'] * nr_up
|
||||||
if cond:
|
subdirs.append(str(year))
|
||||||
|
|
||||||
subdirs = ['..'] * nr_up
|
|
||||||
subdirs.append(str(year))
|
|
||||||
|
|
||||||
if type(url_fname) == int:
|
if type(url_fname) == int:
|
||||||
url_fname = get_full_month_name(url_fname)
|
url_fname = get_full_month_name(url_fname)
|
||||||
|
|
||||||
if type(nav_text) == int:
|
if type(nav_text) == int:
|
||||||
nav_text = get_short_month_name(nav_text)
|
nav_text = get_short_month_name(nav_text)
|
||||||
|
|
||||||
# Figure out if we need <li id="CurrentSection"> or just plain <li>
|
# Note. We use '/' here because it is a URL, not a OS dependent pathname
|
||||||
if url_fname == currentsection:
|
url = url_fname
|
||||||
cs = True
|
if not (url.startswith('http:') or url.startswith('/')):
|
||||||
|
url = '/'.join(subdirs + [url_fname])
|
||||||
|
|
||||||
# Note. We use '/' here because it is a URL, not a OS dependent pathname
|
if not _has_webpage_extension(url, self.ext):
|
||||||
url = url_fname
|
url += self.ext
|
||||||
if not url.startswith('http:'):
|
|
||||||
url = '/'.join(subdirs + [url_fname])
|
|
||||||
|
|
||||||
if not _has_webpage_extension(url, self.ext):
|
# Figure out if we need <li id="CurrentSection"> or just plain <li>
|
||||||
url += self.ext
|
cs = url_fname == currentsection and ' id="CurrentSection"' or ''
|
||||||
|
of.write('\t\t<li%s><a href="%s">%s</a></li>\n' % (cs, url, nav_text))
|
||||||
cs = cs and ' id="CurrentSection"' or ''
|
|
||||||
of.write('\t\t<li%s><a href="%s">%s</a></li>\n'
|
|
||||||
% (cs, url, nav_text))
|
|
||||||
|
|
||||||
of.write('\t</ul>\n')
|
of.write('\t</ul>\n')
|
||||||
of.write('</div>\n\n')
|
of.write('</div>\n\n')
|
||||||
@ -864,7 +854,7 @@ class WebCalReport(Report):
|
|||||||
|
|
||||||
of.write('<body id="fullyearlinked">\n')
|
of.write('<body id="fullyearlinked">\n')
|
||||||
|
|
||||||
self.calendar_common(of, nr_up, year, 'fullyear', title)
|
self.calendar_common(of, nr_up, year, 'fullyear', title, use_home=True)
|
||||||
|
|
||||||
# page description
|
# page description
|
||||||
of.write('<div class="content">\n')
|
of.write('<div class="content">\n')
|
||||||
@ -1571,6 +1561,7 @@ def get_next_day(year, month, day_col):
|
|||||||
next_month_day = firstweek_nextmonth[day_col]
|
next_month_day = firstweek_nextmonth[day_col]
|
||||||
return next_month_day
|
return next_month_day
|
||||||
|
|
||||||
|
# TODO. Eliminate this function, or make it do something useful.
|
||||||
def _has_webpage_extension(url, ext):
|
def _has_webpage_extension(url, ext):
|
||||||
"""
|
"""
|
||||||
determine if a filename has an extension or not...
|
determine if a filename has an extension or not...
|
||||||
|
Loading…
Reference in New Issue
Block a user