# # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2005 Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Pubilc License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # $Id$ "Web Site/Generate Web Site" #------------------------------------------------------------------------ # # python modules # #------------------------------------------------------------------------ import os import time import locale import shutil import codecs import sets from gettext import gettext as _ from cStringIO import StringIO #------------------------------------------------------------------------ # # GNOME/gtk # #------------------------------------------------------------------------ import gtk #------------------------------------------------------------------------ # # GRAMPS module # #------------------------------------------------------------------------ import RelLib import const import GrampsKeys import GenericFilter import Sort import Report import Errors import Utils import ReportOptions import BaseDoc import ReportUtils from QuestionDialog import ErrorDialog from NameDisplay import displayer as _nd from DateHandler import displayer as _dd #------------------------------------------------------------------------ # # constants # #------------------------------------------------------------------------ _NARRATIVE = "narrative.css" _NAME_COL = 3 _css_files = [ [_("Style 1"), 'main1.css'], [_("Style 2"), 'main2.css'], [_("Style 3"), 'main3.css'], [_("Style 4"), 'main4.css'], [_("Style 5"), 'main5.css'], ] _character_sets = [ [_('Unicode (recommended)'), 'utf-8'], ['ISO-8859-1', 'iso-8859-1' ], ['ISO-8859-2', 'iso-8859-2' ], ['ISO-8859-3', 'iso-8859-3' ], ['ISO-8859-4', 'iso-8859-4' ], ['ISO-8859-5', 'iso-8859-5' ], ['ISO-8859-6', 'iso-8859-6' ], ['ISO-8859-7', 'iso-8859-7' ], ['ISO-8859-8', 'iso-8859-8' ], ['ISO-8859-9', 'iso-8859-9' ], ['ISO-8859-10', 'iso-8859-10' ], ['ISO-8859-13', 'iso-8859-13' ], ['ISO-8859-14', 'iso-8859-14' ], ['ISO-8859-15', 'iso-8859-15' ], ['koi8_r', 'koi8_r', ], ] class BasePage: def __init__(self, title, options, archive): self.title_str = title self.inc_download = options.handler.options_dict['NWEBdownload'] self.html_dir = options.handler.options_dict['NWEBod'] self.options = options self.archive = archive self.image_dir = options.handler.options_dict['NWEBimagedir'].strip() self.ext = options.handler.options_dict['NWEBext'] self.encoding = options.handler.options_dict['NWEBencoding'] self.css = options.handler.options_dict['NWEBcss'] self.noid = options.handler.options_dict['NWEBnoid'] self.use_intro = options.handler.options_dict['NWEBintronote'] != u"" self.use_contact = options.handler.options_dict['NWEBcontact'] != u"" def copy_media(self,photo): newpath = photo.gramps_id + os.path.splitext(photo.get_path())[1] if self.image_dir: newpath = os.path.join(self.image_dir,newpath) if self.archive: imagefile = open(photo.get_path(),"r") self.archive.add_file(newpath,time.time(),imagefile) imagefile.close() else: shutil.copyfile(photo.get_path(), os.path.join(self.html_dir,newpath)) return newpath def create_file(self,name): if self.archive: self.string_io = StringIO() of = codecs.EncodedFile(self.string_io,'utf-8',self.encoding) self.cur_name = name + "." + self.ext else: page_name = os.path.join(self.html_dir,name + "." + self.ext) of = codecs.EncodedFile(open(page_name, "w"),'utf-8',self.encoding) return of def close_file(self,of): if self.archive: self.archive.add_file(self.cur_name,time.time(),self.string_io) of.close() else: of.close() def lnkfmt(self,text): return text.replace(' ','%20') def display_footer(self,of): format = locale.nl_langinfo(locale.D_FMT) value = time.strftime(format,time.localtime(time.time())) msg = _('Generated by ' 'GRAMPS on %(date)s' % { 'date' : value }) of.write('\n') of.write('
\n' % msg) of.write('