NarrativeWeb : feature request 5530 (include in CMS or MVS)

This commit is contained in:
SNoiraud 2015-09-02 23:07:11 +02:00
parent 2d92327fbc
commit 3c1671d09f
2 changed files with 124 additions and 29 deletions

View File

@ -107,7 +107,7 @@ class Html(list):
"""
HTML class: Manages a rooted tree of HTML objects
"""
__slots__ = ['items', 'indent', 'inline', 'close']
__slots__ = ['items', 'indent', 'inline', 'close', 'cms']
#
@staticmethod
def xmldecl(version=1.0, encoding="UTF-8", standalone="no"):
@ -199,7 +199,7 @@ class Html(list):
return head
#
@staticmethod
def page(title=None, encoding='utf-8', lang='en', html5=True, *args, **keywargs):
def page(title=None, encoding='utf-8', lang='en', html5=True, cms=False, *args, **keywargs):
"""
This function prepares a new Html class based page and returns
@ -230,11 +230,14 @@ class Html(list):
*args, **keywargs
)
#
if cms:
body = Html('div', class_ = "body", indent=False, *args, **keywargs)
else:
body = Html('body', indent=False, *args, **keywargs)
page += (head, body)
return page, head, body
#
def __init__(self, tag='html', *args, **keywargs):
def __init__(self, tag='html', cms=False, *args, **keywargs):
"""
Class Constructor: Returns a new instance of the Html class
@ -270,6 +273,7 @@ class Html(list):
For full usage of the Html class with examples, please see the wiki
page at: http://www.gramps-project.org/wiki/index.php?title=Libhtml
"""
self.cms = cms
# Replace super(Html, self) with list
# Issue with Python 2.6 and reload of plugin
list.__init__(self, []) # instantiate object

View File

@ -587,6 +587,7 @@ class BasePage(object):
self.create_thumbs_only = report.options['create_thumbs_only']
self.inc_families = report.options['inc_families']
self.inc_events = report.options['inc_events']
self.usecms = report.options['usecms']
# Functions used when no Web Page plugin is provided
def add_instance(self, *param):
@ -1651,7 +1652,7 @@ class BasePage(object):
page, head, body = Html.page('%s - %s' %
(html_escape(self.title_str.strip()),
html_escape(title)),
self.report.encoding, xmllang)
self.report.encoding, xmllang, cms=self.usecms)
# temporary fix for .php parsing error
if self.ext in [".php", ".php3", ".cgi"]:
@ -3008,6 +3009,9 @@ class SurnamePage(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(surnamepage, of, sio)
#################################################
@ -3205,6 +3209,9 @@ class FamilyPages(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(familiesListPage, of, sio)
def FamilyPage(self, report, title, family_handle):
@ -3288,6 +3295,9 @@ class FamilyPages(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(familydetailpage, of, sio)
######################################################
@ -3445,6 +3455,9 @@ class PlacePages(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(placelistpage, of, sio)
def PlacePage(self, report, title, place_handle):
@ -3566,6 +3579,9 @@ class PlacePages(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(placepage, of, sio)
#################################################
@ -3766,6 +3782,9 @@ class EventPages(BasePage):
# send page ut for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(eventslistpage, of, sio)
def _getEventDate(self, event_handle):
@ -3892,6 +3911,9 @@ class EventPages(BasePage):
# send page out for processing
# and close the page
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(eventpage, of, sio)
#################################################
@ -4026,6 +4048,9 @@ class SurnameListPage(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(surnamelistpage, of, sio)
def surname_link(self, fname, name, opt_val = None, up = False):
@ -4068,6 +4093,9 @@ class IntroductionPage(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(intropage, of, sio)
class HomePage(BasePage):
@ -4101,6 +4129,9 @@ class HomePage(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(homepage, of, sio)
#################################################
@ -4236,6 +4267,9 @@ class SourcePages(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(sourcelistpage, of, sio)
def SourcePage(self, report, title, source_handle):
@ -4332,6 +4366,9 @@ class SourcePages(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(sourcepage, of, sio)
#################################################
@ -4464,6 +4501,9 @@ class MediaPages(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(medialistpage, of, sio)
def media_ref_link(self, handle, name, up = False):
@ -4735,6 +4775,9 @@ class MediaPages(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(mediapage, of, sio)
def media_nav_link(self, handle, name, up = False):
@ -4930,8 +4973,12 @@ class ThumbnailPreviewPage(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(thumbnailpage, of, sio)
def thumbnail_link(self, name, index):
"""
creates a hyperlink for Thumbnail Preview Reference...
@ -5080,8 +5127,12 @@ class DownloadPage(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(downloadpage, of, sio)
class ContactPage(BasePage):
def __init__(self, report, title):
self.dbase_ = report.database
@ -5146,6 +5197,9 @@ class ContactPage(BasePage):
# send page out for porcessing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(contactpage, of, sio)
#################################################
@ -5393,6 +5447,9 @@ class PersonPages(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(indlistpage, of, sio)
#################################################
@ -5560,6 +5617,9 @@ class PersonPages(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(indivdetpage, of, sio)
def __create_family_map(self, person, place_lat_long):
@ -5824,6 +5884,9 @@ class PersonPages(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(familymappage, of, sio)
def __display_family_map(self, person, place_lat_long):
@ -6651,6 +6714,9 @@ class RepositoryPages(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(repolistpage, of, sio)
def RepositoryPage(self, report, title, repo, handle):
@ -6716,6 +6782,9 @@ class RepositoryPages(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(repositorypage, of, sio)
class AddressBookListPage(BasePage):
@ -6808,6 +6877,9 @@ class AddressBookListPage(BasePage):
# send the page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(addressbooklistpage, of, sio)
class AddressBookPage(BasePage):
@ -6852,6 +6924,9 @@ class AddressBookPage(BasePage):
# send page out for processing
# and close the file
if self.usecms:
self.XHTMLWriter(body, of, sio)
else:
self.XHTMLWriter(addressbookpage, of, sio)
class NavWebReport(Report):
@ -6938,6 +7013,9 @@ class NavWebReport(Report):
self.use_contact = self.options['contactnote'] or \
self.options['contactimg']
# Do we need to include this in a cms ?
self.usecms = self.options['usecms']
# either include the gender graphics or not?
self.ancestortree = self.options['ancestortree']
@ -7972,6 +8050,7 @@ class NavWebOptions(MenuReportOptions):
self.__graphgens = None
self.__living = None
self.__yearsafterdeath = None
self.__usecms = None
MenuReportOptions.__init__(self, name, dbase)
def add_menu_options(self, menu):
@ -7984,6 +8063,7 @@ class NavWebOptions(MenuReportOptions):
self.__add_download_options(menu)
self.__add_advanced_options(menu)
self.__add_place_map_options(menu)
self.__add_cms_options(menu)
def __add_report_options(self, menu):
@ -8369,6 +8449,17 @@ class NavWebOptions(MenuReportOptions):
self.__placemap_options()
def __add_cms_options(self, menu):
"""
Options for the cms tab ...
"""
category_name = _("CMS inclusion")
addopt = partial(menu.add_option, category_name)
self.__usecms = BooleanOption(_("Do we include these pages in a cms web ?"), False)
addopt("usecms", self.__usecms)
def __archive_changed(self):
"""
Update the change of storage: archive or directory