Changeset 29013

Show
Ignore:
Timestamp:
01.05.2014 18:25:31 (5 years ago)
Author:
ak19
Message:

Following Dr Bainbridge's suggestion on determining a document's title which forms the anchor text for its RSS link.

Location:
main/trunk/greenstone2/perllib
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/inexport.pm

    r28705 r29013  
    633633        # If a plugout was specified in the collect.cfg file, assume it is sensible 
    634634        # We can't check the name because it could be anything, if it is a custom plugout 
    635         print STDERR "Using plugout specified in collect.cfg: $collectcfg->{'plugout'}\n"; 
     635        print STDERR "Using plugout specified in collect.cfg: ".join(' ', @{$collectcfg->{'plugout'}})."\n"; 
    636636        $plugout = $collectcfg->{'plugout'}; 
    637637    } 
  • main/trunk/greenstone2/perllib/plugouts/BasePlugout.pm

    r29000 r29013  
    9494         'reqd' => 'no', 
    9595         'hiddengli' => 'yes'}, 
     96       { 'name' => 'rss_title', 
     97         'desc' => "{BasPlugout.rss_title}", 
     98         'type' => 'string', 
     99     'deft' => 'dc.Title', 
     100         'reqd' => 'no', 
     101         'hiddengli' => 'yes'}, 
    96102    { 'name' => "no_auxiliary_databases", 
    97103      'desc' => "{BasPlugout.no_auxiliary_databases}", 
     
    908914      if (($oid_files->{'index-status'} eq "I") || ($oid_files->{'index-status'} eq "R")) { 
    909915    my $top_section = $doc_obj->get_top_section(); 
    910  
    911     my $titles = $doc_obj->get_metadata($top_section,"dc.Title"); 
    912  
    913     # if there is no dc.Title for this document, then use ex.Title as fallback 
    914     if(scalar(@$titles) == 0) { 
    915         $titles = $doc_obj->get_metadata($top_section,"Title"); 
     916     
     917    # rss_title can be set in collect.cfg as follows:  
     918    #      plugout GreenstoneXMLPlugout -rss_title "dc.Title; ex.Title" 
     919    # rss_title is a semi-colon or comma-separated list of the metadata field names that should 
     920    # be consulted in order to obtain a Title (anchor text) for the RSS document link.    
     921    # If not specified, rss_title will default to dc.Title, and fall back on Untitled 
     922    my $metafieldnames = $self->{'rss_title'}; 
     923    my @metafieldarray = split(/[,;] ?/,$metafieldnames); # , or ; separator can be followed by an optional space 
     924    my $titles; 
     925    #@$titles=(); # at worst @$titles will be (), as get_metadata(dc.Titles) may return () 
     926    foreach my $metafieldname (@metafieldarray) { 
     927        $metafieldname =~ s@^ex\.@@; # if ex.Title, need to get_metadata() on metafieldname=Title 
     928        $titles = $doc_obj->get_metadata($top_section,$metafieldname); 
     929 
     930        if(scalar(@$titles) != 0) { # found at least one title for one metafieldname 
     931           last; # break out of the loop 
     932        } 
     933    } 
     934     
     935    # if ex.Title was listed in the metafieldnames, then we'll surely have a value for title for this doc 
     936    # otherwise, if we have no titles at this point, add in a default of Untitled as this doc's title 
     937    if(scalar(@$titles) == 0) { #&& $metafieldnames !~ m@ex.Title@) { 
     938        push(@$titles, "Untitled"); 
     939    } 
     940     
     941    # encode basic html entities like <>"& in the title(s), since the & char can break RSS links 
     942    for (my $i = 0; $i < scalar(@$titles); $i++) { 
     943        &ghtml::htmlsafe(@$titles[$i]); 
    916944    } 
    917945 
  • main/trunk/greenstone2/perllib/strings.properties

    r28801 r29013  
    13531353BasPlugout.subdir_split_length:The maximum number of characters before spliting an archives subdirectory. 
    13541354BasPlugout.no_rss:Suppress the automatic generation of RSS feed file. 
     1355BasPlugout.rss_title:Comma separated list of metadata fields listed in order of preference from which the title for a document's RSS link is to be obtained 
    13551356 
    13561357DSpacePlugout.desc:DSpace Archive format.