From bc0b71f125b57f9fe8bb7a7e02836c4f44baf5a8 Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Mon, 9 Apr 2007 03:35:58 +0000 Subject: [PATCH] 0001006: Narrative Web: Media objects missing title (description), mime_type, or path, are displayed poorly. svn: r8365 --- gramps2/ChangeLog | 4 ++++ gramps2/src/plugins/NarrativeWeb.py | 25 +++++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index cea04369e..00f2de7c6 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,7 @@ +2007-04-08 Brian Matherly + * src/plugins/NarrativeWeb.py: 0001006: Narrative Web: Media objects missing + title (description), mime_type, or path, are displayed poorly. + 2007-04-08 Brian Matherly * src/plugins/NarrativeWeb.py: 0000896: Crash running Narrative Web report - system memory exhausted. diff --git a/gramps2/src/plugins/NarrativeWeb.py b/gramps2/src/plugins/NarrativeWeb.py index 84306d7d0..db1a26a04 100644 --- a/gramps2/src/plugins/NarrativeWeb.py +++ b/gramps2/src/plugins/NarrativeWeb.py @@ -402,16 +402,19 @@ class BasePage: photo_handle = mediaref.get_reference_handle() photo = db.get_object_from_handle(photo_handle) mime_type = photo.get_mime_type() + title = photo.get_description() + if title == "": + title = "(untitled)" if mime_type: try: (real_path,newpath) = self.copy_media(photo) - descr = " ".join(wrapper.wrap(photo.get_description())) + descr = " ".join(wrapper.wrap(title)) self.media_link(of, photo_handle, newpath, descr, up=True) except (IOError,OSError),msg: WarningDialog(_("Could not add photo to page"),str(msg)) else: try: - descr = " ".join(wrapper.wrap(photo.get_description())) + descr = " ".join(wrapper.wrap(title)) self.doc_link(of, photo_handle, descr, up=True) lnk = (self.cur_name,self.page_title,self.gid) if self.photo_list.has_key(photo_handle): @@ -824,12 +827,13 @@ class MediaPage(BasePage): of = self.create_link_file(handle,"img") mime_type = photo.get_mime_type() - note_only = mime_type == None - if not note_only: + if mime_type: + note_only = False newpath = self.copy_source_file(handle, photo) target_exists = newpath != None else: + note_only = True target_exists = False self.copy_thumbnail(handle, photo) @@ -952,7 +956,9 @@ class MediaPage(BasePage): os.path.join(self.html_dir,newpath)) return newpath except (IOError,OSError),msg: - WarningDialog(_("Missing media object"),str(msg)) + error = _("Missing media object:") + \ + "%s (%s)" % (photo.get_description(),photo.get_gramps_id()) + WarningDialog(error,str(msg)) return None def copy_thumbnail(self,handle,photo): @@ -961,9 +967,9 @@ class MediaPage(BasePage): if photo.get_mime_type(): from_path = ImgManip.get_thumbnail_path(photo.get_path(),photo.get_mime_type()) if not os.path.isfile(from_path): - from_path = os.path.join(const.data_dir,"document.png") + from_path = os.path.join(const.image_dir,"document.png") else: - from_path = os.path.join(const.data_dir,"document.png") + from_path = os.path.join(const.image_dir,"document.png") if self.archive: self.archive.add(from_path,to_path) @@ -1273,12 +1279,15 @@ class GalleryPage(BasePage): for handle in mlist: media = db.get_object_from_handle(handle) date = _dd.display(media.get_date_object()) + title = media.get_description() + if title == "": + title = "untitled" of.write('\n') of.write('%d.\n' % index) of.write('') - self.media_ref_link(of,handle,media.get_description()) + self.media_ref_link(of,handle,title) of.write('\n') of.write('%s\n' % date)