Pep8 cleanup, media_link() and doc_link(): can see object description now and making them look and work like each other. indivgallery changes in style sheet.

svn: r15579
This commit is contained in:
Rob G. Healey 2010-06-19 02:47:48 +00:00
parent 71ecdfdee8
commit 1915b899b3
2 changed files with 52 additions and 36 deletions

View File

@ -1120,32 +1120,32 @@ div#Residence table.infolist tr td {
/* Subsections : Gallery /* Subsections : Gallery
----------------------------------------------------- */ ----------------------------------------------------- */
#indivgallery h4 { #indivgallery h4 {
margin-bottom:1em; margin-bottom: 1em;
} }
#indivgallery .thumbnail { #indivgallery .thumbnail {
margin:0; margin: 0;
float:left; float: left;
width:130px; width: 130px;
height:150px; height: 150px;
text-align:center; text-align: center;
} }
#indivgallery div.thumbnail a { #indivgallery div.thumbnail a {
display:block; display: block;
margin:0; margin: 0;
padding:0; padding: 0;
background:none; text-decoration: none;
cursor: pointer;
} }
#indivgallery div.thumbnail a img { #indivgallery div.thumbnail a img {
margin-bottom:.5cm; padding: 0;
padding:0;
border: solid 1px #000; border: solid 1px #000;
} }
#indivgallery div.thumbnail p { #indivgallery div.thumbnail p {
font:normal .7em/1.4em sans-serif; font: normal .7em/1.4em sans-serif;
text-align:center; text-align: center;
width:80%; width: 80%;
margin:0 auto; margin: 0 auto;
padding:0; padding: 0;
} }
/* Subsections : Narrative /* Subsections : Narrative

View File

@ -1516,7 +1516,7 @@ class BasePage(object):
# begin individualgallery division and section title # begin individualgallery division and section title
with Html("div", class_ = "subsection", id = "indivgallery") as section: with Html("div", class_ = "subsection", id = "indivgallery") as section:
section += Html("h4", _("Gallery"), inline = True) section += Html("h4", _("Media"), inline = True)
displayed = [] displayed = []
for mediaref in photolist_ordered: for mediaref in photolist_ordered:
@ -1537,13 +1537,13 @@ class BasePage(object):
lnkref = (self.report.cur_fname, self.page_title, self.gid) lnkref = (self.report.cur_fname, self.page_title, self.gid)
self.report.add_lnkref_to_photo(photo, lnkref) self.report.add_lnkref_to_photo(photo, lnkref)
real_path, newpath = self.report.prepare_copy_media(photo) real_path, newpath = self.report.prepare_copy_media(photo)
# TODO. Check if build_url_fname can be used.
newpath = "/".join(['..']*3 + [newpath]) # create thumbnail url
if constfunc.win(): # extension needs to be added as it is not already there
newpath = newpath.replace('\\',"/") url = self.report.build_url_fname(photo_handle, "thumb", True) + ".png"
# begin hyperlink # begin hyperlink
section += self.media_link(photo_handle, newpath, descr, True, False) section += self.media_link(photo_handle, url, descr, 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))
@ -1565,7 +1565,7 @@ class BasePage(object):
WarningDialog(_("Could not add photo to page"), str(msg)) WarningDialog(_("Could not add photo to page"), str(msg))
displayed.append(photo_handle) displayed.append(photo_handle)
# add clearline for proper styling # add fullclear for proper styling
section += fullclear section += fullclear
# return indivgallery division to its caller # return indivgallery division to its caller
@ -1827,16 +1827,25 @@ class BasePage(object):
# return hyperlink to its caller # return hyperlink to its caller
return hyper return hyper
# TODO. Check img_url of callers
def media_link(self, handle, img_url, name, up, usedescr = True): def media_link(self, handle, img_url, name, up, usedescr = True):
"""
creates and returns a hyperlink to the thumbnail image
@param: handle - photo handle
@param: img_url - thumbnail url
@param: name - photo description
@param: up - whether to add "../../.." to url
@param: usedescr - add media description
"""
url = self.report.build_url_fname_html(handle, "img", up) url = self.report.build_url_fname_html(handle, "img", up)
# begin thumbnail division # begin thumbnail division
with Html("div", class_ = "thumbnail") as thumbnail: with Html("div", class_ = "thumbnail") as thumbnail:
# begin hyperlink # begin hyperlink
hyper = (Html("a", href = url, title = name) + hyper = Html("a", href = url, title = name) + (
Html("img", src = img_url, alt = name) ) Html("img", src = img_url, alt = name)
)
thumbnail += hyper thumbnail += hyper
if usedescr: if usedescr:
@ -1846,21 +1855,28 @@ class BasePage(object):
return thumbnail return thumbnail
def doc_link(self, handle, name, up, usedescr = True): def doc_link(self, handle, name, up, usedescr = True):
# TODO. Check extension of handle """
create a hyperlink for the media object and returns it
@param: handle - document handle
@param: name - document name
@param: up - whether to add "../../.." or not
@param: usedescr - add description to hyperlink
"""
url = self.report.build_url_fname(handle, "img", up) url = self.report.build_url_fname(handle, "img", up)
# begin thumbnail division # begin thumbnail division
thumbnail = Html("div", class_ = "thumbnail") with Html("div", class_ = "thumbnail") as thumbnail:
# begin hyperlink # begin hyperlink
hyper = Html("a", href = url, title = name) hyper = Html("a", href = url, title = name)
thumbnail += hyper thumbnail += hyper
url = self.report.build_url_image("document.png", "images", up) url = self.report.build_url_image("document.png", "images", up)
hyper += Html("img", src = url, alt = html_escape(name), title = html_escape(name)) hyper += Html("img", src = url, alt = html_escape(name), title = html_escape(name))
if usedescr: if usedescr:
hyper += Html("p", html_escape(name), inline = True) hyper += Html("p", html_escape(name), inline = True)
# return thumbnail division to its callers # return thumbnail division to its callers
return thumbnail return thumbnail