From b93936f10f7652bf0b5b63338c16c3a988d70ff8 Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Tue, 23 Jul 2013 15:40:59 -0400 Subject: [PATCH] OPAC Browse: Replace English pager with customizable pager I have changed the way the formerly English-only paging shortcuts work. There is no longer any need to customize config.tt2. Instead, set the org unit setting 'opac.browse.paging_shortcuts' to a string containing all the characters that you want used in shortcut links, in order. For English, you might use: *0-9*ABCDEFGHIJKLMNOPQRSTUVWXYZ Asterisks are used here to set off shortcuts that are more than one character long. Everything outside of asteriks is a one-character shortcut. Signed-off-by: Lebbeous Fogle-Weekley --- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Browse.pm | 13 +++++++++++++ Open-ILS/src/sql/Pg/950.data.seed-values.sql | 14 ++++++++++++++ .../sql/Pg/upgrade/YYYY.schema.bib-auth-browse.sql | 10 ++++++++++ Open-ILS/src/templates/opac/browse.tt2 | 7 +++---- Open-ILS/src/templates/opac/parts/config.tt2 | 9 --------- docs/RELEASE_NOTES_NEXT/OPAC/BibAuthBrowse.txt | 21 +++++++++++++-------- 6 files changed, 53 insertions(+), 21 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Browse.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Browse.pm index 81644e63e3..593eb2b049 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Browse.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Browse.pm @@ -338,6 +338,19 @@ sub load_browse { } } + my $pager_shortcuts = $self->ctx->{get_org_setting}->( + $self->ctx->{physical_loc} || $self->ctx->{search_ou} || + $self->ctx->{aou_tree}->id, 'opac.browse.pager_shortcuts' + ); + if ($pager_shortcuts) { + my @pager_shortcuts; + while ($pager_shortcuts =~ s/(\*(.+?)\*)//) { + push @pager_shortcuts, [substr($2, 0, 1), $2]; + } + push @pager_shortcuts, map { [$_, $_] } split //, $pager_shortcuts; + $self->ctx->{pager_shortcuts} = \@pager_shortcuts; + } + if ($self->cgi->param('qtype') and defined $self->cgi->param('bterm')) { $self->leading_article_test( diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index a6a16c2a07..e6453db1f6 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -4743,6 +4743,20 @@ INSERT into config.org_unit_setting_type 'description' ), 'string', null) +,( 'opac.browse.pager_shortcuts', 'opac', + oils_i18n_gettext( + 'opac.browse.pager_shortcuts', + 'Paging shortcut links for OPAC Browse', + 'coust', + 'label' + ), + oils_i18n_gettext( + '', + 'The characters in this string, in order, will be used as shortcut links for quick paging in the OPAC browse interface. Any sequence surrounded by asterisks will be taken as a whole label, not split into individual labels at the character level, but only the first character will serve as the basis of the search.', + 'coust', + 'description' + ), + 'string', null) ; diff --git a/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.bib-auth-browse.sql b/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.bib-auth-browse.sql index 466053c6ea..358fb49a51 100644 --- a/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.bib-auth-browse.sql +++ b/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.bib-auth-browse.sql @@ -7487,6 +7487,16 @@ UPDATE config.metabib_field browse_xpath IS NULL AND field_class = 'author'; +INSERT INTO config.org_unit_setting_type ( + name, label, grp, description, datatype +) VALUES ( + 'opac.browse.pager_shortcuts', + 'Paging shortcut links for OPAC Browse', + 'opac', + 'The characters in this string, in order, will be used as shortcut links for quick paging in the OPAC browse interface. Any sequence surrounded by asterisks will be taken as a whole label, not split into individual labels at the character level, but only the first character will serve as the basis of the search.', + 'string' +); + COMMIT; \qecho This is a browse-only reingest of your bib records. It may take a while. diff --git a/Open-ILS/src/templates/opac/browse.tt2 b/Open-ILS/src/templates/opac/browse.tt2 index 58bb0f55f8..8ad04e80f9 100644 --- a/Open-ILS/src/templates/opac/browse.tt2 +++ b/Open-ILS/src/templates/opac/browse.tt2 @@ -50,12 +50,11 @@ [% IF ctx.back_pivot %] ← [%l ('Back') %] [% END %] - [% IF browse.english_pager; # XXX how to apply i18n here? + [% IF ctx.pager_shortcuts; current_qtype = CGI.param('qtype') || 'title' %] - 0-9 - [% FOR letter IN ['A'..'Z'] %] - [% letter %] + [% FOR shortcut IN ctx.pager_shortcuts %] + [% shortcut.1 %] [% END %] [% END %] diff --git a/Open-ILS/src/templates/opac/parts/config.tt2 b/Open-ILS/src/templates/opac/parts/config.tt2 index 39d7d71116..c8e87ef95f 100644 --- a/Open-ILS/src/templates/opac/parts/config.tt2 +++ b/Open-ILS/src/templates/opac/parts/config.tt2 @@ -149,13 +149,4 @@ search.basic_config = { # Set to 1 or 'true' to enable ctx.google_books_preview = 0; -############################################################################## -# Browse settings -# Set to 1 or 'true' to enable. This controls whether or not the -# "0-9 A B C D ..." links appear on the browse page. We don't yet have a -# serviceable way to internationalize these links, so sites must choose to -# turn on this feature. - -browse.english_pager = 0; - %] diff --git a/docs/RELEASE_NOTES_NEXT/OPAC/BibAuthBrowse.txt b/docs/RELEASE_NOTES_NEXT/OPAC/BibAuthBrowse.txt index 279bfbd154..c429dec606 100644 --- a/docs/RELEASE_NOTES_NEXT/OPAC/BibAuthBrowse.txt +++ b/docs/RELEASE_NOTES_NEXT/OPAC/BibAuthBrowse.txt @@ -26,14 +26,19 @@ Configuration considerations for site administrators There are two off-by-default features that site administrators may wish to enable. - * Quick paging links (English): By changing the - ''browse.english_pager'' setting to 1 in the - ''opac/parts/config.tt2'' file for a site's active OPAC templates, - you can make shortcut browsing links ''0-9 A B C D ...'' appear - between the Back and Forward buttons on the browse page. I haven't - figured out how to make this feature internationalizable, so it's - off by default. You can turn it on if it works for your language, - or have a look at improving it if it doesn't. + * Quick paging links: By adding a value for the org unit setting + ''opac.browse.pager_shortcuts'' , you can make shortcut browsing + links such as ''0-9 A B C D ...'' appear between the Back and Next + buttons on the browse page. The set of shortcuts should be chosen + based on the languages in use at your site, but a reasonable value + for English might be the string "*0-9*ABCDEFGHIJKLMNOPQRSTUVWXYZ", + which will yield a link for 0-9 and one for each letter A-Z. The + use of asterisks in the string group a shortcut whose label is more + than a single letter in length. Such longer shortcuts have the multi- + character string for the shortcut label, and the link just goes to the + first heading matching the first character of the label. The letters + not enclosed in asterisks just lead to individual letter shortcuts. + * There is a global flag by the name ''opac.browse.warnable_regexp_per_class'' to control what leading -- 2.11.0