Changeset 629


Ignore:
Timestamp:
May 26, 2005, 12:49:05 PM (17 years ago)
Author:
Earle Martin
Message:

properly encode XML-toxic characters; fix bug in geo/non-geo logic; only show comments describing RDF sections if said sections are actually being generated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/OpenGuides/RDF.pm

    r628 r629  
    44
    55use vars qw( $VERSION );
    6 $VERSION = '0.06';
     6$VERSION = '0.07';
    77
    88use CGI::Wiki::Plugin::RSS::ModWiki;
     
    8383            return $config->script_url . uri_escape($config->script_name) . "?id=" . uri_escape($wiki->formatter->node_name_to_node_param($node_name)) . ";version=" . uri_escape($version);
    8484        } else {
    85             return $config->script_url . uri_escape($config->script_name) . "?" . uri_escape($wiki->formatter->node_name_to_node_param($node_name));
     85            return $config->script_url . uri_escape($config->script_name) . "?id=" . uri_escape($wiki->formatter->node_name_to_node_param($node_name));
    8686        }
    8787    };
     
    159159    my @locales            = @{ $node_data{metadata}{locale} || [] };
    160160
     161    # replace any errant characters in data to prevent illegal XML
     162    foreach ($phone, $fax, $website, $opening_hours_text, $postcode, $city, $country,
     163    $latitude, $longitude, $version, $os_x, $os_y, $catrefs, @locales)
     164    {
     165      $_ =~ s/&/&/g;
     166      $_ =~ s/</&lt;/g;
     167      $_ =~ s/>/&gt;/g;
     168    }
     169   
    161170    my ($is_geospatial, $objType);
    162171
    163     if ($latitude || $longitude || $postcode || $city || $country || @locales)
     172    if ($latitude || $longitude || $postcode || @locales)
    164173    {
    165174      $is_geospatial = 1;
     
    209218  <$objType rdf:ID="obj" dc:title="$node_name">
    210219};
    211     $rdf .= "    <!-- categories -->\n";
    212     $rdf .= "    <dc:subject>$_</dc:subject>\n"             foreach @{$catrefs};
    213     $rdf .= "\n    <!-- address and geospatial data -->\n";
    214     $rdf .= "    <city>$city</city>" if $city && $is_geospatial;
    215     $rdf .= "    <postalCode>$postcode</postalCode>\n"      if $postcode;
    216     $rdf .= "    <country>$country</country>\n" if $country && $is_geospatial;
    217     $rdf .= "    <foaf:based_near><wn:Neighborhood><foaf:name>$_</foaf:name></wn:Neighborhood></foaf:based_near>\n"   foreach @locales;
     220    $rdf .= "\n    <!-- categories -->\n\n" if $catrefs;
     221    $rdf .= "    <dc:subject>$_</dc:subject>\n" foreach @{$catrefs};
     222    $rdf .= "\n    <!-- address and geospatial data -->\n\n" if $is_geospatial;
     223    $rdf .= "    <city>$city</city>\n"                 if $city     && $is_geospatial;
     224    $rdf .= "    <postalCode>$postcode</postalCode>\n" if $postcode && $is_geospatial;
     225    $rdf .= "    <country>$country</country>\n"        if $country  && $is_geospatial;
     226
     227    $rdf .= qq{
     228    <foaf:based_near>
     229         <wn:Neighborhood>
     230           <foaf:name>$_</foaf:name>
     231         </wn:Neighborhood>
     232    </foaf:based_near>\n} foreach @locales;
    218233
    219234    if ($latitude && $longitude) {
    220       $rdf .= qq{    <geo:lat>$latitude</geo:lat>
    221     <geo:long>$longitude</geo:long>
    222 };
     235      $rdf .= qq{
     236    <geo:lat>$latitude</geo:lat>
     237    <geo:long>$longitude</geo:long>\n};
    223238    }
    224239
    225240    if ($os_x && $os_y) {
    226       $rdf .= qq{    <os:x>$os_x</os:x>
     241      $rdf .= qq{
     242    <os:x>$os_x</os:x>
    227243    <os:y>$os_y</os:y>};
    228244    }
    229245
    230     $rdf .= "\n    <!-- contact information -->\n";
     246    $rdf .= "\n\n    <!-- contact information -->\n\n" if ($phone || $fax || $website || $opening_hours_text);
    231247    $rdf .= "    <phone>$phone</phone>\n"                              if $phone;
    232248    $rdf .= "    <fax>$fax</fax>\n"                                    if $fax;
    233     $rdf .= "    <homePage>$website</homePage>\n"                      if $website;
     249    $rdf .= "    <foaf:homepage rdf:resource=\"$website\" />\n"        if $website;
    234250    $rdf .= "    <chefmoz:Hours>$opening_hours_text</chefmoz:Hours>\n" if $opening_hours_text;
    235251
     
    309325=head1 CREDITS
    310326
    311 Code in this module written by Kake Pugh and Earle Martin.  Dan
    312 Brickley, Matt Biddulph and other inhabitants of #swig on irc.freenode.net
    313 gave useful feedback and advice.
     327Code in this module written by Kake Pugh and Earle Martin.  Dan Brickley, Matt
     328Biddulph and other inhabitants of #swig on irc.freenode.net gave useful feedback
     329and advice.
    314330
    315331=cut
Note: See TracChangeset for help on using the changeset viewer.