From 01f5d700d7d7052b48498972b47cc9ef6302684d Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Mon, 8 Jan 2007 03:48:49 +0000 Subject: [PATCH] * src/plugins/NarrativeWeb.py: wrap photo description at a maximum of 20 characters to prevent overlap (bug #658) svn: r7880 --- ChangeLog | 2 ++ src/plugins/NarrativeWeb.py | 18 +++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index ea2e210e5..d646cd48b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * src/SubstKeywords.py: Fix 0000813: IDs in graphical reports error 2007-01-07 Don Allingham + * src/plugins/NarrativeWeb.py: wrap photo description at a maximum + of 20 characters to prevent overlap (bug #658) * src/RelLib/*.py: pylint fixes 2007-01-07 Douglas S. Blank diff --git a/src/plugins/NarrativeWeb.py b/src/plugins/NarrativeWeb.py index f3be2e35c..ac5dde242 100644 --- a/src/plugins/NarrativeWeb.py +++ b/src/plugins/NarrativeWeb.py @@ -38,6 +38,7 @@ import codecs import tarfile from gettext import gettext as _ from cStringIO import StringIO +from textwrap import TextWrapper try: set() @@ -134,6 +135,9 @@ _cc = [ 'Creative Commons License - By attribution, Non-commerical, Share-alike', ] +wrapper = TextWrapper() +wrapper.break_log_words = True +wrapper.width = 20 class BasePage: def __init__(self, title, options, archive, photo_list, gid): @@ -370,10 +374,10 @@ class BasePage: WarningDialog(_("Could not add photo to page"),str(msg)) else: of.write('
\n') - self.doc_link(of,photo_handle, - photo.get_description(),up=True) + descr = " ".join(wrapper.wrap(photo.get_description())) + self.doc_link(of, photo_handle, descr, up=True) of.write('
\n') - 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 lnk not in self.photo_list[photo_handle]: self.photo_list[photo_handle].append(lnk) @@ -394,14 +398,14 @@ class BasePage: if mime_type: try: (real_path,newpath) = self.copy_media(photo) - self.media_link(of,photo_handle,newpath, - photo.get_description(),up=True) + descr = " ".join(wrapper.wrap(photo.get_description())) + 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: - self.doc_link(of,photo_handle, - photo.get_description(),up=True) + descr = " ".join(wrapper.wrap(photo.get_description())) + 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): if lnk not in self.photo_list[photo_handle]: