Changeset 1168

Show
Ignore:
Timestamp:
06/16/08 02:31:05 (4 months ago)
Author:
earle
Message:

Large RDF overhaul: see Changes for 0.63. Fixes #251.

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/Changes

    r1166 r1168  
    55 
    660.63 
    7         Link dc:contributor items in RDF output to actual URIs that exist in 
     7        Major overhaul of RDF output. 
     8        * Remodelled addresses using WAIL. 
     9          (http://www.eyrie.org/~zednenem/2002/wail/) 
     10        * Include node image as foaf:depiction. 
     11        * Link dc:contributor items in RDF output to actual URIs that exist in 
    812          our system. 
     13        * Replace map XMLNS with dedicated vocabulary. 
     14          (http://downlode.org/Code/RDF/Map/) 
     15        * Replace usage of weakly-modeled and unavailable Wordnet vocabulary  
     16          for "neighborhood" value with WAIL term. 
     17        * Replace usage of unmodeled and unmaintained ChefMoz vocabulary for  
     18          opening hours value and replace with Dublin Core "available" term. 
     19        * Replace unnecessary instances of rdf:ID with rdf:nodeID. 
     20        * Model relationship of neighborhood to parent city. 
     21        * Reduce acres of whitespace in output and clean up indenting. 
    922 
    10230.62    8 June 2008 
  • trunk/lib/OpenGuides/RDF.pm

    r1166 r1168  
    8484    foreach my $var ( qw( phone fax website opening_hours_text address 
    8585                          postcode city country latitude longitude 
    86                           os_x os_y map_link summary ) ) { 
     86                          os_x os_y map_link summary node_image ) ) { 
    8787        my $val = $metadata{$var}[0] || $defaults{$var} || ""; 
    8888        $tt_vars{$var} = $val; 
    8989    } 
    9090 
    91      
    9291    my @cats = @{ $metadata{category} || [] }; 
    9392    @cats = map { { name => $_ } } @cats; 
  • trunk/t/21_rdf.t

    r1166 r1168  
    1616} 
    1717 
    18 plan tests => 28; 
     18plan tests => 29; 
    1919 
    2020Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } ); 
     
    7676        longitude          => "-0.114436", 
    7777        summary            => "a nice pub", 
     78        node_image         => "http://example.com/calthorpe.jpg", 
    7879); 
    7980 
     
    8283like( $rdfxml, qr|<\?xml version="1.0"\?>|, "RDF is encoding-neutral" ); 
    8384 
    84 like( $rdfxml, qr|<dc:title>Bloomsbury</dc:title>|, 
     85like( $rdfxml, qr|<foaf:depiction rdf:resource="http://example.com/calthorpe.jpg" />|, "Node image"); 
     86 
     87like( $rdfxml, qr|<wail:Neighborhood rdf:nodeID="Bloomsbury">|, 
    8588    "finds the first locale" ); 
    86 like( $rdfxml, qr|<dc:title>St Pancras</dc:title>|, 
     89like( $rdfxml, qr|<wail:Neighborhood rdf:nodeID="St_Pancras">|, 
    8790    "finds the second locale" ); 
    8891 
    89 like( $rdfxml, qr|<phone>test phone number</phone>|, 
     92like( $rdfxml, qr|<contact:phone>test phone number</contact:phone>|, 
    9093    "picks up phone number" ); 
    9194 
    92 like( $rdfxml, qr|<chefmoz:Hours>test hours</chefmoz:Hours>|, 
     95like( $rdfxml, qr|<dc:available>test hours</dc:available>|, 
    9396    "picks up opening hours text" ); 
    9497 
     
    111114    "set the dc:source with the version-independent uri" ); 
    112115 
    113 like( $rdfxml, qr|<country>United Kingdom</country>|, "country" ). 
    114 like( $rdfxml, qr|<city>London</city>|, "city" ). 
    115 like( $rdfxml, qr|<postalCode>WC1X 8JR</postalCode>|, "postcode" ); 
     116like( $rdfxml, qr|<wail:City rdf:nodeID="city">\n\s+<wail:name>London</wail:name>|, "city" ). 
     117like( $rdfxml, qr|<wail:locatedIn>\n\s+<wail:Country rdf:nodeID="country">\n\s+<wail:name>United Kingdom</wail:name>|, "country" ). 
     118like( $rdfxml, qr|<wail:postalCode>WC1X 8JR</wail:postalCode>|, "postcode" ); 
    116119like( $rdfxml, qr|<geo:lat>51.524193</geo:lat>|, "latitude" ); 
    117120like( $rdfxml, qr|<geo:long>-0.114436</geo:long>|, "longitude" ); 
     
    170173$rdfxml = $rdf_writer->emit_rdfxml( node => "Nonesuch Stores" ); 
    171174 
    172 like( $rdfxml, qr|<geo:SpatialThing rdf:ID="obj" dc:title="Nonesuch Stores">|, 
     175like( $rdfxml, qr|<geo:SpatialThing rdf:ID="obj">|, 
    173176    "having opening hours marks node as geospatial" ); 
    174177 
  • trunk/templates/node_rdf.tt

    r1167 r1168  
    11<?xml version="1.0"?> 
    22<rdf:RDF 
    3   xmlns:chefmoz = "http://chefmoz.org/rdf/elements/1.0/" 
    43  xmlns:dc      = "http://purl.org/dc/elements/1.1/" 
    54  xmlns:dcterms = "http://purl.org/dc/terms/" 
    65  xmlns:foaf    = "http://xmlns.com/foaf/0.1/" 
    76  xmlns:geo     = "http://www.w3.org/2003/01/geo/wgs84_pos#" 
    8   xmlns:map     = "http://www.daml.org/2001/06/map/map-ont#" 
     7  xmlns:map     = "http://downlode.org/Code/RDF/Map/" 
    98  xmlns:os      = "http://downlode.org/Code/RDF/Ordnance_Survey/schema/1#" 
    109  xmlns:owl     = "http://www.w3.org/2002/07/owl#" 
    1110  xmlns:rdf     = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
     11  xmlns:rdfs    = "http://www.w3.org/2000/01/rdf-schema#" 
     12  xmlns:wail    = "http://www.eyrie.org/~zednenem/2002/wail/" 
    1213  xmlns:wiki    = "http://purl.org/rss/1.0/modules/wiki/" 
    13   xmlns:wn      = "http://xmlns.com/wordnet/1.6/" 
    14   xmlns         = "http://www.w3.org/2000/10/swap/pim/contact#" 
     14  xmlns:contact = "http://www.w3.org/2000/10/swap/pim/contact#" 
    1515> 
    1616 
    17   <rdf:Description rdf:about=""> 
    18     <dc:title>[% site_name %]: [% node_name %]</dc:title> 
    19     <dc:date>[% timestamp %]</dc:date> 
    20     <dcterms:modified>[% timestamp %]</dcterms:modified> 
     17<rdf:Description rdf:about=""> 
     18  <dc:title>[% site_name %]: [% node_name %]</dc:title> 
     19  <dc:date>[% timestamp %]</dc:date> 
     20  <dcterms:modified>[% timestamp %]</dcterms:modified> 
    2121 
    22     [% FOREACH contributor = contributors.values %]  
    23     <dc:contributor rdf:resource="[% full_cgi_url %]?id=[% contributor.user_id %];format=rdf#obj" foaf:name="[% contributor.user_id %]" /> 
    24     [% END %] 
     22  [%- FOREACH contributor = contributors.values %]  
     23  <dc:contributor rdf:resource="[% full_cgi_url %]?id=[% contributor.user_id %];format=rdf#obj" /> 
     24  [%- END %] 
    2525 
    26     <dc:source rdf:resource="[% node_uri %]" /> 
    27     <wiki:version>[% version %]</wiki:version> 
    28     <foaf:topic rdf:resource="#obj" /> 
    29   </rdf:Description> 
     26  <dc:source rdf:resource="[% node_uri %]" /> 
     27  <wiki:version>[% version %]</wiki:version> 
     28  <foaf:topic rdf:resource="#obj" /> 
    3029 
    31   <[% obj_type %] rdf:ID="obj" dc:title="[% node_name %]"> 
     30  [%- IF redirect %] 
     31    <owl:sameAs rdf:resource="[% redirect %]" /> 
     32  [%- END %] 
    3233 
    33     [% IF summary %] 
    34       <dc:description>[% summary %]</dc:description> 
    35     [% END %] 
     34</rdf:Description> 
    3635 
    37     [% IF categories %] 
    38       <!-- categories --> 
     36<[% obj_type %] rdf:ID="obj"> 
    3937 
    40       [% FOREACH category = categories %] 
    41         <dc:subject>[% category.name %]</dc:subject> 
    42       [% END %] 
    43     [% END %] 
     38  <dc:title>[% node_name %]</dc:title> 
     39   
     40  [%- IF summary %] 
     41  <dc:description>[% summary %]</dc:description> 
     42  [%- END %] 
    4443 
    45     [% IF is_geospatial %] 
    46       <!-- address and geospatial data --> 
     44  [%- IF node_image %] 
     45  <foaf:depiction rdf:resource="[% node_image %]" /> 
     46  [%- END %] 
    4747 
    48       [% IF address %] 
    49         <address>[% address %]</address> 
    50       [% END %] 
    51       [% IF city %] 
    52         <city>[% city %]</city> 
    53       [% END %] 
    54       [% IF postcode %] 
    55         <postalCode>[% postcode %]</postalCode> 
    56       [% END %] 
    57       [% IF country %] 
    58         <country>[% country %]</country> 
    59       [% END %] 
     48  [%- IF categories %] 
     49  <!-- categories --> 
    6050 
    61       [% IF map_link %] 
    62         <foaf:page> 
    63           <map:Map rdf:about="[% map_link %]" /> 
    64         </foaf:page> 
    65       [% END %] 
     51  [%- FOREACH category = categories %] 
     52  <dc:subject>[% category.name %]</dc:subject> 
     53  [%- END %] 
     54  [%- END %] 
    6655 
    67       [% FOREACH locale = locales %] 
    68         <foaf:based_near> 
    69           <wn:Neighborhood rdf:ID="[% locale.id %]"> 
    70             <dc:title>[% locale.name %]</dc:title> 
    71           </wn:Neighborhood> 
    72         </foaf:based_near> 
    73       [% END %] 
     56  [%- IF is_geospatial %] 
     57  <!-- address and geospatial data --> 
    7458 
    75       [% IF wgs84_lat AND wgs84_long %] 
    76         <geo:lat>[% wgs84_lat %]</geo:lat> 
    77         <geo:long>[% wgs84_long %]</geo:long> 
    78       [% END %] 
     59  <wail:location> 
     60    <wail:Address rdf:nodeID="address"> 
     61  [%- IF address %] 
     62      <wail:streetName>[% address %]</wail:streetName> 
     63  [%- END %] 
     64  [%- IF postcode %] 
     65      <wail:postalCode>[% postcode %]</wail:postalCode> 
     66  [%- END %] 
     67  [%- IF city %] 
     68      <wail:locatedIn> 
     69        <wail:City rdf:nodeID="city"> 
     70          <wail:name>[% city %]</wail:name> 
     71          [%- IF country %] 
     72            <wail:locatedIn> 
     73              <wail:Country rdf:nodeID="country"> 
     74                <wail:name>[% country %]</wail:name> 
     75              </wail:Country> 
     76            </wail:locatedIn> 
     77          [%- END %] 
     78        </wail:City> 
     79      </wail:locatedIn> 
     80  [%- END %] 
     81    </wail:Address> 
     82  </wail:location> 
    7983 
    80       [% IF os_x AND os_y %] 
    81         <os:x>[% os_x %]</os:x> 
    82         <os:y>[% os_y %]</os:y> 
    83       [% END %] 
     84  [%- IF map_link %] 
     85  <map:shownBy> 
     86    <map:Map rdf:about="[% map_link %]" /> 
     87  </map:shownBy> 
     88  [%- END %] 
    8489 
    85     [% END %] 
     90  [%- FOREACH locale = locales %] 
     91  <foaf:based_near> 
     92    <wail:Neighborhood rdf:nodeID="[% locale.id %]"> 
     93      <wail:name>[% locale.name %]</wail:name> 
     94      [%- IF city %] 
     95        <wail:locatedIn rdf:nodeID="city" /> 
     96      [%- END %] 
     97    </wail:Neighborhood> 
     98  </foaf:based_near> 
     99  [%- END %] 
    86100 
    87     [% IF phone OR fax OR website OR opening_hours_text %] 
    88       <!-- contact information --> 
    89       [% IF phone %] 
    90         <phone>[% phone %]</phone> 
    91       [% END %] 
    92       [% IF fax %] 
    93         <fax>[% fax %]</fax> 
    94       [% END %] 
    95       [% IF website %] 
    96         <foaf:homepage rdf:resource="[% website %]" /> 
    97       [% END %] 
    98       [% IF opening_hours_text %] 
    99         <chefmoz:Hours>[% opening_hours_text %]</chefmoz:Hours> 
    100       [% END %] 
    101     [% END %] 
     101  [%- IF wgs84_lat AND wgs84_long %] 
     102  <geo:lat>[% wgs84_lat %]</geo:lat> 
     103  <geo:long>[% wgs84_long %]</geo:long> 
     104  [%- END %] 
    102105 
    103     [% IF redirect %] 
    104       <owl:sameAs rdf:resource="[% redirect %]" /> 
    105     [% END %] 
     106  [%- IF os_x AND os_y %] 
     107  <os:x>[% os_x %]</os:x> 
     108  <os:y>[% os_y %]</os:y> 
     109  [%- END %] 
    106110 
    107   </[% obj_type %]> 
     111  [%- END %] 
     112 
     113  [%- IF phone OR fax OR website OR opening_hours_text %] 
     114  <!-- contact information --> 
     115  [%- IF phone %] 
     116  <contact:phone>[% phone %]</contact:phone> 
     117  [%- END %] 
     118  [%- IF fax %] 
     119  <contact:fax>[% fax %]</contact:fax> 
     120  [%- END %] 
     121  [%- IF website %] 
     122  <foaf:homepage rdf:resource="[% website %]" /> 
     123  [%- END %] 
     124  [%- IF opening_hours_text %] 
     125  <dc:available>[% opening_hours_text %]</dc:available> 
     126  [%- END %] 
     127  [%- END %] 
     128 
     129</[% obj_type %]> 
     130 
    108131</rdf:RDF>