From 103e843be32e6cfcf8d5bad9442adba7e3f05894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Charette?= Date: Sun, 6 Jan 2008 21:26:59 +0000 Subject: [PATCH] resize and link to very large images, included sources for media objects svn: r9728 --- ChangeLog | 4 ++++ src/plugins/NarrativeWeb.py | 44 ++++++++++++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 395dd4078..77ea3ee00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-01-06 Stéphane Charette + * src/plugins/NarrativeWeb.py: resize and link to very large images, + include sources (when available) for media objects + 2008-01-04 Jerome Rapinat * src/DateHandler/_Date_fr.py : typo diff --git a/src/plugins/NarrativeWeb.py b/src/plugins/NarrativeWeb.py index ca30b2c4f..a92c2d5ff 100644 --- a/src/plugins/NarrativeWeb.py +++ b/src/plugins/NarrativeWeb.py @@ -88,6 +88,8 @@ from DateHandler import displayer as _dd _NARRATIVE = "narrative.css" _NAME_COL = 3 +MAX_IMG_WIDTH=800 # resize images that are wider than this +MAX_IMG_HEIGHT=600 # resize images that are taller than this WIDTH=160 HEIGHT=50 VGAP=10 @@ -1049,7 +1051,10 @@ class MediaPage(BasePage): BasePage.__init__(self, title, options, archive, media_list, photo.gramps_id) of = self.create_link_file(handle,"img") - + + self.db = db + self.src_list = src_list + mime_type = photo.get_mime_type() if mime_type: @@ -1085,8 +1090,27 @@ class MediaPage(BasePage): if mime_type.startswith("image/"): of.write('
\n') if target_exists: - of.write('\n' % newpath) + + of.write('%s\n' % (newpath, self.page_title)) + + if scale <> 1.0: + of.write('\n'); + else: of.write('
(%s)' % _("The file has been moved or deleted")) of.write('
\n') @@ -1152,9 +1176,19 @@ class MediaPage(BasePage): self.close_file(of) def display_media_sources(self,of,db,photo): - self.db = db - self.src_list = {} sreflist = photo.get_source_references() + + # add the media source refs to the global list of source refs + for sref in sreflist: + msh = sref.get_reference_handle() + lnk = (self.cur_name, self.page_title, self.gid) + if self.src_list.has_key(msh): + if photo.handle not in self.src_list[msh]: + self.src_list[msh].append(lnk) + else: + self.src_list[msh] = [lnk] + + # print the media source reference self.display_source_refs(of,db,sreflist) def display_attr_list(self,of,attrlist=None): @@ -2497,9 +2531,9 @@ class WebReport(Report): self.person_pages(ind_list, restrict_list, place_list, source_list, archive) self.surname_pages(ind_list, restrict_list, archive) self.place_pages(place_list, source_list, archive) - self.source_pages(source_list, self.photo_list, archive) if self.inc_gallery: self.gallery_pages(self.photo_list, source_list, archive) + self.source_pages(source_list, self.photo_list, archive) if archive: archive.close()