From 3725e10a63d41452ffc6951908d7c89ada82fe73 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Tue, 15 Aug 2017 10:19:22 -0400 Subject: [PATCH] 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 Signed-off-by: Kathy Lussier --- Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm index da18d7e56d..adc3438d42 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm @@ -208,8 +208,8 @@ sub load_context { $ctx->{base_path} = $r->dir_config('OILSWebBasePath'); $ctx->{web_dir} = $r->dir_config('OILSWebWebDir'); $ctx->{debug_template} = ($r->dir_config('OILSWebDebugTemplate') =~ /true/io) ? 1 : 0; - $ctx->{media_prefix} = $r->dir_config('OILSWebMediaPrefix'); $ctx->{hostname} = $r->hostname; + $ctx->{media_prefix} = $r->dir_config('OILSWebMediaPrefix') || $ctx->{hostname}; $ctx->{base_url} = $cgi->url(-base => 1); $ctx->{skin} = $cgi->cookie(OILS_HTTP_COOKIE_SKIN) || 'default'; $ctx->{theme} = $cgi->cookie(OILS_HTTP_COOKIE_THEME) || 'default'; -- 2.43.2