From d8d03e335cfef75cb287bb025be79de4831a4bfa Mon Sep 17 00:00:00 2001 From: Martin Hawlisch Date: Fri, 10 Jun 2005 14:03:27 +0000 Subject: [PATCH] * src/plugins/NavWebPage.py: Marked strings for translation; Dont crash if media file does not exist; Generate pages for every place; Build list of used sources svn: r4819 --- gramps2/ChangeLog | 3 + gramps2/src/plugins/NavWebPage.py | 122 +++++++++++++++++++++++------- 2 files changed, 98 insertions(+), 27 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 53741f37c..0b755e46f 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,5 +1,8 @@ 2005-06-10 Martin Hawlisch * src/ReportUtils.py (place_name): Really return place name + * src/plugins/NavWebPage.py: Marked strings for translation; Dont crash + if media file does not exist; Generate pages for every place; Build list + of used sources 2005-06-09 Martin Hawlisch * src/plugins/Makefile.am: Install vCal and vCard plugins diff --git a/gramps2/src/plugins/NavWebPage.py b/gramps2/src/plugins/NavWebPage.py index 8e14cb246..931bf5c84 100644 --- a/gramps2/src/plugins/NavWebPage.py +++ b/gramps2/src/plugins/NavWebPage.py @@ -135,7 +135,7 @@ class BasePage: of.write('
\n') of.write('
\n') of.write('
\n') - of.write('\n') @@ -255,9 +255,9 @@ class PlaceListPage(BasePage): for handle in handle_list: place = db.get_place_from_handle(handle) - n = place.title + n = ReportUtils.place_name(db,handle) - if len(n) == 0: + if not n or len(n) == 0: continue if n[0] != last_letter: @@ -274,7 +274,7 @@ class PlaceListPage(BasePage): of.write(' ') of.write('') of.write(n) - of.write(' ' % place.gramps_id) + of.write(' ' % place.gramps_id) of.write('[%s]' % place.gramps_id) of.write('') @@ -282,6 +282,58 @@ class PlaceListPage(BasePage): self.display_footer(of) of.close() +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +class PlacePage(BasePage): + + def __init__(self, db, title, place_handle, html_dir, src_list): + place = db.get_place_from_handle( place_handle) + BasePage.__init__(self,title) + page_name = os.path.join(html_dir,place.get_gramps_id()+".html") + of = open(page_name, "w") + place_name = ReportUtils.place_name(db,place_handle) + self.display_header(of,place_name, + db.get_researcher().get_name()) + of.write('

%s

\n' % place_name) + + photolist = place.get_media_list() + if photolist: + photo_handle = photolist[0].get_reference_handle() + photo = db.get_object_from_handle(photo_handle) + + try: + newpath = photo.gramps_id + os.path.splitext(photo.get_path())[1] + shutil.copyfile(photo.get_path(),os.path.join(html_dir,newpath)) + of.write('
\n') + of.write('' % newpath) + of.write('') + of.write('
\n') + except (IOError,OSError),msg: + ErrorDialog(str(msg)) + + # TODO: Add more information + + of.write('

%s

\n' % _('Narrative')) + of.write('
\n') + + noteobj = place.get_note_object() + if noteobj: + format = noteobj.get_format() + text = noteobj.get() + + if format: + text = "
" + "
".join(text.split("\n")) + else: + text = "

".join(text.split("\n")) + of.write('

%s

\n' % text) + + self.display_footer(of) + of.close() + #------------------------------------------------------------------------ # # @@ -403,13 +455,16 @@ class HomePage(BasePage): else: mime_type = obj.get_mime_type() if mime_type and mime_type.startswith("image"): - newpath = obj.gramps_id + os.path.splitext(obj.get_path())[1] - shutil.copyfile(obj.get_path(), - os.path.join(html_dir,newpath)) - of.write('
\n') - of.write('' % newpath) - of.write('
\n') + try: + newpath = obj.gramps_id + os.path.splitext(obj.get_path())[1] + shutil.copyfile(obj.get_path(), + os.path.join(html_dir,newpath)) + of.write('
\n') + of.write('' % newpath) + of.write('
\n') + except (IOError,OSError),msg: + ErrorDialog(str(msg)) note_obj = obj.get_note_object() if note_obj: @@ -447,9 +502,12 @@ class SourcesPage(BasePage): index = 1 for handle in handle_list: + source = db.get_source_from_handle(handle) of.write('%d.\n' % index) of.write('') + of.write(source.get_title()) of.write('\n') + index += 1 of.write('\n
\n') @@ -615,13 +673,16 @@ class IndividualPage(BasePage): photo_handle = photolist[0].get_reference_handle() photo = self.db.get_object_from_handle(photo_handle) - newpath = self.person.gramps_id + os.path.splitext(photo.get_path())[1] - shutil.copyfile(photo.get_path(),os.path.join(self.dirpath,newpath)) - of.write('
\n') - of.write('' % newpath) - of.write('') - of.write('
\n') + try: + newpath = self.person.gramps_id + os.path.splitext(photo.get_path())[1] + shutil.copyfile(photo.get_path(),os.path.join(self.dirpath,newpath)) + of.write('
\n') + of.write('' % newpath) + of.write('') + of.write('
\n') + except (IOError,OSError),msg: + ErrorDialog(str(msg)) of.write('
\n') of.write('

%s

\n' % self.sort_name) @@ -819,6 +880,8 @@ class IndividualPage(BasePage): of.write('
\n') def format_event(self,event): + for sref in event.get_source_references(): + self.src_list.add(sref.get_base_handle()) descr = event.get_description() place_handle = event.get_place_handle() if place_handle: @@ -994,6 +1057,11 @@ class WebReport(Report.Report): PlaceListPage(self.database, self.title, place_list, dir_name, source_list) + + for place in place_list: + print place + PlacePage(self.database, self.title, place, dir_name, source_list) + SourcesPage(self.database,self.title, source_list, dir_name) self.progress_bar_done() @@ -1031,7 +1099,7 @@ class WebReportOptions(ReportOptions.ReportOptions): 'HTMLsplita' : 0, 'HTMLshorttree' : 1, 'HTMLimagedir' : 'images', - 'HTMLtitle' : 'My Family Tree', + 'HTMLtitle' : _('My Family Tree'), 'HTMLincid' : 0, 'HTMLidurl' : '', 'HTMLlinktidx' : 1,