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
----------------------------------------------------- */
#indivgallery h4 {
margin-bottom:1em;
margin-bottom: 1em;
}
#indivgallery .thumbnail {
margin:0;
float:left;
width:130px;
height:150px;
text-align:center;
margin: 0;
float: left;
width: 130px;
height: 150px;
text-align: center;
}
#indivgallery div.thumbnail a {
display:block;
margin:0;
padding:0;
background:none;
display: block;
margin: 0;
padding: 0;
text-decoration: none;
cursor: pointer;
}
#indivgallery div.thumbnail a img {
margin-bottom:.5cm;
padding:0;
padding: 0;
border: solid 1px #000;
}
#indivgallery div.thumbnail p {
font:normal .7em/1.4em sans-serif;
text-align:center;
width:80%;
margin:0 auto;
padding:0;
font: normal .7em/1.4em sans-serif;
text-align: center;
width: 80%;
margin: 0 auto;
padding: 0;
}
/* Subsections : Narrative

View File

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