diff --git a/src/gen/plug/report/_options.py b/src/gen/plug/report/_options.py index 80b519b1f..265097d9a 100644 --- a/src/gen/plug/report/_options.py +++ b/src/gen/plug/report/_options.py @@ -571,13 +571,14 @@ class OptionHandler(_options.OptionHandler): """ 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) def init_subclass(self): self.collection_class = OptionListCollection self.list_class = OptionList - self.filename = const.REPORT_OPTIONS + self.filename = self.default_filename def init_common(self): """ @@ -742,9 +743,12 @@ class ReportOptions(_options.Options): self.options_dict = {} self.options_help = {} self.handler = None + self.default_report_options_file = os.path.join(dbase.full_name, + "report_options.xml") 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): """ diff --git a/src/gui/plug/report/_docreportdialog.py b/src/gui/plug/report/_docreportdialog.py index b66e2a6c0..ff3e858fc 100644 --- a/src/gui/plug/report/_docreportdialog.py +++ b/src/gui/plug/report/_docreportdialog.py @@ -66,6 +66,7 @@ class DocReportDialog(ReportDialog): self.style_name = "default" self.firstpage_added = False self.CSS = PLUGMAN.process_plugin_data('WEBSTUFF') + self.dbname = dbstate.db.get_dbname() ReportDialog.__init__(self, dbstate, uistate, option_class, name, trans_name) @@ -174,7 +175,9 @@ class DocReportDialog(ReportDialog): ext = "" else: 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)) self.target_fileentry.set_filename(spath) diff --git a/src/gui/plug/report/_graphvizreportdialog.py b/src/gui/plug/report/_graphvizreportdialog.py index fa9be372a..bd0f6d344 100644 --- a/src/gui/plug/report/_graphvizreportdialog.py +++ b/src/gui/plug/report/_graphvizreportdialog.py @@ -115,6 +115,7 @@ class GraphvizReportDialog(ReportDialog): more information.""" self.category = CATEGORY_GRAPHVIZ self.__gvoptions = graphdoc.GVOptions() + self.dbname = dbstate.db.get_dbname() ReportDialog.__init__(self, dbstate, uistate, opt, name, translated_name) @@ -165,7 +166,9 @@ class GraphvizReportDialog(ReportDialog): ext = "" else: 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)) self.target_fileentry.set_filename(spath) diff --git a/src/plugins/webreport/NarrativeWeb.py b/src/plugins/webreport/NarrativeWeb.py index d5dd5a33c..362c7cfa4 100644 --- a/src/plugins/webreport/NarrativeWeb.py +++ b/src/plugins/webreport/NarrativeWeb.py @@ -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 ) diff --git a/src/plugins/webreport/WebCal.py b/src/plugins/webreport/WebCal.py index 50ad00ddf..dc72e3754 100644 --- a/src/plugins/webreport/WebCal.py +++ b/src/plugins/webreport/WebCal.py @@ -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)