0003968: [NarWeb] Save/Restore settings for Narrated Website Generation. Change report_options file to be in the database directory, and implement different default report file and directory names based on the Family Tree Name. N.B. On upgrading, if you want to preserve your report_options, copy the report_option.xml file from the .gramps directory to the applicable .gramps.grampsdb.<number> directory. Also don't forget that the default options are to EXCLUDE private and living data.

svn: r21304
This commit is contained in:
Tim G L Lyons
2013-02-05 18:06:02 +00:00
parent db4977c244
commit 366fdb34f9
5 changed files with 39 additions and 13 deletions
+11 -5
View File
@@ -78,12 +78,12 @@ try:
except ImportError:
from md5 import md5
import time, datetime
import locale
import shutil
import codecs
import tarfile
import tempfile
from cStringIO import StringIO
from io import BytesIO, TextIOWrapper
from textwrap import TextWrapper
from unicodedata import normalize
from collections import defaultdict
@@ -108,7 +108,7 @@ from gen.lib import (ChildRefType, Date, EventType, FamilyRelType, Name,
EventRoleType, Family, Event, Place, Source,
Citation, MediaObject, Repository, Note, Tag)
from gen.lib.date import Today
from const import PROGRAM_NAME, URL_HOMEPAGE, USER_HOME, VERSION
from const import PROGRAM_NAME, URL_HOMEPAGE, VERSION
from Sort import Sort
from gen.plug.menu import PersonOption, NumberOption, StringOption, \
BooleanOption, EnumeratedListOption, FilterOption, \
@@ -120,6 +120,7 @@ from gen.plug.report import MenuReportOptions
from Utils import get_researcher, confidence, media_path_full, probably_alive, \
conv_unicode_tosrtkey_ongtk, xml_lang, COLLATE_LANG
from constfunc import win
import config
from ThumbNails import get_thumbnail_path, run_thumbnailer
from ImgManip import image_size, resize_to_jpeg_buffer
from gen.mime import get_description
@@ -6980,6 +6981,8 @@ class NavWebReport(Report):
self.user.notify_error(_("Could not create %s") % self.target_path,
str(value))
return
config.set('paths.website-directory',
os.path.dirname(self.target_path) + os.sep)
# for use with discovering biological, half, and step siblings for use
# in display_ind_parents()...
@@ -7966,8 +7969,11 @@ class NavWebOptions(MenuReportOptions):
addopt( "archive", self.__archive )
self.__archive.connect('value-changed', self.__archive_changed)
dbname = self.__db.get_dbname()
default_dir = dbname + "_" + "NAVWEB"
self.__target = DestinationOption(_("Destination"),
os.path.join(USER_HOME, "NAVWEB"))
os.path.join(config.get('paths.website-directory'),
default_dir))
self.__target.set_help( _("The destination directory for the web "
"files"))
addopt( "target", self.__target )
@@ -8188,7 +8194,7 @@ class NavWebOptions(MenuReportOptions):
self.__incdownload.connect('value-changed', self.__download_changed)
self.__down_fname1 = DestinationOption(_("Download Filename"),
os.path.join(USER_HOME, ""))
os.path.join(config.get('paths.website-directory'), ""))
self.__down_fname1.set_help(_("File to be used for downloading of database"))
addopt( "down_fname1", self.__down_fname1 )
@@ -8197,7 +8203,7 @@ class NavWebOptions(MenuReportOptions):
addopt( "dl_descr1", self.__dl_descr1 )
self.__down_fname2 = DestinationOption(_("Download Filename"),
os.path.join(USER_HOME, ""))
os.path.join(config.get('paths.website-directory'), ""))
self.__down_fname2.set_help(_("File to be used for downloading of database"))
addopt( "down_fname2", self.__down_fname2 )
+13 -3
View File
@@ -51,6 +51,7 @@ log = logging.getLogger(".WebPage")
import gen.lib
import const
import constfunc
import config
from gen.plug.report import Report
from gen.plug.report import utils as ReportUtils
from gen.plug.report import MenuReportOptions
@@ -248,6 +249,8 @@ class WebCalReport(Report):
"a different directory to store your generated "
"web pages."))
self.warn_dir = False
config.set('paths.website-directory',
os.path.dirname(self.html_dir) + os.sep)
def add_day_item(self, text, year, month, day, event):
"""
@@ -1299,8 +1302,11 @@ class WebCalOptions(MenuReportOptions):
"""
category_name = _("Report Options")
dbname = self.__db.get_dbname()
default_dir = dbname + "_WEBCAL"
target = DestinationOption( _("Destination"),
os.path.join(const.USER_HOME, "WEBCAL"))
os.path.join(config.get('paths.website-directory'),
default_dir))
target.set_help( _("The destination directory for the web files"))
target.set_directory_entry(True)
menu.add_option(category_name, "target", target)
@@ -1418,7 +1424,9 @@ class WebCalOptions(MenuReportOptions):
start_dow.set_help(_("Select the first day of the week for the calendar"))
menu.add_option(category_name, "start_dow", start_dow)
home_link = StringOption(_('Home link'), '../../NAVWEB/index.html')
dbname = self.__db.get_dbname()
default_link = '../../' + dbname + "_NAVWEB/index.html"
home_link = StringOption(_('Home link'), default_link)
home_link.set_help(_("The link to be included to direct the user to "
"the main page of the web site"))
menu.add_option(category_name, "home_link", home_link)
@@ -1519,7 +1527,9 @@ class WebCalOptions(MenuReportOptions):
menu.add_option(category_name, 'link_to_narweb', self.__links)
self.__links.connect('value-changed', self.__links_changed)
self.__prefix = StringOption(_('Link prefix'), "../../NAVWEB/")
dbname = self.__db.get_dbname()
default_prefix = '../../' + dbname + "_NAVWEB/"
self.__prefix = StringOption(_('Link prefix'), default_prefix)
self.__prefix.set_help(_("A Prefix on the links to take you to "
"Narrated Web Report"))
menu.add_option(category_name, "prefix", self.__prefix)