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:
Serge Noiraud 2021-12-03 10:31:06 +01:00 committed by GitHub
parent 1d51576a28
commit fd15775580
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 10 deletions

View File

@ -75,6 +75,7 @@ class Backlinks(Gramplet):
Display the back references for an object. Display the back references for an object.
""" """
self.evts = False self.evts = False
sdcolumn = None
for classname, handle in \ for classname, handle in \
self.dbstate.db.find_backlink_handles(active_handle): self.dbstate.db.find_backlink_handles(active_handle):
name = navigation_label(self.dbstate.db, classname, handle)[0] name = navigation_label(self.dbstate.db, classname, handle)[0]
@ -97,7 +98,8 @@ class Backlinks(Gramplet):
sdcolumn.set_visible(False) sdcolumn.set_visible(False)
else: else:
self.date_column.set_visible(False) self.date_column.set_visible(False)
sdcolumn.set_visible(False) if sdcolumn:
sdcolumn.set_visible(False)
self.set_has_data(self.model.count > 0) self.set_has_data(self.model.count > 0)
def get_has_data(self, active_handle): def get_has_data(self, active_handle):

View File

@ -2385,6 +2385,11 @@ class NavWebOptions(MenuReportOptions):
_('Whether or not to include the place pages.')) _('Whether or not to include the place pages.'))
addopt("inc_places", inc_places) 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 = BooleanOption(_('Include source pages'), False)
inc_sources.set_help( inc_sources.set_help(
_('Whether or not to include the source pages.')) _('Whether or not to include the source pages.'))

View File

@ -49,7 +49,7 @@ import logging
# Gramps module # Gramps module
#------------------------------------------------ #------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale 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.plug.report import Bibliography
from gramps.gen.mime import is_image_type from gramps.gen.mime import is_image_type
from gramps.plugins.lib.libhtml import Html from gramps.plugins.lib.libhtml import Html
@ -123,6 +123,34 @@ class PlacePages(BasePage):
LOG.debug(" %s", str(item)) LOG.debug(" %s", str(item))
message = _("Creating place pages") message = _("Creating place pages")
progress_title = self.report.pgrs_title(the_lang) 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, with self.r_user.progress(progress_title, message,
len(self.report.obj_dict[Place]) + 1 len(self.report.obj_dict[Place]) + 1
) as step: ) as step:
@ -134,7 +162,7 @@ class PlacePages(BasePage):
self.placepage(self.report, the_lang, the_title, p_handle[0], self.placepage(self.report, the_lang, the_title, p_handle[0],
place_name) place_name)
step() step()
self.placelistpage(self.report, the_lang, the_title) self.placelistpage(self.report, the_lang, the_title)
def placelistpage(self, report, the_lang, the_title): def placelistpage(self, report, the_lang, the_title):
""" """
@ -326,12 +354,13 @@ class PlacePages(BasePage):
with Html("div", class_="content", id="PlaceDetail") as placedetail: with Html("div", class_="content", id="PlaceDetail") as placedetail:
outerwrapper += placedetail outerwrapper += placedetail
media_list = place.get_media_list()
if self.create_media: if self.create_media:
media_list = place.get_media_list()
thumbnail = self.disp_first_img_as_thumbnail(media_list, thumbnail = self.disp_first_img_as_thumbnail(media_list,
place) place)
if thumbnail is not None: if thumbnail is not None:
placedetail += thumbnail if media_list[0].ref in self.report.obj_dict[Media]:
placedetail += thumbnail
# add section title # add section title
placedetail += Html("h3", placedetail += Html("h3",
@ -349,7 +378,9 @@ class PlacePages(BasePage):
self.dump_place(place, table) self.dump_place(place, table)
# place gallery # 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) placegallery = self.disp_add_img_as_gallery(media_list, place)
if placegallery is not None: if placegallery is not None:
placedetail += placegallery placedetail += placegallery
@ -429,9 +460,13 @@ class PlacePages(BasePage):
tooltip += Html("div", id="tooltip-content") tooltip += Html("div", id="tooltip-content")
# source references # source references
srcrefs = self.display_ind_sources(place) if not self.report.options['inc_uplaces']:
if srcrefs is not None: # We can't display source reference when we display
placedetail += srcrefs # 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
# References list # References list
ref_list = self.display_bkref_list(Place, place_handle) ref_list = self.display_bkref_list(Place, place_handle)
@ -462,7 +497,8 @@ class PlacePages(BasePage):
imglnk = self.media_link(photo_hdle, newpath, imglnk = self.media_link(photo_hdle, newpath,
descr, uplink=uplnk, descr, uplink=uplnk,
usedescr=False) usedescr=False)
tracelife += str(imglnk) if photo_hdle in self.report.obj_dict[Media]:
tracelife += str(imglnk)
break # We show only the first image break # We show only the first image
scripts = Html() scripts = Html()
if self.mapservice == "Google": if self.mapservice == "Google":