Created Feature Request#5381; NarrativeWeb: Remove full sized images; please see http://www.gramps-project.org/bugs/view.php?id=5381 for further information...

svn: r18480
This commit is contained in:
Rob G. Healey 2011-11-22 05:31:15 +00:00
parent ff41ecc5cb
commit e527a0bb82

View File

@ -339,7 +339,7 @@ class BasePage(object):
self.noid = report.options['nogid']
self.linkhome = report.options['linkhome']
self.create_media = report.options['gallery']
self.inc_thumbnails = report.options['inc_thumbnails']
self.create_thumbs_only = report.options['create_thumbs_only']
self.inc_families = report.options['inc_families']
self.inc_events = report.options['inc_events']
@ -647,8 +647,6 @@ class BasePage(object):
@param: place_lat_long -- for use in Family Map Pages
"""
placetitle = place.get_title()
latitude, longitude = "", ""
latitude = place.get_latitude()
longitude = place.get_longitude()
@ -1245,10 +1243,11 @@ class BasePage(object):
not len(self.report.database.get_repository_handles()) ):
inc_repos = False
# include thumbnails preview page or not?
inc_thumbnails = True
if (not self.create_media or not self.report.inc_thumbnails):
inc_thumbnails = False
# create media pages...
if self.create_media:
_create_media_link = True
if self.create_thumbs_only:
_create_media_link = False
# determine which menu items will be available?
navs = [
@ -1259,8 +1258,8 @@ class BasePage(object):
('families', _("Families"), self.report.inc_families),
('places', _("Places"), True),
('events', _("Events"), self.report.inc_events),
('media', _("Media"), self.create_media),
('thumbnails', _("Thumbnails"), inc_thumbnails),
('media', _("Media"), _create_media_link),
('thumbnails', _("Thumbnails"), True),
('sources', _("Sources"), True),
('repositories', _("Repositories"), inc_repos),
("addressbook", _("Address Book"), self.report.inc_addressbook),
@ -2087,9 +2086,12 @@ class BasePage(object):
with Html("div", class_ = "thumbnail") as thumbnail:
# begin hyperlink
if not self.create_thumbs_only:
hyper = Html("a", href = url, title = name) + (
Html("img", src = img_url, alt = name)
)
else:
hyper = Html("img", src =img_url, alt =name)
thumbnail += hyper
if usedescr:
@ -2108,20 +2110,24 @@ class BasePage(object):
@param: usedescr - add description to hyperlink
"""
url = self.report.build_url_fname(handle, "img", up)
name = html_escape(name)
# begin thumbnail division
with Html("div", class_ = "thumbnail") as thumbnail:
document_url = self.report.build_url_image("document.png", "images", up)
# begin hyperlink
hyper = Html("a", href = url, title = html_escape(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))
if not self.create_thumbs_only:
document_link = Html("a", href =url, title = name) + (
Html("img", src =document_url, alt =name)
)
else:
document_link = Html("img", src =document_url, alt =name)
if usedescr:
hyper += Html('br')
hyper += Html("span", html_escape(name), inline = True)
document_link += Html('br') + (
Html("span", name, inline =True)
)
thumbnail += document_link
# return thumbnail division to its callers
return thumbnail
@ -4302,6 +4308,7 @@ class ThumbnailPreviewPage(BasePage):
def __init__(self, report, title, cb_progress):
BasePage.__init__(self, report, title)
db = report.database
self.create_thumbs_only = report.options['create_thumbs_only']
sort = Sort.Sort(db)
self.photo_keys = sorted(self.report.photo_list, key =sort.by_media_title_key)
@ -4311,8 +4318,13 @@ class ThumbnailPreviewPage(BasePage):
media_list = []
for phandle in self.photo_keys:
photo = db.get_object_from_handle(phandle)
if (photo and photo.get_mime_type().startswith("image/")):
if photo:
if photo.get_mime_type().startswith("image"):
media_list.append((photo.get_description(), phandle, photo))
if self.create_thumbs_only:
copy_thumbnail(self.report, phandle, photo)
if not media_list:
return
media_list.sort()
@ -4447,19 +4459,27 @@ class ThumbnailPreviewPage(BasePage):
"""
return Html("a", index, title =html_escape(name), href ="#%d" % index)
def thumb_hyper_image(self, img_src, subdir, fname, name):
def thumb_hyper_image(self, thumbnailUrl, subdir, fname, name):
"""
eplaces media_link() because it doesn't work for this instance
"""
name = html_escape(name)
url = "/".join(self.report.build_subdirs(subdir, fname) + [fname]) + self.ext
with Html("div", class_ ="thumbnail") as section:
thumb = Html("a", title =name, href =url) + (
Html("img", alt =name, src =img_src)
)
section += thumb
with Html("div", class_ ="content", id ="ThumbnailPreview") as section:
with Html("div", class_="snapshot") as snapshot:
section += snapshot
with Html("div", class_ ="thumbnail") as thumbnail:
snapshot += thumbnail
if not self.create_thumbs_only:
thumbnail_link = Html("a", href =url, title =name) + (
Html("img", src =thumbnailUrl, alt =name)
)
else:
thumbnail_link = Html("img", src =thumbnailUrl, alt =name)
thumbnail += thumbnail_link
return section
class DownloadPage(BasePage):
@ -4852,6 +4872,25 @@ class IndividualPage(BasePage):
# sort place_lat_long based on latitude and longitude order...
place_lat_long.sort()
# create the array, if there are more than one set of coordinates to be displayed?
if number_markers > 1:
tracelife = """
var tracelife = ["""
titleArray = """
var titleArray = ["""
for index in xrange(0, (number_markers - 1)):
dataline = place_lat_long[index]
latitude, longitude, placetitle = dateline[0], dataline[1], dataline[2]
tracelife += """ new google.maps.LatLng(%s, %s),""" % (latitude, longitude)
titleArray += """ ['%s'],""" % placetitle
dataline = place_lat_long[-1]
latitude, longitude, placetitle = dataline[0], dataline[1], dataline[2]
tracelife += """ new google.maps.LatLng(%s, %s) ];""" % (latitude, longitude)
titleArray += """ ['%s'] ];""" % placetitle
of = self.report.create_file(person.get_handle(), "maps")
self.up = True
familymappage, head, body = self.write_header(_("Family Map"))
@ -4901,13 +4940,6 @@ class IndividualPage(BasePage):
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var lifeHistory = [""" % (midX_, midY_, zoomlevel)
for index in xrange(0, (number_markers - 1)):
latitude, longitude = place_lat_long[index][0], place_lat_long[index][1]
jsc += """ new google.maps.LatLng(%s, %s),""" % (latitude, longitude)
latitude, longitude = place_lat_long[-1][0], place_lat_long[-1][1]
jsc += """ new google.maps.LatLng(%s, %s) ];
var flightPath = new google.maps.Polyline({
path: lifeHistory,
strokeColor: "#FF0000",
@ -6276,8 +6308,9 @@ class NavWebReport(Report):
self.navigation = self.options["navigation"]
self.title = self.options['title']
self.inc_gallery = self.options['gallery']
self.inc_thumbnails = self.options['inc_thumbnails']
self.create_thumbs_only = self.options['create_thumbs_only']
self.inc_contact = self.options['contactnote'] or \
self.options['contactimg']
@ -6288,9 +6321,6 @@ class NavWebReport(Report):
# include families or not?
self.inc_families = self.options['inc_families']
# create a media thumbnail preview page or not?
self.inc_thumbnails = self.options['inc_thumbnails']
# create an event pages or not?
self.inc_events = self.options['inc_events']
@ -6449,10 +6479,10 @@ class NavWebReport(Report):
# build classes MediaListPage and MediaPage
if self.inc_gallery:
self.gallery_pages(source_list)
if not self.create_thumbs_only:
self.media_pages(source_list)
# build Thumbnail Preview Page...
if self.inc_thumbnails:
self.thumbnail_preview_page()
# Build classes source pages a second time to pick up sources referenced
@ -6719,7 +6749,7 @@ class NavWebReport(Report):
self.user.step_progress()
self.user.end_progress()
def gallery_pages(self, source_list):
def media_pages(self, source_list):
"""
creates MediaListPage and MediaPage
"""
@ -6739,8 +6769,7 @@ class NavWebReport(Report):
gc.collect() # Reduce memory usage when there are many images.
next = None if index == total else photo_keys[index]
# Notice. Here self.photo_list[photo_handle] is used not self.photo_list
MediaPage(self, self.title, photo_handle, source_list, self.photo_list[photo_handle],
(prev, next, index, total))
MediaPage(self, self.title, photo_handle, source_list, self.photo_list[photo_handle], (prev, next, index, total))
self.user.step_progress()
prev = photo_handle
index += 1
@ -7259,6 +7288,12 @@ class NavWebOptions(MenuReportOptions):
addopt( "gallery", self.__gallery )
self.__gallery.connect('value-changed', self.__gallery_changed)
self.__create_thumbs_only = BooleanOption(_("Create and only use thumbnail- sized images"), True)
self.__create_thumbs_only.set_help(_("This options allows you the choice to not create any full- sized"
"images as in the Media Page, and only a thumb- sized images or not?"))
addopt("create_thumbs_only", self.__create_thumbs_only)
self.__create_thumbs_only.connect("value-changed", self.__gallery_changed)
self.__maxinitialimagewidth = NumberOption(_("Max width of initial image"),
_DEFAULT_MAX_IMG_WIDTH, 0, 2000)
self.__maxinitialimagewidth.set_help(_("This allows you to set the maximum width "
@ -7271,12 +7306,6 @@ class NavWebOptions(MenuReportOptions):
"of the image shown on the media page. Set to 0 for no limit."))
addopt( "maxinitialimageheight", self.__maxinitialimageheight)
self.__inc_thumbnails = BooleanOption(_("Create a media thumbnails preview page"), False)
self.__inc_thumbnails.set_help(_("Whether to create a thumbnail's preview page? "
"This will be hyper- linked to the Media List Page only!")
)
addopt("inc_thumbnails", self.__inc_thumbnails)
self.__gallery_changed()
nogid = BooleanOption(_('Suppress Gramps ID'), False)
@ -7517,17 +7546,30 @@ class NavWebOptions(MenuReportOptions):
"""
Handles the changing nature of gallery
"""
_gallery_option = self.__gallery.get_value()
_create_thumbs_only_option = self.__create_thumbs_only.get_value()
if not self.__gallery.get_value():
# images and media objects to be used, make all opti8ons available...
if _gallery_option:
self.__create_thumbs_only.set_available(True)
self.__maxinitialimagewidth.set_available(True)
self.__maxinitialimageheight.set_available(True)
# thumbnail-sized images only...
if _create_thumbs_only_option:
self.__maxinitialimagewidth.set_available(False)
self.__maxinitialimageheight.set_available(False)
self.__inc_thumbnails.set_available(False)
# full- sized images and Media Pages will be created...
else:
self.__maxinitialimagewidth.set_available(True)
self.__maxinitialimageheight.set_available(True)
self.__inc_thumbnails.set_available(True)
# no images or media objects are to be used...
else:
self.__create_thumbs_only.set_available(False)
self.__maxinitialimagewidth.set_available(False)
self.__maxinitialimageheight.set_available(False)
def __living_changed(self):
"""