Added section roles to web output. Modified menu navigation so that it will continue to work with all style sheets. Added ability to have Fade menu if there is only one year being created and only if Blue or Visually is being used.
svn: r18751
This commit is contained in:
parent
f23e2b41d3
commit
1d7da62b10
@ -319,8 +319,13 @@ class WebCalReport(Report):
|
|||||||
|
|
||||||
# copy Navigation Menu Layout if Blue or Visually is being used
|
# copy Navigation Menu Layout if Blue or Visually is being used
|
||||||
if CSS[self.css]["navigation"]:
|
if CSS[self.css]["navigation"]:
|
||||||
|
|
||||||
|
# if there are multiple years, add Horizontal else add Fade...
|
||||||
|
if self.multiyear:
|
||||||
fname = CSS["Horizontal-Menus"]["filename"]
|
fname = CSS["Horizontal-Menus"]["filename"]
|
||||||
self.copy_file(fname, "narrative-menus.css", "styles")
|
else:
|
||||||
|
fname = CSS["Fade-Menus"]["filename"]
|
||||||
|
self.copy_file(fname, "calendar-menus.css", "styles")
|
||||||
|
|
||||||
# copy print stylesheet
|
# copy print stylesheet
|
||||||
fname = CSS["Print-Default"]["filename"]
|
fname = CSS["Print-Default"]["filename"]
|
||||||
@ -385,11 +390,23 @@ class WebCalReport(Report):
|
|||||||
|
|
||||||
# Header contants
|
# Header contants
|
||||||
xmllang = xml_lang()
|
xmllang = xml_lang()
|
||||||
_META1 = 'name="generator" content="%s %s %s"' % \
|
_META1 = 'name ="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1"'
|
||||||
(const.PROGRAM_NAME, const.VERSION, const.URL_HOMEPAGE)
|
_META2 = 'name ="apple-mobile-web-app-capable" content="yes"'
|
||||||
_META2 = 'name="author" content="%s"' % self.author
|
_META3 = 'name="generator" content="%s %s %s"' % (
|
||||||
|
const.PROGRAM_NAME, const.VERSION, const.URL_HOMEPAGE)
|
||||||
|
_META4 = 'name="author" content="%s"' % self.author
|
||||||
|
|
||||||
page, head, body = Html.page(title, self.encoding, xmllang)
|
# create additional meta tags
|
||||||
|
meta = Html("meta", attr = _META1) + (
|
||||||
|
Html("meta", attr = _META2, indent = False),
|
||||||
|
Html("meta", attr = _META3, indent =False),
|
||||||
|
Html("meta", attr = _META4, indent = False)
|
||||||
|
)
|
||||||
|
|
||||||
|
# begin each html page...
|
||||||
|
page, head, body = Html.page(title,
|
||||||
|
self.encoding,
|
||||||
|
xmllang)
|
||||||
|
|
||||||
# add body id tag if not None
|
# add body id tag if not None
|
||||||
if body_id is not None:
|
if body_id is not None:
|
||||||
@ -401,40 +418,31 @@ class WebCalReport(Report):
|
|||||||
# _CALENDARSCREEN stylesheet
|
# _CALENDARSCREEN stylesheet
|
||||||
fname2 = "/".join(subdirs + ["styles", _CALENDARSCREEN])
|
fname2 = "/".join(subdirs + ["styles", _CALENDARSCREEN])
|
||||||
|
|
||||||
# create additional meta tags
|
|
||||||
meta = Html("meta", attr = _META1) + (
|
|
||||||
Html("meta", attr = _META2, indent = False)
|
|
||||||
)
|
|
||||||
|
|
||||||
# links for GRAMPS favicon and stylesheets
|
# links for GRAMPS favicon and stylesheets
|
||||||
links = Html("link", rel = 'shortcut icon', href = fname1, type = "image/x-icon") + (
|
links = Html("link", rel = 'shortcut icon', href = fname1, type = "image/x-icon") + (
|
||||||
Html("link",rel = "stylesheet", href = fname2, type = "text/css", media = "screen", indent = False)
|
Html("link",href = fname2, type = "text/css", media = "screen", rel = "stylesheet", indent = False)
|
||||||
|
)
|
||||||
|
|
||||||
|
# add horizontal menu if css == Blue or Visually because there is no menus?
|
||||||
|
if CSS[self.css]["navigation"]:
|
||||||
|
fname = "/".join(subdirs + ["styles", "calendar-menus.css"])
|
||||||
|
links.extend(
|
||||||
|
Html("link", href = fname, type = "text/css", media = "screen", rel = "stylesheet", indent = False)
|
||||||
)
|
)
|
||||||
|
|
||||||
# add printer stylesheet to webcalendar() and one_day() only
|
# add printer stylesheet to webcalendar() and one_day() only
|
||||||
if add_print:
|
if add_print:
|
||||||
fname = "/".join(subdirs + ["styles", _CALENDARPRINT])
|
fname = "/".join(subdirs + ["styles", _CALENDARPRINT])
|
||||||
links += Html("link",rel = "stylesheet", href = fname,type = "text/css", media = "print", indent = False)
|
|
||||||
|
|
||||||
# add horizontal menu if css == Blue or Visually because there is no menus?
|
|
||||||
if CSS[self.css]["navigation"]:
|
|
||||||
|
|
||||||
# Link to Navigation Menus stylesheet
|
|
||||||
fname = "/".join(subdirs + ["styles", "narrative-menus.css"])
|
|
||||||
links.extend(
|
links.extend(
|
||||||
Html("link", href =fname, type ="text/css", media ="screen", rel ="stylesheet")
|
Html("link",href = fname,type = "text/css", media = "print", rel = "stylesheet", indent = False)
|
||||||
)
|
)
|
||||||
|
|
||||||
# add meta tags and links to head section
|
# add meta tags and links to head section
|
||||||
head += (meta, links)
|
head += (meta, links)
|
||||||
|
|
||||||
# start header division section
|
# start header section and page title...
|
||||||
header = Html("div", id = "header") + (
|
with Html("div", id = "header", role = "Title-n-Navigation") as header:
|
||||||
|
header += Html("h1", title, id = "SiteTitle", inline = True)
|
||||||
# page title
|
|
||||||
Html("h1", title, id = "SiteTitle", inline = True)
|
|
||||||
)
|
|
||||||
body += header
|
|
||||||
|
|
||||||
# Created for ?
|
# Created for ?
|
||||||
msg = None
|
msg = None
|
||||||
@ -445,10 +453,10 @@ class WebCalReport(Report):
|
|||||||
elif self.author:
|
elif self.author:
|
||||||
msg = _('Created for %(author)s') % {'author' : self.author}
|
msg = _('Created for %(author)s') % {'author' : self.author}
|
||||||
|
|
||||||
if msg is not None:
|
if msg:
|
||||||
header += Html("p", msg, id = "CreatorInfo")
|
header += Html("p", msg, id = "CreatorInfo")
|
||||||
|
|
||||||
# return to its callers; either webcalendar(), year_glance(), or one_day()
|
body += header
|
||||||
return page, body
|
return page, body
|
||||||
|
|
||||||
def year_navigation(self, nr_up, currentsection):
|
def year_navigation(self, nr_up, currentsection):
|
||||||
@ -518,11 +526,15 @@ class WebCalReport(Report):
|
|||||||
# Add a link for year_glance() if requested
|
# Add a link for year_glance() if requested
|
||||||
navs.append(('fullyearlinked', _('Year Glance'), self.fullyear))
|
navs.append(('fullyearlinked', _('Year Glance'), self.fullyear))
|
||||||
|
|
||||||
|
# remove menu items if they are not True
|
||||||
|
navs = [(u, n) for u, n, c in navs if c]
|
||||||
|
|
||||||
# begin month subnavigation
|
# begin month subnavigation
|
||||||
with Html("div", class_ = "wrapper", id = "nav", role = "navigation") as navigation:
|
with Html("div", class_ = "wrapper", id = "nav", role = "navigation") as navigation:
|
||||||
unordered = Html("ul")
|
with Html("div", class_ = "container") as container:
|
||||||
|
|
||||||
|
unordered = Html("ul", class_ = "menu")
|
||||||
|
|
||||||
navs = [(u, n) for u, n, c in navs if c]
|
|
||||||
for url_fname, nav_text in navs:
|
for url_fname, nav_text in navs:
|
||||||
|
|
||||||
# Note. We use '/' here because it is a URL, not a OS dependent pathname
|
# Note. We use '/' here because it is a URL, not a OS dependent pathname
|
||||||
@ -561,7 +573,8 @@ class WebCalReport(Report):
|
|||||||
unordered.extend(
|
unordered.extend(
|
||||||
Html("li", hyper, inline = True)
|
Html("li", hyper, inline = True)
|
||||||
)
|
)
|
||||||
navigation += unordered
|
container += unordered
|
||||||
|
navigation += container
|
||||||
return navigation
|
return navigation
|
||||||
|
|
||||||
def calendar_build(self, cal, year, month):
|
def calendar_build(self, cal, year, month):
|
||||||
@ -602,11 +615,11 @@ class WebCalReport(Report):
|
|||||||
def __get_previous_month_day(year, month, day_col):
|
def __get_previous_month_day(year, month, day_col):
|
||||||
|
|
||||||
if month == 1:
|
if month == 1:
|
||||||
prevmonth = calendar.monthcalendar(year - 1, 12)
|
prevmonth = calendar.monthcalendar((year - 1), 12)
|
||||||
else:
|
else:
|
||||||
prevmonth = calendar.monthcalendar(year, month-1)
|
prevmonth = calendar.monthcalendar(year, (month - 1))
|
||||||
num_weeks = len(prevmonth)
|
num_weeks = len(prevmonth)
|
||||||
lastweek_prevmonth = prevmonth[num_weeks - 1]
|
lastweek_prevmonth = prevmonth[(num_weeks - 1)]
|
||||||
previous_month_day = lastweek_prevmonth[day_col]
|
previous_month_day = lastweek_prevmonth[day_col]
|
||||||
|
|
||||||
# return previous month day number based on day_col
|
# return previous month day number based on day_col
|
||||||
@ -616,9 +629,9 @@ class WebCalReport(Report):
|
|||||||
def __get_next_month_day(year, month, day_col):
|
def __get_next_month_day(year, month, day_col):
|
||||||
|
|
||||||
if month == 12:
|
if month == 12:
|
||||||
nextmonth = calendar.monthcalendar(year + 1, 1)
|
nextmonth = calendar.monthcalendar((year + 1), 1)
|
||||||
else:
|
else:
|
||||||
nextmonth = calendar.monthcalendar(year, month + 1)
|
nextmonth = calendar.monthcalendar(year, (month + 1))
|
||||||
firstweek_nextmonth = nextmonth[0]
|
firstweek_nextmonth = nextmonth[0]
|
||||||
next_month_day = firstweek_nextmonth[day_col]
|
next_month_day = firstweek_nextmonth[day_col]
|
||||||
|
|
||||||
@ -635,8 +648,7 @@ class WebCalReport(Report):
|
|||||||
th_txt = '%s %04d' % (month_name, year)
|
th_txt = '%s %04d' % (month_name, year)
|
||||||
|
|
||||||
# begin calendar table and table head
|
# begin calendar table and table head
|
||||||
with Html("table", class_ = "calendar", id = month_name) as table:
|
with Html("table", class_ = "calendar", id = month_name, role = "Calendar-Grid") as table:
|
||||||
|
|
||||||
thead = Html("thead")
|
thead = Html("thead")
|
||||||
table += thead
|
table += thead
|
||||||
|
|
||||||
@ -1173,7 +1185,7 @@ class WebCalReport(Report):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# begin calendar footer
|
# begin calendar footer
|
||||||
with Html("div", id = "footer") as footer:
|
with Html("div", id = "footer", role = "Footer-End") as footer:
|
||||||
|
|
||||||
# Display date as user set in preferences
|
# Display date as user set in preferences
|
||||||
msg = _('Generated by <a href="http://gramps-project.org">'
|
msg = _('Generated by <a href="http://gramps-project.org">'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user