Ticket #26: ticket_26.patch

File ticket_26.patch, 3.0 kB (added by ivorw, 3 years ago)

Patch for [748] using <os:map_link>

  • trunk/t/21_rdf.t

     
    55use OpenGuides::Utils; 
    66use OpenGuides::Test; 
    77use URI::Escape; 
    8 use Test::More tests => 27; 
     8use Test::More tests => 28; 
    99 
    1010eval { require DBD::SQLite; }; 
    1111my $have_sqlite = $@ ? 0 : 1; 
     
    5959            latitude           => "51.524193", 
    6060            longitude          => "-0.114436", 
    6161            summary            => "a nice pub", 
     62            map_link           => "http://pubsite.com/calthorpe/get_there.htm", 
    6263        } 
    6364    ); 
    6465 
     
    8384        qr|<dc:title>CGI::Wiki Test Site: Calthorpe Arms</dc:title>|, 
    8485        "sets the title correctly" ); 
    8586 
     87    like( $rdfxml, 
     88        qr|<os:map_link rdf:resource="http://pubsite.com/calthorpe/get_there.htm" />|, 
     89        "Map link" ); 
     90 
    8691    like( $rdfxml, qr|<dc:contributor foaf:nick="Kake" />|, 
    8792        "last username to edit used as contributor" ); 
    8893 
  • trunk/lib/OpenGuides/RDF.pm

     
    7676    my $username           = $node_data{metadata}{username}[0]           || ''; 
    7777    my $os_x               = $node_data{metadata}{os_x}[0]               || ''; 
    7878    my $os_y               = $node_data{metadata}{os_y}[0]               || ''; 
     79    my $map_link           = $node_data{metadata}{map_link}[0]           || ''; 
    7980    my @categories         = @{ $node_data{metadata}{category} || [] }; 
    8081    my @locales            = @{ $node_data{metadata}{locale} || [] }; 
    8182    my $summary            = $node_data{metadata}{summary}[0]            || ''; 
     
    8384    # replace any errant characters in data to prevent illegal XML 
    8485    foreach ($phone, $fax, $website, $opening_hours_text, $address, $postcode,  
    8586             $city, $country, $latitude, $longitude, $version, $os_x, $os_y,  
    86              @categories, @locales, $summary) 
     87             @categories, @locales, $summary, $map_link) 
    8788    { 
    8889      if ($_) 
    8990      { 
     
    9596     
    9697    my ($is_geospatial, $objType); 
    9798 
    98     if ($os_x || $os_y || $latitude || $longitude || $address || $postcode || @locales || $opening_hours_text) { 
     99    if ($os_x || $os_y || $latitude || $longitude || $address || $postcode || 
     100        @locales || $opening_hours_text || $map_link) { 
    99101        $is_geospatial = 1; 
    100102        $objType    = 'geo:SpatialThing'; 
    101103    } else { 
     
    172174    <os:x>$os_x</os:x> 
    173175    <os:y>$os_y</os:y>}; 
    174176      } 
     177      if ($map_link) { 
     178          $rdf .= qq{\n<os:map_link rdf:resource="$map_link" />}; 
     179      } 
    175180    } 
    176      
    177181    $rdf .= "\n\n    <!-- contact information -->\n\n" if ($phone || $fax || $website || $opening_hours_text); 
    178182    $rdf .= "    <phone>$phone</phone>\n"                              if $phone; 
    179183    $rdf .= "    <fax>$fax</fax>\n"                                    if $fax;