0001006: Narrative Web: Media objects missing title (description), mime_type, or path, are displayed poorly.

svn: r8365
This commit is contained in:
Brian Matherly 2007-04-09 03:35:58 +00:00
parent ecb95e1c1a
commit bc0b71f125
2 changed files with 21 additions and 8 deletions

View File

@ -1,3 +1,7 @@
2007-04-08 Brian Matherly <brian@gramps-project.org>
* src/plugins/NarrativeWeb.py: 0001006: Narrative Web: Media objects missing
title (description), mime_type, or path, are displayed poorly.
2007-04-08 Brian Matherly <brian@gramps-project.org> 2007-04-08 Brian Matherly <brian@gramps-project.org>
* src/plugins/NarrativeWeb.py: 0000896: Crash running Narrative Web report - * src/plugins/NarrativeWeb.py: 0000896: Crash running Narrative Web report -
system memory exhausted. system memory exhausted.

View File

@ -402,16 +402,19 @@ class BasePage:
photo_handle = mediaref.get_reference_handle() photo_handle = mediaref.get_reference_handle()
photo = db.get_object_from_handle(photo_handle) photo = db.get_object_from_handle(photo_handle)
mime_type = photo.get_mime_type() mime_type = photo.get_mime_type()
title = photo.get_description()
if title == "":
title = "(untitled)"
if mime_type: if mime_type:
try: try:
(real_path,newpath) = self.copy_media(photo) (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) self.media_link(of, photo_handle, newpath, descr, up=True)
except (IOError,OSError),msg: except (IOError,OSError),msg:
WarningDialog(_("Could not add photo to page"),str(msg)) WarningDialog(_("Could not add photo to page"),str(msg))
else: else:
try: try:
descr = " ".join(wrapper.wrap(photo.get_description())) descr = " ".join(wrapper.wrap(title))
self.doc_link(of, photo_handle, descr, up=True) self.doc_link(of, photo_handle, descr, up=True)
lnk = (self.cur_name,self.page_title,self.gid) lnk = (self.cur_name,self.page_title,self.gid)
if self.photo_list.has_key(photo_handle): if self.photo_list.has_key(photo_handle):
@ -824,12 +827,13 @@ class MediaPage(BasePage):
of = self.create_link_file(handle,"img") of = self.create_link_file(handle,"img")
mime_type = photo.get_mime_type() 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) newpath = self.copy_source_file(handle, photo)
target_exists = newpath != None target_exists = newpath != None
else: else:
note_only = True
target_exists = False target_exists = False
self.copy_thumbnail(handle, photo) self.copy_thumbnail(handle, photo)
@ -952,7 +956,9 @@ class MediaPage(BasePage):
os.path.join(self.html_dir,newpath)) os.path.join(self.html_dir,newpath))
return newpath return newpath
except (IOError,OSError),msg: 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 return None
def copy_thumbnail(self,handle,photo): def copy_thumbnail(self,handle,photo):
@ -961,9 +967,9 @@ class MediaPage(BasePage):
if photo.get_mime_type(): if photo.get_mime_type():
from_path = ImgManip.get_thumbnail_path(photo.get_path(),photo.get_mime_type()) from_path = ImgManip.get_thumbnail_path(photo.get_path(),photo.get_mime_type())
if not os.path.isfile(from_path): 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: else:
from_path = os.path.join(const.data_dir,"document.png") from_path = os.path.join(const.image_dir,"document.png")
if self.archive: if self.archive:
self.archive.add(from_path,to_path) self.archive.add(from_path,to_path)
@ -1273,12 +1279,15 @@ class GalleryPage(BasePage):
for handle in mlist: for handle in mlist:
media = db.get_object_from_handle(handle) media = db.get_object_from_handle(handle)
date = _dd.display(media.get_date_object()) date = _dd.display(media.get_date_object())
title = media.get_description()
if title == "":
title = "untitled"
of.write('<tr>\n') of.write('<tr>\n')
of.write('<td class="category">%d.</td>\n' % index) of.write('<td class="category">%d.</td>\n' % index)
of.write('<td class="data">') of.write('<td class="data">')
self.media_ref_link(of,handle,media.get_description()) self.media_ref_link(of,handle,title)
of.write('</td>\n') of.write('</td>\n')
of.write('<td class="data">%s</td>\n' % date) of.write('<td class="data">%s</td>\n' % date)