First step in breaking up NarrativeWeb into plugins; please test

svn: r15704
This commit is contained in:
Doug Blank 2010-08-11 14:11:35 +00:00
parent 919f632993
commit 864c79e446
2 changed files with 72 additions and 35 deletions

View File

@ -30,12 +30,14 @@
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gen.ggettext import gettext as _ from gen.ggettext import gettext as _
import os
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Constants # Constants
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import const
# Report categories # Report categories
from gen.plug import CATEGORY_TEXT, CATEGORY_DRAW, CATEGORY_CODE, CATEGORY_WEB,\ from gen.plug import CATEGORY_TEXT, CATEGORY_DRAW, CATEGORY_CODE, CATEGORY_WEB,\
@ -62,15 +64,23 @@ book_categories = {
# stylesheets in src/data. # stylesheets in src/data.
CSS_FILES = [ CSS_FILES = [
# First is used as default selection. # id, user selectable, translated_name, fullpath, navigation target name, additional files
[_("Basic-Ash"), 'Web_Basic-Ash.css'], # "default" is used as default
[_("Basic-Blue"), 'Web_Basic-Blue.css'], ["Basic-Ash", 1, _("Basic-Ash"), os.path.join(const.DATA_DIR, 'Web_Basic-Ash.css'), None, []],
[_("Basic-Cypress"), 'Web_Basic-Cypress.css'], ["Basic-Blue", 1, _("Basic-Blue"), os.path.join(const.DATA_DIR, 'Web_Basic-Blue.css'), "Web_Navigation-Menus.css", []],
[_("Basic-Lilac"), 'Web_Basic-Lilac.css'], ["Basic-Cypress", 1, _("Basic-Cypress"), os.path.join(const.DATA_DIR, 'Web_Basic-Cypress.css'), None, []],
[_("Basic-Peach"), 'Web_Basic-Peach.css'], ["Basic-Lilac", 1, _("Basic-Lilac"), os.path.join(const.DATA_DIR, 'Web_Basic-Lilac.css'), None, []],
[_("Basic-Spruce"), 'Web_Basic-Spruce.css'], ["Basic-Peach", 1, _("Basic-Peach"), os.path.join(const.DATA_DIR, 'Web_Basic-Peach.css'), None, []],
[_("Mainz"), 'Web_Mainz.css'], ["Basic-Spruce", 1, _("Basic-Spruce"), os.path.join(const.DATA_DIR, 'Web_Basic-Spruce.css'), None, []],
[_("Nebraska"), 'Web_Nebraska.css'], ["Mainz", 1, _("Mainz"), os.path.join(const.DATA_DIR, 'Web_Mainz.css'), None,
[_("Visually Impaired"), 'Web_Visually.css'], [os.path.join(const.IMAGE_DIR, "Web_Mainz_Bkgd.png"),
[_("No style sheet"), ''], os.path.join(const.IMAGE_DIR, "Web_Mainz_Header.png"),
os.path.join(const.IMAGE_DIR, "Web_Mainz_Mid.png"),
os.path.join(const.IMAGE_DIR, "Web_Mainz_MidLight.png")]],
["Nebraska", 1, _("Nebraska"), os.path.join(const.DATA_DIR, 'Web_Nebraska.css'), None, []],
["Visually Impaired", 1, _("Visually Impaired"), os.path.join(const.DATA_DIR, 'Web_Visually.css'), "Web_Navigation-Menus.css", []],
["No style sheet",1, _("No style sheet"), '', None, []],
["behaviour", 0, "Behaviour", os.path.join(const.DATA_DIR, 'behaviour.css'), None, []],
["default", 0, _("Basic-Ash"), os.path.join(const.DATA_DIR, 'Web_Basic-Ash.css'), None, []],
["Print-Default", 0, "Print-Default", os.path.join(const.DATA_DIR, 'Web_Print-Default.css'), None, []],
] ]

View File

@ -192,6 +192,18 @@ _html_replacement = {
"<" : "&#60;", "<" : "&#60;",
} }
def make_css_dict(tup):
return {
"id": tup[0],
"user": tup[1],
"translation": tup[2],
"filename": tup[3],
"navigation": tup[4],
"images": tup[5],
}
CSS = dict([(css[0], make_css_dict(css)) for css in CSS_FILES])
# This command then defines the 'html_escape' option for escaping # This command then defines the 'html_escape' option for escaping
# special characters for presentation in HTML based on the above list. # special characters for presentation in HTML based on the above list.
def html_escape(text): def html_escape(text):
@ -1134,8 +1146,8 @@ class BasePage(object):
) )
# Link to Navigation Menus stylesheet # Link to Navigation Menus stylesheet
if self.report.css in ["Web_Basic-Blue.css", "Web_Visually.css"]: if CSS[self.report.css]["navigation"]: # in ["Web_Basic-Blue.css", "Web_Visually.css"]:
fname = "/".join(["styles", "Web_Navigation-Menus.css"]) fname = "/".join(["styles", CSS[self.report.css]["navigation"]])
url = self.report.build_url_fname(fname, None, self.up) url = self.report.build_url_fname(fname, None, self.up)
links.extend( links.extend(
Html("link", href = url, type = "text/css", media = "screen", rel = "stylesheet", indent = False) Html("link", href = url, type = "text/css", media = "screen", rel = "stylesheet", indent = False)
@ -2022,9 +2034,8 @@ class IndividualListPage(BasePage):
thead += trow thead += trow
# show surname and first name # show surname and first name
trow += ( Html("th", _("Surname"), class_ = "ColumnSurname", inline = True) + trow += Html("th", _("Surname"), class_ = "ColumnSurname", inline = True)
Html("th", _("Name"), class_ = "ColumnName", inline = True) trow += Html("th", _("Name"), class_ = "ColumnName", inline = True)
)
if showbirth: if showbirth:
trow += Html("th", BIRTH, class_ = "ColumnBirth", inline = True) trow += Html("th", BIRTH, class_ = "ColumnBirth", inline = True)
@ -2470,6 +2481,11 @@ class PlacePage(BasePage):
if urllinks is not None: if urllinks is not None:
placedetail += urllinks placedetail += urllinks
#for all plugins
# if a place place_detail plugin
# if plugin active
# call_generate_page(report, title, place_handle, src_list, head, body, place, placedetail)
# add place map here # add place map here
if self.placemappages: if self.placemappages:
if (place and (place.lat and place.long)): if (place and (place.lat and place.long)):
@ -3944,6 +3960,11 @@ class IndividualPage(BasePage):
self.up = True self.up = True
familymappage, head, body = self.write_header(_("Family Map")) familymappage, head, body = self.write_header(_("Family Map"))
# for all plugins
# if family_detail_page
# if active
# call_(report, up, head)
# add Mapstraction CSS # add Mapstraction CSS
fname = "/".join(["styles", "mapstraction.css"]) fname = "/".join(["styles", "mapstraction.css"])
url = self.report.build_url_fname(fname, None, self.up) url = self.report.build_url_fname(fname, None, self.up)
@ -5680,20 +5701,20 @@ class NavWebReport(Report):
""" """
# copy behaviour style sheet # copy behaviour style sheet
fname = os.path.join(const.DATA_DIR, "behaviour.css") fname = CSS["behaviour"]["filename"] # "behaviour.css")
self.copy_file(fname, "behaviour.css", "styles") self.copy_file(fname, "behaviour.css", "styles")
# copy screen style sheet # copy screen style sheet
if self.css: if CSS[self.css]["filename"]:
fname = os.path.join(const.DATA_DIR, self.css) fname = CSS[self.css]["filename"]
self.copy_file(fname, _NARRATIVESCREEN, "styles") self.copy_file(fname, _NARRATIVESCREEN, "styles")
# copy Navigation Menu Layout style sheet if Blue or Visually is being used # copy Navigation Menu Layout style sheet if Blue or Visually is being used
if self.css == "Web_Basic-Blue.css" or "Web_Visually.css": if CSS[self.css]["navigation"]: #== "Web_Basic-Blue.css" or "Web_Visually.css":
if self.navigation == "Horizontal": if self.navigation == "Horizontal":
fname = os.path.join(const.DATA_DIR, "Web_Navigation-Horizontal.css") fname = CSS["Navigation-Horizontal"]["filename"] #"Web_Navigation-Horizontal.css")
else: else:
fname = os.path.join(const.DATA_DIR, "Web_Navigation-Vertical.css") fname = CSS["Navigation-Vertical"]["filename"] # "Web_Navigation-Vertical.css")
self.copy_file(fname, "Web_Navigation-Menus.css", "styles") self.copy_file(fname, "Web_Navigation-Menus.css", "styles")
# copy Mapstraction style sheet if using Place Maps # copy Mapstraction style sheet if using Place Maps
@ -5702,7 +5723,7 @@ class NavWebReport(Report):
self.copy_file(fname, "mapstraction.css", "styles") self.copy_file(fname, "mapstraction.css", "styles")
# copy printer style sheet # copy printer style sheet
fname = os.path.join(const.DATA_DIR, "Web_Print-Default.css") fname = CSS["Print-Default"]["filename"] # "Web_Print-Default.css")
self.copy_file(fname, _NARRATIVEPRINT, "styles") self.copy_file(fname, _NARRATIVEPRINT, "styles")
# copy mapstraction files to mapstraction directory # copy mapstraction files to mapstraction directory
@ -5723,12 +5744,6 @@ class NavWebReport(Report):
imgs = [] imgs = []
# Mainz stylesheet graphics
# will only be used if Mainz is slected as the stylesheet
if self.css == "Web_Mainz.css":
imgs += [ "Web_Mainz_Bkgd.png", "Web_Mainz_Header.png",
"Web_Mainz_Mid.png", "Web_Mainz_MidLight.png" ]
# Copy the Creative Commons icon if the Creative Commons # Copy the Creative Commons icon if the Creative Commons
# license is requested # license is requested
if 0 < self.copyright <= len(_CC): if 0 < self.copyright <= len(_CC):
@ -5748,8 +5763,17 @@ class NavWebReport(Report):
imgs += ["Web_Gender_Female.png", imgs += ["Web_Gender_Female.png",
"Web_Gender_Male.png" ] "Web_Gender_Male.png" ]
for fname in imgs: # add system path to images:
from_path = os.path.join(const.IMAGE_DIR, fname) imgs = [os.path.join(const.IMAGE_DIR, fname) for fname in imgs]
# Mainz stylesheet graphics
# will only be used if Mainz is slected as the stylesheet
#if self.css == "Web_Mainz.css":
imgs += CSS[self.css]["images"] #[ "Web_Mainz_Bkgd.png", "Web_Mainz_Header.png",
#"Web_Mainz_Mid.png", "Web_Mainz_MidLight.png" ]
for from_path in imgs:
fdir, fname = os.path.split(from_path)
self.copy_file(from_path, fname, "images") self.copy_file(from_path, fname, "images")
def build_attributes(self, person): def build_attributes(self, person):
@ -6213,6 +6237,7 @@ class NavWebReport(Report):
'to_dir' is the relative path name in the destination root. It will 'to_dir' is the relative path name in the destination root. It will
be prepended before 'to_fname'. be prepended before 'to_fname'.
""" """
log.debug("copying '%s' to '%s/%s'" % (from_fname, to_dir, to_fname))
if self.archive: if self.archive:
dest = os.path.join(to_dir, to_fname) dest = os.path.join(to_dir, to_fname)
self.archive.add(from_fname, dest) self.archive.add(from_fname, dest)
@ -6328,9 +6353,11 @@ class NavWebOptions(MenuReportOptions):
cright.set_help( _("The copyright to be used for the web files")) cright.set_help( _("The copyright to be used for the web files"))
menu.add_option(category_name, "cright", cright) menu.add_option(category_name, "cright", cright)
self.__css = EnumeratedListOption(_('StyleSheet'), CSS_FILES[0][1]) self.__css = EnumeratedListOption(_('StyleSheet'), CSS["default"]["id"])
for style in CSS_FILES: for (name, id) in sorted([(CSS[key]["translation"], CSS[key]["id"])
self.__css.add_item(style[1], style[0]) for key in CSS.keys()]):
if CSS[id]["user"]:
self.__css.add_item(CSS[id]["translation"], CSS[id]["id"])
self.__css.set_help( _('The stylesheet to be used for the web pages')) self.__css.set_help( _('The stylesheet to be used for the web pages'))
menu.add_option(category_name, "css", self.__css) menu.add_option(category_name, "css", self.__css)
self.__css.connect("value-changed", self.__stylesheet_changed) self.__css.connect("value-changed", self.__stylesheet_changed)
@ -6618,7 +6645,7 @@ class NavWebOptions(MenuReportOptions):
""" """
css_opts = self.__css.get_value() css_opts = self.__css.get_value()
if css_opts in ["Web_Basic-Blue.css", "Web_Visually.css"]: if CSS[css_opts]["navigation"]: # in ["Web_Basic-Blue.css", "Web_Visually.css"]:
self.__navigation.set_available(True) self.__navigation.set_available(True)
else: else:
self.__navigation.set_available(False) self.__navigation.set_available(False)