LP#1710747: Absolute URL for media_prefix in templates user/dbs/lp1710747-absolute-url-media-prefix
authorDan Scott <dscott@laurentian.ca>
Tue, 15 Aug 2017 14:19:22 +0000 (10:19 -0400)
committerDan Scott <dscott@laurentian.ca>
Tue, 15 Aug 2017 14:19:22 +0000 (10:19 -0400)
commitbc38ad307a5fd2c72595e97fc9e8bd2cdcf43215
treed19ebb39a4233a03f9fc7f1ae7f762c07b7ed028
parent0a4960fd54bfdacde0e933119b6464b4ee44f512
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>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm