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:
parent
db4977c244
commit
366fdb34f9
@ -571,13 +571,14 @@ class OptionHandler(_options.OptionHandler):
|
|||||||
"""
|
"""
|
||||||
Implements handling of the options for the plugins.
|
Implements handling of the options for the plugins.
|
||||||
"""
|
"""
|
||||||
def __init__(self, module_name, options_dict):
|
def __init__(self, module_name, options_dict, filename):
|
||||||
|
self.default_filename = filename
|
||||||
_options.OptionHandler.__init__(self, module_name, options_dict, None)
|
_options.OptionHandler.__init__(self, module_name, options_dict, None)
|
||||||
|
|
||||||
def init_subclass(self):
|
def init_subclass(self):
|
||||||
self.collection_class = OptionListCollection
|
self.collection_class = OptionListCollection
|
||||||
self.list_class = OptionList
|
self.list_class = OptionList
|
||||||
self.filename = const.REPORT_OPTIONS
|
self.filename = self.default_filename
|
||||||
|
|
||||||
def init_common(self):
|
def init_common(self):
|
||||||
"""
|
"""
|
||||||
@ -742,9 +743,12 @@ class ReportOptions(_options.Options):
|
|||||||
self.options_dict = {}
|
self.options_dict = {}
|
||||||
self.options_help = {}
|
self.options_help = {}
|
||||||
self.handler = None
|
self.handler = None
|
||||||
|
self.default_report_options_file = os.path.join(dbase.full_name,
|
||||||
|
"report_options.xml")
|
||||||
|
|
||||||
def load_previous_values(self):
|
def load_previous_values(self):
|
||||||
self.handler = OptionHandler(self.name, self.options_dict)
|
self.handler = OptionHandler(self.name, self.options_dict,
|
||||||
|
self.default_report_options_file)
|
||||||
|
|
||||||
def make_default_style(self, default_style):
|
def make_default_style(self, default_style):
|
||||||
"""
|
"""
|
||||||
|
@ -66,6 +66,7 @@ class DocReportDialog(ReportDialog):
|
|||||||
self.style_name = "default"
|
self.style_name = "default"
|
||||||
self.firstpage_added = False
|
self.firstpage_added = False
|
||||||
self.CSS = PLUGMAN.process_plugin_data('WEBSTUFF')
|
self.CSS = PLUGMAN.process_plugin_data('WEBSTUFF')
|
||||||
|
self.dbname = dbstate.db.get_dbname()
|
||||||
ReportDialog.__init__(self, dbstate, uistate, option_class,
|
ReportDialog.__init__(self, dbstate, uistate, option_class,
|
||||||
name, trans_name)
|
name, trans_name)
|
||||||
|
|
||||||
@ -174,7 +175,9 @@ class DocReportDialog(ReportDialog):
|
|||||||
ext = ""
|
ext = ""
|
||||||
else:
|
else:
|
||||||
spath = self.get_default_directory()
|
spath = self.get_default_directory()
|
||||||
base = "%s.%s" % (self.raw_name, ext)
|
default_name = self.dbname + "_" + \
|
||||||
|
"".join(x[0].upper() for x in self.raw_name.split("_"))
|
||||||
|
base = "%s.%s" % (default_name, ext)
|
||||||
spath = os.path.normpath(os.path.join(spath, base))
|
spath = os.path.normpath(os.path.join(spath, base))
|
||||||
self.target_fileentry.set_filename(spath)
|
self.target_fileentry.set_filename(spath)
|
||||||
|
|
||||||
|
@ -115,6 +115,7 @@ class GraphvizReportDialog(ReportDialog):
|
|||||||
more information."""
|
more information."""
|
||||||
self.category = CATEGORY_GRAPHVIZ
|
self.category = CATEGORY_GRAPHVIZ
|
||||||
self.__gvoptions = graphdoc.GVOptions()
|
self.__gvoptions = graphdoc.GVOptions()
|
||||||
|
self.dbname = dbstate.db.get_dbname()
|
||||||
ReportDialog.__init__(self, dbstate, uistate, opt,
|
ReportDialog.__init__(self, dbstate, uistate, opt,
|
||||||
name, translated_name)
|
name, translated_name)
|
||||||
|
|
||||||
@ -165,7 +166,9 @@ class GraphvizReportDialog(ReportDialog):
|
|||||||
ext = ""
|
ext = ""
|
||||||
else:
|
else:
|
||||||
spath = self.get_default_directory()
|
spath = self.get_default_directory()
|
||||||
base = "%s%s" % (self.raw_name, ext)
|
default_name = self.dbname + "_" + \
|
||||||
|
"".join(x[0].upper() for x in self.raw_name.split("_"))
|
||||||
|
base = "%s%s" % (default_name, ext)
|
||||||
spath = os.path.normpath(os.path.join(spath, base))
|
spath = os.path.normpath(os.path.join(spath, base))
|
||||||
self.target_fileentry.set_filename(spath)
|
self.target_fileentry.set_filename(spath)
|
||||||
|
|
||||||
|
@ -78,12 +78,12 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
from md5 import md5
|
from md5 import md5
|
||||||
import time, datetime
|
import time, datetime
|
||||||
import locale
|
|
||||||
import shutil
|
import shutil
|
||||||
import codecs
|
import codecs
|
||||||
import tarfile
|
import tarfile
|
||||||
import tempfile
|
import tempfile
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
|
from io import BytesIO, TextIOWrapper
|
||||||
from textwrap import TextWrapper
|
from textwrap import TextWrapper
|
||||||
from unicodedata import normalize
|
from unicodedata import normalize
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
@ -108,7 +108,7 @@ from gen.lib import (ChildRefType, Date, EventType, FamilyRelType, Name,
|
|||||||
EventRoleType, Family, Event, Place, Source,
|
EventRoleType, Family, Event, Place, Source,
|
||||||
Citation, MediaObject, Repository, Note, Tag)
|
Citation, MediaObject, Repository, Note, Tag)
|
||||||
from gen.lib.date import Today
|
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 Sort import Sort
|
||||||
from gen.plug.menu import PersonOption, NumberOption, StringOption, \
|
from gen.plug.menu import PersonOption, NumberOption, StringOption, \
|
||||||
BooleanOption, EnumeratedListOption, FilterOption, \
|
BooleanOption, EnumeratedListOption, FilterOption, \
|
||||||
@ -120,6 +120,7 @@ from gen.plug.report import MenuReportOptions
|
|||||||
from Utils import get_researcher, confidence, media_path_full, probably_alive, \
|
from Utils import get_researcher, confidence, media_path_full, probably_alive, \
|
||||||
conv_unicode_tosrtkey_ongtk, xml_lang, COLLATE_LANG
|
conv_unicode_tosrtkey_ongtk, xml_lang, COLLATE_LANG
|
||||||
from constfunc import win
|
from constfunc import win
|
||||||
|
import config
|
||||||
from ThumbNails import get_thumbnail_path, run_thumbnailer
|
from ThumbNails import get_thumbnail_path, run_thumbnailer
|
||||||
from ImgManip import image_size, resize_to_jpeg_buffer
|
from ImgManip import image_size, resize_to_jpeg_buffer
|
||||||
from gen.mime import get_description
|
from gen.mime import get_description
|
||||||
@ -6980,6 +6981,8 @@ class NavWebReport(Report):
|
|||||||
self.user.notify_error(_("Could not create %s") % self.target_path,
|
self.user.notify_error(_("Could not create %s") % self.target_path,
|
||||||
str(value))
|
str(value))
|
||||||
return
|
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
|
# for use with discovering biological, half, and step siblings for use
|
||||||
# in display_ind_parents()...
|
# in display_ind_parents()...
|
||||||
@ -7966,8 +7969,11 @@ class NavWebOptions(MenuReportOptions):
|
|||||||
addopt( "archive", self.__archive )
|
addopt( "archive", self.__archive )
|
||||||
self.__archive.connect('value-changed', self.__archive_changed)
|
self.__archive.connect('value-changed', self.__archive_changed)
|
||||||
|
|
||||||
|
dbname = self.__db.get_dbname()
|
||||||
|
default_dir = dbname + "_" + "NAVWEB"
|
||||||
self.__target = DestinationOption(_("Destination"),
|
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 "
|
self.__target.set_help( _("The destination directory for the web "
|
||||||
"files"))
|
"files"))
|
||||||
addopt( "target", self.__target )
|
addopt( "target", self.__target )
|
||||||
@ -8188,7 +8194,7 @@ class NavWebOptions(MenuReportOptions):
|
|||||||
self.__incdownload.connect('value-changed', self.__download_changed)
|
self.__incdownload.connect('value-changed', self.__download_changed)
|
||||||
|
|
||||||
self.__down_fname1 = DestinationOption(_("Download Filename"),
|
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"))
|
self.__down_fname1.set_help(_("File to be used for downloading of database"))
|
||||||
addopt( "down_fname1", self.__down_fname1 )
|
addopt( "down_fname1", self.__down_fname1 )
|
||||||
|
|
||||||
@ -8197,7 +8203,7 @@ class NavWebOptions(MenuReportOptions):
|
|||||||
addopt( "dl_descr1", self.__dl_descr1 )
|
addopt( "dl_descr1", self.__dl_descr1 )
|
||||||
|
|
||||||
self.__down_fname2 = DestinationOption(_("Download Filename"),
|
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"))
|
self.__down_fname2.set_help(_("File to be used for downloading of database"))
|
||||||
addopt( "down_fname2", self.__down_fname2 )
|
addopt( "down_fname2", self.__down_fname2 )
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ log = logging.getLogger(".WebPage")
|
|||||||
import gen.lib
|
import gen.lib
|
||||||
import const
|
import const
|
||||||
import constfunc
|
import constfunc
|
||||||
|
import config
|
||||||
from gen.plug.report import Report
|
from gen.plug.report import Report
|
||||||
from gen.plug.report import utils as ReportUtils
|
from gen.plug.report import utils as ReportUtils
|
||||||
from gen.plug.report import MenuReportOptions
|
from gen.plug.report import MenuReportOptions
|
||||||
@ -248,6 +249,8 @@ class WebCalReport(Report):
|
|||||||
"a different directory to store your generated "
|
"a different directory to store your generated "
|
||||||
"web pages."))
|
"web pages."))
|
||||||
self.warn_dir = False
|
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):
|
def add_day_item(self, text, year, month, day, event):
|
||||||
"""
|
"""
|
||||||
@ -1299,8 +1302,11 @@ class WebCalOptions(MenuReportOptions):
|
|||||||
"""
|
"""
|
||||||
category_name = _("Report Options")
|
category_name = _("Report Options")
|
||||||
|
|
||||||
|
dbname = self.__db.get_dbname()
|
||||||
|
default_dir = dbname + "_WEBCAL"
|
||||||
target = DestinationOption( _("Destination"),
|
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_help( _("The destination directory for the web files"))
|
||||||
target.set_directory_entry(True)
|
target.set_directory_entry(True)
|
||||||
menu.add_option(category_name, "target", target)
|
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"))
|
start_dow.set_help(_("Select the first day of the week for the calendar"))
|
||||||
menu.add_option(category_name, "start_dow", start_dow)
|
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 "
|
home_link.set_help(_("The link to be included to direct the user to "
|
||||||
"the main page of the web site"))
|
"the main page of the web site"))
|
||||||
menu.add_option(category_name, "home_link", home_link)
|
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)
|
menu.add_option(category_name, 'link_to_narweb', self.__links)
|
||||||
self.__links.connect('value-changed', self.__links_changed)
|
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 "
|
self.__prefix.set_help(_("A Prefix on the links to take you to "
|
||||||
"Narrated Web Report"))
|
"Narrated Web Report"))
|
||||||
menu.add_option(category_name, "prefix", self.__prefix)
|
menu.add_option(category_name, "prefix", self.__prefix)
|
||||||
|
Loading…
Reference in New Issue
Block a user