lp1863252 toward geosort * fix swap of lat/lon that broke Math::Trig-based distance calculations TODO: might want to drop that entirely in favor of delegating to a DB call that uses earthdistance * first pass at implementing display of distance in the OPAC * include "Distance" label on mobile view of copy table * display warning if address input is not translated to coordinates * add distance column to TPAC copy table * add default item sort button to both TPAC and Bootstrap * changes to open-ils.geo registration - don't register with the public router - add to param redaction list * add temporary caching of address => coordinates results By default, coordinates are cached in memcached for 5 minutes. The cache key is derived from a SHA-2 hash of the input address. * implement query parameter log redaction as a PerLogHandler * Don't need perl-script for a PerlLogHandler Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org> Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
LP#1721575: Batch Actions In the Public Catalog The public catalog now displays checkboxes on the bibliographic and metarecord constituents results pages. Selecting one or more titles by using the checkboxes will dynamically add those title to the temporary list, which is now renamed the basket. Above the results lists there is now a bar with a select-all checkbox, a link to the basket management page that also indicates the number of of titles in the basket, and a link to remove from the basket titles that are selected on the currently displayed results page. The search bar now includes an icon of a basket and displays the number of titles currently in the basket. Next to that icon is a menu of basket actions. The basket actions available are Place Hold, Print Title Details, Email Title Details, Add Cart to Saved List, and Clear Cart. In the web staff client, the basket actions also include Add Cart to Bucket. When an action is selected from this menu, the user is given an opportunity to confirm the action and to optionally empty the basket when the action is complete. The action is applied to all titles in the basket. Clicking on the basket icon brings the user to a page listing the titles in the basket. From there, the user can select specific records to request, print, email, add to a list, or remove from the basket. The list of actions on the record details page now provides separate links for adding the title to a basket or to a permanent list. The permanent list management page in the public catalog now also includes batch print and email actions. Additional information ++++++++++++++++++++++ * The checkboxes do not display on the metarecord results page, as metarecords currently cannot be put into baskets or lists. * The checkboxes are displayed only if Javascript is enabled. However, users can still add items to the basket and perform batch actions on the basket and on lists. * A template `config.tt2` setting, `ctx.max_basket_size`, can be used to set a soft limit on the number of titles that can be added to the basket. If this limit is reached, checkboxes to add more records to the basket are disabled unless existing titles in the basket are removed first. The default value for this setting is 500. Developer notes +++++++++++++++ This patch adds the the public catalog two routes that return JSON rather than HTML: * `GET /eg/opac/api/mylist/add?record=45` * `GET /eg/opac/api/mylist/delete?record=45` The JSON response is a hash containing a mylist key pointing to the list of bib IDs of contents of the basket. The record parameter can be repeated to allow adding or removing records as an atomic operation. Note that this change also now available to `/eg/opac/mylist/{add,delete}` More generally, this adds a way for EGWeb context loaders to specify that a response should be emitted as JSON rather than rendering an HTML page using `Template::Toolkit`. Specifically, if the context as munged by the context loader contains a `json_response` key, the contents of that key will to provide a JSON reponse. The `json_response_cookie` key, if present, can be used to set a cookie as part of the response. Template Toolkit processing is bypassed entirely when emitting a JSON response, so the context loader would be entirely reponsible for localization of strings in the response meant for direct human consumption. Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org> Signed-off-by: Kathy Lussier <klussier@masslnc.org> Signed-off-by: Bill Erickson <berickxx@gmail.com>
LP#1717777: Ensure the en-US is always represented in the dropdown The assumption of an array in the eval'd code was causing the forced en_us tag to fail. Here we push the default en_us into the list of locales in a more structured way to ensure that failure doesn't happen. Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Ben Shum <ben@evergreener.net>
LP#1717777: absorb all PO files for a locale We assumed only one file per locale, but apache <Location>s because are not independent WRT locale helpers in mod_perl, we need to load all files from all <Location> directives for a given locale. NOTE: there is a risk of translation collision, where the same key string in two PO files have different translations, but in our context that is almost surely a mistake. Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Ben Shum <ben@evergreener.net>
LP#1710747: Absolute URL for media_prefix in templates If OILSWebMediaPrefix is set in the Apache configuration, then the ctx.media_prefix TT2 template variable uses that value as the hostname; otherwise it is null, resulting in many relative URLs for images, CSS, and JavaScript files. Normally this is not a problem, but the Open Graph image property requires a full absolute URL rather than the relative URL that would previously result on the record summary page in the absence of the OILSWebMediaPrefix variable having been set in the Apache config. This patch tweaks the EGWeb handler to fall back to the base hostname in the absence of the OILSWebMediaPrefix variable, thus ensuring that all uses of ctx.media_prefix result in an absolute URL. Test Plan: Pre-patch - Visit a record summary page in the catalog. View the source of the page. In the head section, find the og:image meta property. The content will display a relative URL to the record's book jacket cover image. Post-patch - When viewing the source of the page, og:image will display the full URL. Signed-off-by: Dan Scott <dscott@laurentian.ca> Signed-off-by: Kathy Lussier <klussier@masslnc.org>
LP#1449709: Always get a real hostname for the cache key EGCatLoader overwrites $ctx->{hostname} when serving the staff client version of TT-generated content. This is bad for us because we use that as part of the TT Processor cache key. Instead, we'll just always ask Apache, via $r. Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Bill Erickson <berickxx@gmail.com>
LP#1452366: allow EGWeb context loaders to have child_init actions This patch adds the ability for EGWeb to call an initialization function for context loaders during the child_init phase of Apache backend startup. In particular, portions of the R/O object cache for EGCatLoader are now initialized when a backend starts up; testing indicates that this can shave a couple seconds off the time it takes for a backend to render a bib details page the first time. Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Bill Erickson <berickxx@gmail.com>
LP#1449709: caching compiled Template Toolkit templates This patch enables caching of compiled Template Toolkit files on Evergreen web servers, which can provide a modest improvement in the time it takes (say) TPAC to render a page, particularly by a fresh Apache backend. This is controlled by a new Apache virtualhost variable, OILSWebCompiledTemplateCache, which can be set to a directory on the webserver for storing compiled templates. This is enabled by default for new installations. This patch also adds OILSWebTemplateStatTTL, which can be use to tweak the STAT_TTL Template Toolkit setting. Note this bit works because of the caching of TT handlers added by the previous patch. Finally, this patch also fixes a bug where attempting to disable OILSWebDebugTemplate would result in internal server errors; it also sets the default value of this setting to false. Note: the caching added by this patch and the previous one mean that if a change to (say) TPAC templates is made on the file system, it is now required to reload Apache to have a guarantee that the change is visible, although one can also wait the OILSWebTemplateStatTTL interval. Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Bill Erickson <berickxx@gmail.com>
LP#1449709: Persist template processor for speed By persisting the Template Toolkit processor object per vhost/locale/context-loader/xml-strictness instead of creating a new one for every request, we allow TT to maintain an in-memory cache of all the templates it has compiled. This increases speed by as much as 80%. In addition, we reduce the number of times the TPAC checks for the existance of a template by remembering the state of the first readability probe. This is most important on systems where the templates are stored on NFS, where stat(2) system calls can be particularly expensive. We now pass the Apache object ($r) to the template processor instead of relying on tied-STDOUT behaviour, because each request gets a new tied file handle. After the first one, it's the wrong one. Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Bill Erickson <berickxx@gmail.com>
LP#1406025: Provide graceful human output for HTTP errors For the expected HTTP errors of HTTP_GONE (record deleted) and HTTP_NOT_FOUND (record never existed), return the HTML pages that we used to return (red border warning that the record was deleted, or just an empty template for non-existing records) so that the user can at least try another search. However, the HTTP status code gets set to 410 or 404 as expected so that machines can react accordingly. Signed-off-by: Dan Scott <dscott@laurentian.ca> Signed-off-by: Ben Shum <bshum@biblio.org>
LP#1350042 browser client apache config additions * Location configuratoin for /eg/staff templates * Support for "stop-at-index" in EGWeb, so that navigating to "/eg/foo" can result in /eg/index.tt2 getting served. * Cache and compress additions for /js files. Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Ben Shum <bshum@biblio.org>
LP#1306675 TPAC maketext default handler Fall back to an unitialized maketext handler, which defaults to the template language, when OpenILS::WWW::EGWeb::I18N->get_handle fails to return a response. Note that why get_handle() returns undef is not yet known. Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Ben Shum <bshum@biblio.org>
LP#1053397 TPAC metarecord search and holds UI API, TPAC backend, and UI bits for TPAC metarecord searching and holds. * Group Formats and Editions options in advanced search / searchbar * MR holds placement form, allowing selected formats and languages * MR holds targeting updated to work w/ new holdable formats composite definitions Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Dan Wells <dbw2@calvin.edu>
Default per-request TPAC locale Set the OpenSRF default client locale for each TPAC request to ensure all outbound OpenSRF calls use the requested locale. When done, reset the locale to the OpenSRF default. Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Dan Wells <dbw2@calvin.edu>
Post-2.5-m1 whitespace fixup This is an attempt at an automated whitespace cleanup for the m1 milestone of version 2.5. It was created using the following commands (run from Open-ILS/src/perlmods/lib): find . -name "*.pm" \ -exec sh -c 'sed "/<</s/\t/ /g" < {} \ | expand -t 4 > {}.fixed ; \ cp --no-preserve=mode,ownership {}.fixed {}; \ rm {}.fixed' \; Signed-off-by: Dan Wells <dbw2@calvin.edu> Signed-off-by: Remington Steed <rjs7@calvin.edu>
LP#1098669: improve handling of Content Cafe external content in staff client This patch introduces a new TPac content variable, ctx.ext_proto, to specify whether external content should be retrieved via HTTP or HTTPS. ctx.proto can't be used for that purpose since it's set to 'oils' when TPac is running inside the staff client. This fixes a bug where Content Cafe reviews wouldn't display in the staff client bib record page and where clicking on the reviews link from search results would open an empty window. Signed-off-by: Galen Charlton <gmc@esilibrary.com> Signed-off-by: Bill Erickson <berick@esilibrary.com>
TPAC: Add the ability to set a different default locale Installations with multiple sites might desire different default locales for their skins. This adds the Apache config directive "OILSWebDefaultLocale", which enables you to set the default locale on a global and a per-skin basis. Note that this prevents the browser Accept-language header from having any effect; sadly that header is not often used in real life. Signed-off-by: Dan Scott <dscott@laurentian.ca> Signed-off-by: Art Rhyno <art632000@yahoo.ca> Conflicts: Open-ILS/examples/apache/eg_vhost.conf Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Dan Scott <dscott@laurentian.ca>
TPAC i18n: Turn UA locales into Evergreen locales We need to convert the likes of fr_ca into fr-CA to be able to pull the appropriate localized values from the database via CStoreEditor. Signed-off-by: Dan Scott <dscott@laurentian.ca> Signed-off-by: Bill Erickson <berick@esilibrary.com>
Set the default CStoreEditor locale on page load Ech CStoreEditor request will use the locale of the current page as the default opensrf session locale. Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Dan Scott <dscott@laurentian.ca>
TPAC: Silence two uninit variable warnings These warnings were being thrown on every TPAC page request, slowly filling the logs: Use of uninitialized value $set_locale in string eq at /usr/local/share/perl/5.10.1/OpenILS/WWW/EGWeb.pm line 159. Use of uninitialized value in pattern match (m//) at /usr/local/share/perl/5.10.1/OpenILS/WWW/EGCatLoader.pm line 250. Banish them. Signed-off-by: Dan Scott <dscott@laurentian.ca> Signed-off-by: Bill Erickson <berick@esilibrary.com>