use XML::LibXML;
use File::stat;
use Encode;
+use Lingua::EN::Titlecase;
use Apache2::Const -compile => qw(OK DECLINED HTTP_INTERNAL_SERVER_ERROR);
use Apache2::Log;
use OpenSRF::EX qw(:try);
$ctx->{encode_utf8} = sub {return encode_utf8(shift())};
- unless($tt->process($template, {ctx => $ctx, ENV => \%ENV, l => $text_handler})) {
+ unless($tt->process($template, {ctx => $ctx, ENV => \%ENV, l => $text_handler, tc => Lingua::EN::Titlecase->new()})) {
$r->log->warn('egweb: template error: ' . $tt->error);
return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR;
}
# Include subfields 'abnp' to generate a more comprehensive title display in search results
titresults = xml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b" or @code="n" or @code="p"]');
titresults_content = [];
- FOR sub IN titresults; titresults_content.push(sub.textContent); END;
+ FOR sub IN titresults;
+ IF sub.getAttribute('code') == 'a';
+ titresults_content.push(tc.title(sub.textContent));
+ ELSE;
+ titresults_content.push(sub.textContent);
+ END;
+ END;
args.title = titresults_content.join(" ");
# Avoid ugly trailing syntax on brief titles
args.title = args.title | replace('[:;/]$', '');
# Provide correct spacing between the subfields
titsubs = xml.findnodes('//*[@tag="245"]/*[@code]');
titsubs_content = [];
- FOR sub IN titsubs; titsubs_content.push(sub.textContent); END;
+ FOR sub IN titsubs;
+ IF sub.getAttribute('code') == 'a';
+ titsubs_content.push(tc.title(sub.textContent));
+ ELSE;
+ titsubs_content.push(sub.textContent);
+ END;
+ END;
args.title_extended = titsubs_content.join(" ");
args.publishers = [];