Navweb: add option to show all places (#1230)
* Navweb: add option to show all places Fixes #012315 * Don't display media, source ref for unused place. * backlink gramplet problem if no back references * Show image on the map only if it was collected. * Show the thumbnail place if already collected * Narrative web: minor changes to the text * changed back to source pages * restore last tanslatable text. * restore last strings
This commit is contained in:
parent
1d51576a28
commit
fd15775580
@ -75,6 +75,7 @@ class Backlinks(Gramplet):
|
||||
Display the back references for an object.
|
||||
"""
|
||||
self.evts = False
|
||||
sdcolumn = None
|
||||
for classname, handle in \
|
||||
self.dbstate.db.find_backlink_handles(active_handle):
|
||||
name = navigation_label(self.dbstate.db, classname, handle)[0]
|
||||
@ -97,6 +98,7 @@ class Backlinks(Gramplet):
|
||||
sdcolumn.set_visible(False)
|
||||
else:
|
||||
self.date_column.set_visible(False)
|
||||
if sdcolumn:
|
||||
sdcolumn.set_visible(False)
|
||||
self.set_has_data(self.model.count > 0)
|
||||
|
||||
|
@ -2385,6 +2385,11 @@ class NavWebOptions(MenuReportOptions):
|
||||
_('Whether or not to include the place pages.'))
|
||||
addopt("inc_places", inc_places)
|
||||
|
||||
inc_uplaces = BooleanOption(_('Include unused place pages'), False)
|
||||
inc_uplaces.set_help(
|
||||
_('Whether or not to include the unused place pages.'))
|
||||
addopt("inc_uplaces", inc_uplaces)
|
||||
|
||||
inc_sources = BooleanOption(_('Include source pages'), False)
|
||||
inc_sources.set_help(
|
||||
_('Whether or not to include the source pages.'))
|
||||
|
@ -49,7 +49,7 @@ import logging
|
||||
# Gramps module
|
||||
#------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
from gramps.gen.lib import (PlaceType, Place, PlaceName)
|
||||
from gramps.gen.lib import (PlaceType, Place, PlaceName, Media)
|
||||
from gramps.gen.plug.report import Bibliography
|
||||
from gramps.gen.mime import is_image_type
|
||||
from gramps.plugins.lib.libhtml import Html
|
||||
@ -123,6 +123,34 @@ class PlacePages(BasePage):
|
||||
LOG.debug(" %s", str(item))
|
||||
message = _("Creating place pages")
|
||||
progress_title = self.report.pgrs_title(the_lang)
|
||||
if self.report.options['inc_uplaces']:
|
||||
place_count = len(self.r_db.get_place_handles())
|
||||
else:
|
||||
place_count = len(self.report.obj_dict[Place])
|
||||
with self.r_user.progress(progress_title, message,
|
||||
place_count + 1
|
||||
) as step:
|
||||
if self.report.options['inc_uplaces']:
|
||||
# add unused place
|
||||
place_list = self.r_db.get_place_handles()
|
||||
for place_ref in place_list:
|
||||
if place_ref not in self.report.obj_dict[Place]:
|
||||
place = self.r_db.get_place_from_handle(place_ref)
|
||||
if place:
|
||||
place_name = place.get_title()
|
||||
p_fname = self.report.build_url_fname(place_ref,
|
||||
"plc",
|
||||
False,
|
||||
init=True)
|
||||
p_fname += self.ext
|
||||
plc_dict = (p_fname, place_name,
|
||||
place.gramps_id, None)
|
||||
self.report.obj_dict[Place][place_ref] = plc_dict
|
||||
p_name = _pd.display(self.r_db, place)
|
||||
plc_dict = (place_ref, p_name,
|
||||
place.gramps_id, None)
|
||||
self.report.obj_dict[PlaceName][p_name] = plc_dict
|
||||
|
||||
with self.r_user.progress(progress_title, message,
|
||||
len(self.report.obj_dict[Place]) + 1
|
||||
) as step:
|
||||
@ -326,11 +354,12 @@ class PlacePages(BasePage):
|
||||
with Html("div", class_="content", id="PlaceDetail") as placedetail:
|
||||
outerwrapper += placedetail
|
||||
|
||||
if self.create_media:
|
||||
media_list = place.get_media_list()
|
||||
if self.create_media:
|
||||
thumbnail = self.disp_first_img_as_thumbnail(media_list,
|
||||
place)
|
||||
if thumbnail is not None:
|
||||
if media_list[0].ref in self.report.obj_dict[Media]:
|
||||
placedetail += thumbnail
|
||||
|
||||
# add section title
|
||||
@ -349,7 +378,9 @@ class PlacePages(BasePage):
|
||||
self.dump_place(place, table)
|
||||
|
||||
# place gallery
|
||||
if self.create_media:
|
||||
if self.create_media and not self.report.options['inc_uplaces']:
|
||||
# Don't diplay media for unused places. It generates
|
||||
# "page not found" if they are not collected in pass 1.
|
||||
placegallery = self.disp_add_img_as_gallery(media_list, place)
|
||||
if placegallery is not None:
|
||||
placedetail += placegallery
|
||||
@ -429,6 +460,10 @@ class PlacePages(BasePage):
|
||||
tooltip += Html("div", id="tooltip-content")
|
||||
|
||||
# source references
|
||||
if not self.report.options['inc_uplaces']:
|
||||
# We can't display source reference when we display
|
||||
# unused places. These info are not in the collected objects.
|
||||
# This is to avoid "page not found" errors.
|
||||
srcrefs = self.display_ind_sources(place)
|
||||
if srcrefs is not None:
|
||||
placedetail += srcrefs
|
||||
@ -462,6 +497,7 @@ class PlacePages(BasePage):
|
||||
imglnk = self.media_link(photo_hdle, newpath,
|
||||
descr, uplink=uplnk,
|
||||
usedescr=False)
|
||||
if photo_hdle in self.report.obj_dict[Media]:
|
||||
tracelife += str(imglnk)
|
||||
break # We show only the first image
|
||||
scripts = Html()
|
||||
|
Loading…
Reference in New Issue
Block a user