Removed the use of key in write_header(). Added <h2> tags back into write_header() so that the printed pages can be identified by it. Re-wrote alphabet_navigation for the class EventsListPage only. Added title for navigation and alphabet so that screen readers and braille writers can identify the menu items.
svn: r15256
This commit is contained in:
		| @@ -143,7 +143,7 @@ _NARRATIVESCREEN = "narrative-screen.css" | ||||
| _NARRATIVEPRINT = "narrative-print.css" | ||||
|  | ||||
| # variables for alphabet_navigation() | ||||
| _KEYPERSON, _KEYPLACE, _KEYEVENT, _ALPHAEVENT = 0, 1, 2, 3 | ||||
| _KEYPERSON, _KEYPLACE, _KEYEVENT = 0, 1, 2 | ||||
|  | ||||
| # Web page filename extensions | ||||
| _WEB_EXT = ['.html', '.htm', '.shtml', '.php', '.php3', '.cgi'] | ||||
| @@ -980,7 +980,7 @@ class BasePage(object): | ||||
|         # return footer to its callers | ||||
|         return footer | ||||
|  | ||||
|     def write_header(self, title, key): | ||||
|     def write_header(self, title): | ||||
|         """ | ||||
|         Note. 'title' is used as currentsection in the navigation links and | ||||
|         as part of the header title. | ||||
| @@ -1042,29 +1042,29 @@ class BasePage(object): | ||||
|         head += meta | ||||
|         head += links | ||||
|  | ||||
|         # alpha event pages do not need these things | ||||
|         if key is not _ALPHAEVENT: | ||||
|         # begin header section | ||||
|         headerdiv = (Html("div", id = 'header') + | ||||
|             Html("h1", html_escape(self.title_str), id = "SiteTitle", inline = True) | ||||
|             ) | ||||
|         body += headerdiv | ||||
|  | ||||
|             # begin header section | ||||
|             headerdiv = (Html("div", id = 'header') + | ||||
|                 Html("h1", html_escape(self.title_str), id = "SiteTitle", inline = True) | ||||
|                 ) | ||||
|             body += headerdiv | ||||
|         header_note = self.report.options['headernote'] | ||||
|         if header_note: | ||||
|             note = db.get_note_from_gramps_id(header_note) | ||||
|  | ||||
|             header_note = self.report.options['headernote'] | ||||
|             if header_note: | ||||
|                 note = db.get_note_from_gramps_id(header_note) | ||||
|  | ||||
|                 user_header = Html("div", id = 'user_header') | ||||
|                 headerdiv += user_header   | ||||
|             user_header = Html("div", id = 'user_header') | ||||
|             headerdiv += user_header   | ||||
|   | ||||
|                 # attach note | ||||
|                 user_header += note.get() | ||||
|             # attach note | ||||
|             user_header += note.get() | ||||
|  | ||||
|             # Begin Navigation Menu | ||||
|             body += self.display_nav_links(title) | ||||
|         # Begin Navigation Menu | ||||
|         body += self.display_nav_links(title) | ||||
|  | ||||
|         # return to its caller, page and body | ||||
|         # Add page title for the printed page as there is no navigation menus for reference | ||||
|         body += Html("h2", title, inline = True) | ||||
|  | ||||
|         # return to its callers: page and body | ||||
|         return page, body | ||||
|  | ||||
|     def display_nav_links(self, currentsection): | ||||
| @@ -1141,7 +1141,7 @@ class BasePage(object): | ||||
|  | ||||
|             cs = 'class = "CurrentSection"' if cs else "" | ||||
|             ul += (Html("li", attr = cs, inline = True) + | ||||
|                    Html("a", nav_text, href = url) | ||||
|                    Html("a", nav_text, href = url, title = _("Main navigation item: %s" % nav_text)) | ||||
|                   ) | ||||
|  | ||||
|         navigation += ul | ||||
| @@ -1157,6 +1157,7 @@ class BasePage(object): | ||||
|             obj = db.get_object_from_gramps_id(pic_id) | ||||
|             if obj is None: | ||||
|                 return None | ||||
|  | ||||
|             obj_handle = obj.handle | ||||
|             mime_type = obj.get_mime_type() | ||||
|             if mime_type and mime_type.startswith("image"): | ||||
| @@ -1729,8 +1730,8 @@ class BasePage(object): | ||||
|         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 = html_escape(name)) + | ||||
|                      Html("img", src = img_url, alt = html_escape(name)) ) | ||||
|             thumbnail += hyper | ||||
|  | ||||
|             if usedescr: | ||||
| @@ -1747,7 +1748,7 @@ class BasePage(object): | ||||
|         thumbnail = Html("div", class_ = "thumbnail") | ||||
|  | ||||
|         # begin hyperlink | ||||
|         hyper = Html("a", href = url, title = name) | ||||
|         hyper = Html("a", href = url, title = html_escape(name)) | ||||
|         thumbnail += hyper | ||||
|  | ||||
|         url = self.report.build_url_image("document.png", "images", up) | ||||
| @@ -1884,7 +1885,7 @@ class IndividualListPage(BasePage): | ||||
|         showparents = report.options['showparents'] | ||||
|  | ||||
|         of = self.report.create_file("individuals") | ||||
|         indlistpage, body = self.write_header(_("Individuals"), _KEYPERSON) | ||||
|         indlistpage, body = self.write_header(_("Individuals")) | ||||
|  | ||||
|         # begin Individuals division | ||||
|         with Html("div", class_ = "content", id = "Individuals") as individuallist: | ||||
| @@ -1897,8 +1898,8 @@ class IndividualListPage(BasePage): | ||||
|             individuallist += Html("p", msg, id = "description") | ||||
|  | ||||
|             # add alphabet navigation | ||||
|             menu_set = get_first_letters(db, person_handle_list, _KEYPERSON)  | ||||
|             alpha_nav, menu_set = alphabet_navigation(menu_set, _KEYPERSON) | ||||
|             menu_set = get_first_letters(db, person_handle_list, _KEYPERSON) | ||||
|             alpha_nav, menu_set = alphabet_navigation(menu_set) | ||||
|             if alpha_nav is not None: | ||||
|                 individuallist += alpha_nav | ||||
|  | ||||
| @@ -2062,7 +2063,7 @@ class SurnamePage(BasePage): | ||||
|  | ||||
|         of = self.report.create_file(name_to_md5(surname), "srn") | ||||
|         self.up = True | ||||
|         surnamepage, body = self.write_header("%s - %s" % (_("Surname"), surname), _KEYPERSON) | ||||
|         surnamepage, body = self.write_header("%s - %s" % (_("Surname"), surname)) | ||||
|  | ||||
|         # begin SurnameDetail division | ||||
|         with Html("div", class_ = "content", id = "SurnameDetail") as surnamedetail: | ||||
| @@ -2211,7 +2212,7 @@ class PlaceListPage(BasePage): | ||||
|         db = report.database | ||||
|  | ||||
|         of = self.report.create_file("places") | ||||
|         placelistpage, body = self.write_header(_("Places"), _KEYPLACE) | ||||
|         placelistpage, body = self.write_header(_("Places")) | ||||
|  | ||||
|         # begin places division | ||||
|         with Html("div", class_ = "content", id = "Places") as placelist: | ||||
| @@ -2225,7 +2226,7 @@ class PlaceListPage(BasePage): | ||||
|  | ||||
|             # begin alphabet navigation | ||||
|             menu_set = get_first_letters(db, place_handles, _KEYPLACE)  | ||||
|             alpha_nav, menu_set = alphabet_navigation(menu_set, _KEYPLACE) | ||||
|             alpha_nav, menu_set = alphabet_navigation(menu_set) | ||||
|             if alpha_nav is not None: | ||||
|                 placelist += alpha_nav | ||||
|  | ||||
| @@ -2310,7 +2311,7 @@ class PlacePage(BasePage): | ||||
|         of = self.report.create_file(place.get_handle(), "plc") | ||||
|         self.up = True | ||||
|         self.page_title = ReportUtils.place_name(db, place_handle) | ||||
|         placepage, body = self.write_header(_("Places"), _KEYPLACE) | ||||
|         placepage, body = self.write_header(_("Places")) | ||||
|  | ||||
|         # begin PlaceDetail Division | ||||
|         with Html("div", class_ = "content", id = "PlaceDetail") as placedetail: | ||||
| @@ -2381,7 +2382,7 @@ class EventListPage(BasePage): | ||||
|         db = report.database | ||||
|  | ||||
|         of = self.report.create_file("events") | ||||
|         eventslistpage, body = self.write_header(_("Events"), _KEYEVENT) | ||||
|         eventslistpage, body = self.write_header(_("Events")) | ||||
|  | ||||
|         # begin events list  division | ||||
|         with Html("div", class_ = "content", id = "EventList") as eventlist: | ||||
| @@ -2393,7 +2394,8 @@ class EventListPage(BasePage): | ||||
|             eventlist += Html("p", msg, id = "description") | ||||
|  | ||||
|             # get alphabet navigation for class EventListPage | ||||
|             alpha_nav, event_types = alphabet_navigation(event_types, _ALPHAEVENT) | ||||
|             menu_set = get_first_letters(db, event_types, _KEYEVENT) | ||||
|             alpha_nav, menu_set = alphabet_navigation(menu_set) | ||||
|             if alpha_nav is not None: | ||||
|                 eventlist += alpha_nav | ||||
|  | ||||
| @@ -2410,18 +2412,19 @@ class EventListPage(BasePage): | ||||
|                 trow.extend( | ||||
|                     Html("th", label, class_ = "Column" + colclass, inline = True) | ||||
|                     for (label, colclass) in [ | ||||
|                         [THEAD,    "Type"], | ||||
|                         [DHEAD,    "Date"], | ||||
|                         [GRAMPSID, "GRAMPSID"], | ||||
|                         [_PERSON,  "Person"] ] | ||||
|                         [_("Letter"), "Letter"], | ||||
|                         [THEAD,       "Type"], | ||||
|                         [DHEAD,       "Date"], | ||||
|                         [GRAMPSID,    "GRAMPSID"], | ||||
|                         [_PERSON,     "Person"] ] | ||||
|                     )  | ||||
|  | ||||
|                 tbody = Html("tbody") | ||||
|                 table += tbody | ||||
|  | ||||
|                 # separate events by their type and then thier event handles | ||||
|                 for (evt_type, datalist) in sort_event_types(db, event_types,  | ||||
|                         event_handle_list): | ||||
|                 displayed = [] | ||||
|                 for (evt_type, datalist) in sort_event_types(db, event_types, event_handle_list): | ||||
|                     first_event = True | ||||
|  | ||||
|                     for (date, gid, event_handle) in datalist: | ||||
| @@ -2430,14 +2433,23 @@ class EventListPage(BasePage): | ||||
|                         trow = Html("tr") | ||||
|                         tbody += trow | ||||
|  | ||||
|                         # display first letter if it is the first one | ||||
|                         tcell = Html("td", class_ = "ColumnLetter", inline = True) | ||||
|                         trow += tcell | ||||
|  | ||||
|                         ltr = evt_type[0] | ||||
|                         if ltr in displayed: | ||||
|                             tcell += " " | ||||
|                         else: | ||||
|                             trow.attr = 'class = "BeginLetter" '  | ||||
|                             tcell += Html("a", ltr, name = ltr, title = "Events beginning with letter %s" % ltr,  | ||||
|                                 inline = True) | ||||
|  | ||||
|                         # display Event type if first in the list | ||||
|                         tcell = Html("td", class_ = "ColumnType", inline = True) | ||||
|                         trow += tcell | ||||
|                         if first_event: | ||||
|                             trow.attr = 'class = "BeginEvent"' | ||||
|                             tcell += Html("a", evt_type, name = evt_type,  | ||||
|                                 title = _("Event types beginning with %(eventtype)s") % { | ||||
|                                     'eventtype': evt_type}, inline = True) | ||||
|                             tcell += evt_type | ||||
|                         else: | ||||
|                             tcell += " "  | ||||
|  | ||||
| @@ -2503,7 +2515,8 @@ class EventListPage(BasePage): | ||||
|                                 first_person = False | ||||
|                         else: | ||||
|                             tcell += " "  | ||||
|                         first_event = False     | ||||
|                         first_event = False | ||||
|                         displayed.append(ltr) | ||||
|  | ||||
|         # add clearline for proper styling | ||||
|         # add footer section | ||||
| @@ -2542,7 +2555,7 @@ class EventPage(BasePage): | ||||
|         self.bibli = Bibliography() | ||||
|  | ||||
|         of = self.report.create_file(event_handle, "evt") | ||||
|         eventpage, body = self.write_header(_("Events"), _KEYEVENT) | ||||
|         eventpage, body = self.write_header(_("Events")) | ||||
|  | ||||
|         # start event detail division | ||||
|         with Html("div", class_ = "content", id = "EventDetail") as eventdetail: | ||||
| @@ -2690,7 +2703,7 @@ class MediaPage(BasePage): | ||||
|  | ||||
|         copy_thumbnail(self.report, handle, media) | ||||
|         self.page_title = media.get_description() | ||||
|         mediapage, body = self.write_header("%s - %s" % (_("Media"), self.page_title), _KEYPERSON) | ||||
|         mediapage, body = self.write_header("%s - %s" % (_("Media"), self.page_title)) | ||||
|  | ||||
|         # begin MediaDetail division | ||||
|         with Html("div", class_ = "content", id = "GalleryDetail") as mediadetail: | ||||
| @@ -2784,9 +2797,9 @@ class MediaPage(BasePage): | ||||
|                                     url = self.report.build_url_fname(newpath,  | ||||
|                                                 None, self.up) | ||||
|                                 mediadisplay += Html("a", href = url) + ( | ||||
|                                     Html("img", width=new_width,  | ||||
|                                          height=new_height, src=url, | ||||
|                                          alt=html_escape(self.page_title)) | ||||
|                                     Html("img", width = new_width,  | ||||
|                                          height = new_height, src = url, | ||||
|                                          alt = html_escape(self.page_title)) | ||||
|                                         ) | ||||
|                     else: | ||||
|                         dirname = tempfile.mkdtemp() | ||||
| @@ -2813,7 +2826,7 @@ class MediaPage(BasePage): | ||||
|                             if target_exists: | ||||
|                                 # TODO. Convert disk path to URL | ||||
|                                 url = self.report.build_url_fname(newpath, None, self.up) | ||||
|                                 hyper = Html("a", href = url) + ( | ||||
|                                 hyper = Html("a", href = url, title = html_escape(self.page_title)) + ( | ||||
|                                     Html("img", src = img_url, alt = html_escape(self.page_title)) | ||||
|                                     ) | ||||
|                                 mediadisplay += hyper | ||||
| @@ -2943,10 +2956,10 @@ class SurnameListPage(BasePage): | ||||
|  | ||||
|         if order_by == self.ORDER_BY_NAME: | ||||
|             of = self.report.create_file(filename) | ||||
|             surnamelistpage, body = self.write_header(_('Surnames'), _KEYPERSON) | ||||
|             surnamelistpage, body = self.write_header(_('Surnames')) | ||||
|         else: | ||||
|             of = self.report.create_file("surnames_count") | ||||
|             surnamelistpage, body = self.write_header(_('Surnames by person count'), _KEYPERSON) | ||||
|             surnamelistpage, body = self.write_header(_('Surnames by person count')) | ||||
|  | ||||
|         # begin surnames division | ||||
|         with Html("div", class_ = "content", id = "surnames") as surnamelist: | ||||
| @@ -2963,7 +2976,7 @@ class SurnameListPage(BasePage): | ||||
|             # only if surname list not surname count | ||||
|             if order_by == self.ORDER_BY_NAME: | ||||
|                 menu_set = get_first_letters(db, person_handle_list, _KEYPERSON) | ||||
|                 alpha_nav, menu_set = alphabet_navigation(menu_set, _KEYPERSON) | ||||
|                 alpha_nav, menu_set = alphabet_navigation(menu_set) | ||||
|                 if alpha_nav is not None: | ||||
|                     surnamelist += alpha_nav | ||||
|  | ||||
| @@ -3071,7 +3084,7 @@ class IntroductionPage(BasePage): | ||||
|         db = report.database | ||||
|  | ||||
|         of = self.report.create_file(report.intro_fname) | ||||
|         intropage, body = self.write_header(_('Introduction'), _KEYPERSON) | ||||
|         intropage, body = self.write_header(_('Introduction')) | ||||
|  | ||||
|         # begin Introduction division | ||||
|         with Html("div", class_ = "content", id = "Introduction") as section: | ||||
| @@ -3108,7 +3121,7 @@ class HomePage(BasePage): | ||||
|         db = report.database | ||||
|  | ||||
|         of = self.report.create_file("index") | ||||
|         homepage, body = self.write_header(_('Home'), _KEYPERSON) | ||||
|         homepage, body = self.write_header(_('Home')) | ||||
|  | ||||
|         # begin home division | ||||
|         with Html("div", class_ = "content", id = "Home") as section: | ||||
| @@ -3145,7 +3158,7 @@ class SourceListPage(BasePage): | ||||
|         source_dict = {} | ||||
|  | ||||
|         of = self.report.create_file("sources") | ||||
|         sourcelistpage, body = self.write_header(_("Sources"), _KEYPERSON) | ||||
|         sourcelistpage, body = self.write_header(_("Sources")) | ||||
|  | ||||
|         # begin source list division | ||||
|         with Html("div", class_ = "content", id = "Sources") as sourceslist: | ||||
| @@ -3216,7 +3229,7 @@ class SourcePage(BasePage): | ||||
|  | ||||
|         of = self.report.create_file(source.get_handle(), "src") | ||||
|         self.up = True | ||||
|         sourcepage, body = self.write_header(_('Sources'), _KEYPERSON) | ||||
|         sourcepage, body = self.write_header(_('Sources')) | ||||
|  | ||||
|         # begin source detail division | ||||
|         with Html("div", class_ = "content", id = "SourceDetail") as section: | ||||
| @@ -3285,7 +3298,7 @@ class MediaListPage(BasePage): | ||||
|         db = report.database | ||||
|  | ||||
|         of = self.report.create_file("media") | ||||
|         medialistpage, body = self.write_header(_('Media'), _KEYPERSON) | ||||
|         medialistpage, body = self.write_header(_('Media')) | ||||
|  | ||||
|         # begin gallery division | ||||
|         with Html("div", class_ = "content", id = "Gallery") as medialist: | ||||
| @@ -3402,7 +3415,7 @@ class DownloadPage(BasePage): | ||||
|             return | ||||
|  | ||||
|         of = self.report.create_file("download") | ||||
|         downloadpage, body = self.write_header(_('Download'), _KEYPERSON) | ||||
|         downloadpage, body = self.write_header(_('Download')) | ||||
|  | ||||
|         # begin download page and table | ||||
|         with Html("div", class_ = "content", id = "Download") as download: | ||||
| @@ -3509,7 +3522,7 @@ class ContactPage(BasePage): | ||||
|         db = report.database | ||||
|  | ||||
|         of = self.report.create_file("contact") | ||||
|         contactpage, body = self.write_header(_('Contact'), _KEYPERSON) | ||||
|         contactpage, body = self.write_header(_('Contact')) | ||||
|  | ||||
|         # begin contact division | ||||
|         with Html("div", class_ = "content", id = "Contact") as section: | ||||
| @@ -3590,7 +3603,7 @@ class IndividualPage(BasePage): | ||||
|  | ||||
|         of = self.report.create_file(person.handle, "ppl") | ||||
|         self.up = True | ||||
|         indivdetpage, body = self.write_header(self.sort_name, _KEYPERSON) | ||||
|         indivdetpage, body = self.write_header(self.sort_name) | ||||
|  | ||||
|         # begin individualdetail division | ||||
|         with Html("div", class_ = "content", id = 'IndividualDetail') as individualdetail: | ||||
| @@ -4677,7 +4690,7 @@ class RepositoryListPage(BasePage): | ||||
|         db = report.database | ||||
|  | ||||
|         of = self.report.create_file("repositories") | ||||
|         repolistpage, body = self.write_header(_("Repositories"), _KEYPERSON) | ||||
|         repolistpage, body = self.write_header(_("Repositories")) | ||||
|  | ||||
|         # begin RepositoryList division | ||||
|         with Html("div", class_ = "content", id = "RepositoryList") as repositorylist: | ||||
| @@ -4746,7 +4759,7 @@ class RepositoryPage(BasePage): | ||||
|  | ||||
|         of = self.report.create_file(handle, 'repo') | ||||
|         self.up = True | ||||
|         repositorypage, body = self.write_header(_('Repositories'), _KEYPERSON) | ||||
|         repositorypage, body = self.write_header(_('Repositories')) | ||||
|  | ||||
|         # begin RepositoryDetail division and page title | ||||
|         with Html("div", class_ = "content", id = "RepositoryDetail") as repositorydetail: | ||||
| @@ -4818,7 +4831,7 @@ class AddressBookListPage(BasePage): | ||||
|         of = self.report.create_file("addressbook") | ||||
|  | ||||
|         # Add xml, doctype, meta and stylesheets | ||||
|         addressbooklistpage, body = self.write_header("%s - %s" % (title, _("Address Book")), _KEYPERSON) | ||||
|         addressbooklistpage, body = self.write_header(_("Address Book")) | ||||
|  | ||||
|         # begin AddressBookList division | ||||
|         with Html("div", class_ = "content", id = "AddressBookList") as addressbooklist: | ||||
| @@ -4920,7 +4933,7 @@ class AddressBookPage(BasePage): | ||||
|  | ||||
|         # set the file name and open file | ||||
|         of = self.report.create_file(person_handle, "addr") | ||||
|         addressbookpage, body = self.write_header("%s - %s" % (title, _("Address Book")), _KEYPERSON) | ||||
|         addressbookpage, body = self.write_header(_("Address Book")) | ||||
|  | ||||
|         # begin address book page division and section title | ||||
|         with Html("div", class_ = "content", id = "AddressBookDetail") as addressbookdetail: | ||||
| @@ -5359,23 +5372,19 @@ class NavWebReport(Report): | ||||
|         a dump of all the events sorted by event type, date, and surname | ||||
|         for classes EventListPage and EventPage | ||||
|         """ | ||||
|         db = self.database | ||||
|  | ||||
|         # set up progress bar for event pages; using ind list | ||||
|         event_handle_list, event_types = build_event_data(db, ind_list) | ||||
|         event_handle_list, event_types = build_event_data(self.database, ind_list) | ||||
|         self.progress.set_pass(_("Creating event pages"), len(event_handle_list)) | ||||
|  | ||||
|         # send all data to the events list page | ||||
|         EventListPage(self, self.title, event_types, event_handle_list) | ||||
|  | ||||
|         index = 0 | ||||
|         for event_handle in event_handle_list: | ||||
|             self.progress.set_header(_("Creating event page %02d of %02d") % (index + 1, len(event_handle_list))) | ||||
|  | ||||
|             # create individual event pages | ||||
|             EventPage(self, self.title, event_handle) | ||||
|  | ||||
|             index += 1 | ||||
|             self.progress.step() | ||||
|  | ||||
|     def gallery_pages(self, source_list): | ||||
| @@ -5436,9 +5445,7 @@ class NavWebReport(Report): | ||||
|         # RepositoryListPage Class | ||||
|         RepositoryListPage(self, self.title, repos_dict, keys) | ||||
|  | ||||
|         count = 1 | ||||
|         for index, key in enumerate(keys): | ||||
|             self.progress.set_header(_("Creating repository page %d of %d" % (count, repo_size))) | ||||
|             (repo, handle) = repos_dict[key] | ||||
|  | ||||
|             # RepositoryPage Class | ||||
| @@ -5446,7 +5453,6 @@ class NavWebReport(Report): | ||||
|  | ||||
|             # increment progress bar  | ||||
|             self.progress.step() | ||||
|             count += 1 | ||||
|  | ||||
|     def addressbook_pages(self, ind_list): | ||||
|         """ | ||||
| @@ -5495,15 +5501,12 @@ class NavWebReport(Report): | ||||
|             addr_size = len( has_url_address ) | ||||
|             self.progress.set_pass(_("Creating address book pages ..."), addr_size) | ||||
|  | ||||
|             count = 1  | ||||
|             for (sort_name, person_handle, has_add, has_res, has_url) in has_url_address: | ||||
|                 self.progress.set_header(_("Creating address book page %d of %d" % (count, addr_size)))  | ||||
|  | ||||
|                 AddressBookPage(self, self.title, person_handle, has_add, has_res, has_url) | ||||
|  | ||||
|                 # increment progress bar | ||||
|                 self.progress.step() | ||||
|                 count += 1 | ||||
|  | ||||
|     def build_subdirs(self, subdir, fname, up = False): | ||||
|         """ | ||||
| @@ -6169,30 +6172,46 @@ def first_letter(string): | ||||
|     return letter | ||||
|  | ||||
| def get_first_letters(db, handle_list, key): | ||||
|     """ key is _PLACE or _PERSON ....""" | ||||
|     """ | ||||
|     return a dictionary for the first letters | ||||
|  | ||||
|     @param: habdle_list = a dictionary of handle or event types | ||||
|     @param: key = _KEYPERSON, _KEYPLACE, or _KEYEVENT | ||||
|     """ | ||||
|   | ||||
|     first_letters = [] | ||||
|  | ||||
|     for handle in handle_list: | ||||
|         if key == _KEYPERSON: | ||||
|             keyname = __get_person_keyname(db, handle) | ||||
|         else: | ||||
|             keyname = __get_place_keyname(db, handle)  | ||||
|         ltr = first_letter(keyname) | ||||
|     if key == _KEYEVENT: | ||||
|         for evttype in handle_list: | ||||
|             first_letters.append(evttype[0]) | ||||
|  | ||||
|         if ltr is not ",": | ||||
|             first_letters.append(ltr) | ||||
|     else: | ||||
|  | ||||
|         for handle in handle_list: | ||||
|             if key == _KEYPERSON: | ||||
|                 keyname = __get_person_keyname(db, handle) | ||||
|             else: | ||||
|                 keyname = __get_place_keyname(db, handle)  | ||||
|             ltr = first_letter(keyname) | ||||
|  | ||||
|             if ltr is not ",": | ||||
|                 first_letters.append(ltr) | ||||
|  | ||||
|     # return first letters from data to its callers | ||||
|     return first_letters | ||||
|  | ||||
| def alphabet_navigation(menu_set, alphakey): | ||||
| def alphabet_navigation(menu_set): | ||||
|     """ | ||||
|     Will create the alphabet navigation bar for classes IndividualListPage, | ||||
|     SurnameListPage, PlaceListPage, and EventList | ||||
|  | ||||
|     @param: menu_set -- a dictionary of either letters or words | ||||
|     @param: alphakey -- either Person, Place, or AlphaEvent | ||||
|     """ | ||||
|  | ||||
|     # if no letters or words, return None to its callers | ||||
|     if not menu_set: | ||||
|         return None, [] | ||||
|  | ||||
|     sorted_set = defaultdict(int) | ||||
|     # The comment below from the glibc locale sv_SE in | ||||
|     # localedata/locales/sv_SE : | ||||
| @@ -6207,7 +6226,6 @@ def alphabet_navigation(menu_set, alphakey): | ||||
|     # See : http://www.gramps-project.org/bugs/view.php?id = 2933 | ||||
|     # | ||||
|     (lang_country, modifier ) = locale.getlocale() | ||||
|     ltr = get_first_letters | ||||
|  | ||||
|     for menu_item in menu_set: | ||||
|         sorted_set[menu_item] += 1 | ||||
| @@ -6215,20 +6233,12 @@ def alphabet_navigation(menu_set, alphakey): | ||||
|     # remove the number of each occurance of each letter | ||||
|     sorted_alpha_index = sorted(sorted_set, key = locale.strxfrm) | ||||
|  | ||||
|     # remove any commas from the letter set | ||||
|     sorted_alpha_index = [(menu_item) for menu_item in sorted_alpha_index if menu_item != ","] | ||||
|  | ||||
|     # remove any single spaces from the letter set also | ||||
|     # Event Types can and do have spaces, so leave them alone for now... | ||||
|     if alphakey is not _ALPHAEVENT:   | ||||
|         sorted_alpha_index = [(ltr) for ltr in sorted_alpha_index if ltr != " "] | ||||
|  | ||||
|     # if no letters or words, return None to its callers | ||||
|     if not sorted_alpha_index: | ||||
|         return None, [] | ||||
|     # remove any commas and spaces from the letter set | ||||
|     sorted_alpha_index = [(menu_item) for menu_item in sorted_alpha_index  | ||||
|         if menu_item not in [ ",", " "]] | ||||
|  | ||||
|     num_ltrs = len(sorted_alpha_index) | ||||
|     num_of_cols = 34 if alphakey is not _ALPHAEVENT else 10 | ||||
|     num_of_cols = 32 | ||||
|     num_of_rows = ((num_ltrs // num_of_cols) + 1) | ||||
|  | ||||
|     # begin alphabet navigation division | ||||
| @@ -6245,10 +6255,14 @@ def alphabet_navigation(menu_set, alphakey): | ||||
|                 unordered += list | ||||
|  | ||||
|                 menu_item = sorted_alpha_index[index] | ||||
|  | ||||
|                 # adding for Visually Impaired screen readers and braille writers | ||||
|                 title_str = _("Alphabet Navigation Item: %s" % menu_item) | ||||
|  | ||||
|                 if lang_country == "sv_SE" and menu_item == u'V': | ||||
|                     hyper = Html("a", "V,W", href = "#V,W", alt = "V,W") | ||||
|                     hyper = Html("a", "V,W", href = "#V,W", title = title_str) | ||||
|                 else: | ||||
|                     hyper = Html("a", menu_item, href = "#%s" % menu_item, alt = html_escape(menu_item)) | ||||
|                     hyper = Html("a", menu_item, href = "#%s" % menu_item, title = title_str) | ||||
|                 list += hyper | ||||
|  | ||||
|                 # increase letter/ word in sorted_alpha_index | ||||
|   | ||||
		Reference in New Issue
	
	Block a user