Author: earle Date: 2008-06-16 02:31:05 +0100 (Mon, 16 Jun 2008) New Revision: 1168
Modified: trunk/Changes trunk/lib/OpenGuides/RDF.pm trunk/t/21_rdf.t trunk/templates/node_rdf.tt Log: Large RDF overhaul: see Changes for 0.63. Fixes #251.
Modified: trunk/Changes =================================================================== --- trunk/Changes 2008-06-15 20:02:45 UTC (rev 1167) +++ trunk/Changes 2008-06-16 01:31:05 UTC (rev 1168) @@ -4,8 +4,21 @@ http://dev.openguides.org/log/trunk.
0.63 - Link dc:contributor items in RDF output to actual URIs that exist in + Major overhaul of RDF output. + * Remodelled addresses using WAIL. + (http://www.eyrie.org/~zednenem/2002/wail/) + * Include node image as foaf:depiction. + * Link dc:contributor items in RDF output to actual URIs that exist in our system. + * Replace map XMLNS with dedicated vocabulary. + (http://downlode.org/Code/RDF/Map/) + * Replace usage of weakly-modeled and unavailable Wordnet vocabulary + for "neighborhood" value with WAIL term. + * Replace usage of unmodeled and unmaintained ChefMoz vocabulary for + opening hours value and replace with Dublin Core "available" term. + * Replace unnecessary instances of rdf:ID with rdf:nodeID. + * Model relationship of neighborhood to parent city. + * Reduce acres of whitespace in output and clean up indenting.
0.62 8 June 2008 Allow wiki page links (simple: [[Foo]], title: [[Foo|bar]]) in
Modified: trunk/lib/OpenGuides/RDF.pm =================================================================== --- trunk/lib/OpenGuides/RDF.pm 2008-06-15 20:02:45 UTC (rev 1167) +++ trunk/lib/OpenGuides/RDF.pm 2008-06-16 01:31:05 UTC (rev 1168) @@ -83,12 +83,11 @@
foreach my $var ( qw( phone fax website opening_hours_text address postcode city country latitude longitude - os_x os_y map_link summary ) ) { + os_x os_y map_link summary node_image ) ) { my $val = $metadata{$var}[0] || $defaults{$var} || ""; $tt_vars{$var} = $val; }
- my @cats = @{ $metadata{category} || [] }; @cats = map { { name => $_ } } @cats; $tt_vars{categories} = @cats;
Modified: trunk/t/21_rdf.t =================================================================== --- trunk/t/21_rdf.t 2008-06-15 20:02:45 UTC (rev 1167) +++ trunk/t/21_rdf.t 2008-06-16 01:31:05 UTC (rev 1168) @@ -15,7 +15,7 @@ plan skip_all => "DBD::SQLite could not be used - no database to test with. ($error)"; }
-plan tests => 28; +plan tests => 29;
Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } ); my $config = OpenGuides::Test->make_basic_config; @@ -75,21 +75,24 @@ latitude => "51.524193", longitude => "-0.114436", summary => "a nice pub", + node_image => "http://example.com/calthorpe.jpg", );
my $rdfxml = $rdf_writer->emit_rdfxml( node => "Calthorpe Arms" );
like( $rdfxml, qr|<?xml version="1.0"?>|, "RDF is encoding-neutral" );
-like( $rdfxml, qr|dc:titleBloomsbury</dc:title>|, +like( $rdfxml, qr|<foaf:depiction rdf:resource="http://example.com/calthorpe.jpg" />|, "Node image"); + +like( $rdfxml, qr|<wail:Neighborhood rdf:nodeID="Bloomsbury">|, "finds the first locale" ); -like( $rdfxml, qr|dc:titleSt Pancras</dc:title>|, +like( $rdfxml, qr|<wail:Neighborhood rdf:nodeID="St_Pancras">|, "finds the second locale" );
-like( $rdfxml, qr|<phone>test phone number</phone>|, +like( $rdfxml, qr|contact:phonetest phone number</contact:phone>|, "picks up phone number" );
-like( $rdfxml, qr|chefmoz:Hourstest hours</chefmoz:Hours>|, +like( $rdfxml, qr|dc:availabletest hours</dc:available>|, "picks up opening hours text" );
like( $rdfxml, qr|<foaf:homepage rdf:resource="test website" />|, "picks up website" ); @@ -110,9 +113,9 @@ like( $rdfxml, qr|<dc:source rdf:resource="http://wiki.example.com/mywiki.cgi%5C?Calthorpe_Arms" />|, "set the dc:source with the version-independent uri" );
-like( $rdfxml, qr|<country>United Kingdom</country>|, "country" ). -like( $rdfxml, qr|<city>London</city>|, "city" ). -like( $rdfxml, qr|<postalCode>WC1X 8JR</postalCode>|, "postcode" ); +like( $rdfxml, qr|<wail:City rdf:nodeID="city">\n\s+wail:nameLondon</wail:name>|, "city" ). +like( $rdfxml, qr|wail:locatedIn\n\s+<wail:Country rdf:nodeID="country">\n\s+wail:nameUnited Kingdom</wail:name>|, "country" ). +like( $rdfxml, qr|wail:postalCodeWC1X 8JR</wail:postalCode>|, "postcode" ); like( $rdfxml, qr|geo:lat51.524193</geo:lat>|, "latitude" ); like( $rdfxml, qr|geo:long-0.114436</geo:long>|, "longitude" ); like( $rdfxml, qr|dc:descriptiona nice pub</dc:description>|, "summary (description)" ); @@ -169,6 +172,6 @@
$rdfxml = $rdf_writer->emit_rdfxml( node => "Nonesuch Stores" );
-like( $rdfxml, qr|<geo:SpatialThing rdf:ID="obj" dc:title="Nonesuch Stores">|, +like( $rdfxml, qr|<geo:SpatialThing rdf:ID="obj">|, "having opening hours marks node as geospatial" );
Modified: trunk/templates/node_rdf.tt =================================================================== --- trunk/templates/node_rdf.tt 2008-06-15 20:02:45 UTC (rev 1167) +++ trunk/templates/node_rdf.tt 2008-06-16 01:31:05 UTC (rev 1168) @@ -1,108 +1,131 @@ <?xml version="1.0"?> <rdf:RDF - xmlns:chefmoz = "http://chefmoz.org/rdf/elements/1.0/" xmlns:dc = "http://purl.org/dc/elements/1.1/" xmlns:dcterms = "http://purl.org/dc/terms/" xmlns:foaf = "http://xmlns.com/foaf/0.1/" xmlns:geo = "http://www.w3.org/2003/01/geo/wgs84_pos#" - xmlns:map = "http://www.daml.org/2001/06/map/map-ont#" + xmlns:map = "http://downlode.org/Code/RDF/Map/" xmlns:os = "http://downlode.org/Code/RDF/Ordnance_Survey/schema/1#" xmlns:owl = "http://www.w3.org/2002/07/owl#" xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:rdfs = "http://www.w3.org/2000/01/rdf-schema#" + xmlns:wail = "http://www.eyrie.org/~zednenem/2002/wail/" xmlns:wiki = "http://purl.org/rss/1.0/modules/wiki/" - xmlns:wn = "http://xmlns.com/wordnet/1.6/" - xmlns = "http://www.w3.org/2000/10/swap/pim/contact#" + xmlns:contact = "http://www.w3.org/2000/10/swap/pim/contact#"
- <rdf:Description rdf:about=""> - dc:title[% site_name %]: [% node_name %]</dc:title> - dc:date[% timestamp %]</dc:date> - dcterms:modified[% timestamp %]</dcterms:modified> +<rdf:Description rdf:about=""> + dc:title[% site_name %]: [% node_name %]</dc:title> + dc:date[% timestamp %]</dc:date> + dcterms:modified[% timestamp %]</dcterms:modified>
- [% FOREACH contributor = contributors.values %] - <dc:contributor rdf:resource="[% full_cgi_url %]?id=[% contributor.user_id %];format=rdf#obj" foaf:name="[% contributor.user_id %]" /> - [% END %] + [%- FOREACH contributor = contributors.values %] + <dc:contributor rdf:resource="[% full_cgi_url %]?id=[% contributor.user_id %];format=rdf#obj" /> + [%- END %]
- <dc:source rdf:resource="[% node_uri %]" /> - wiki:version[% version %]</wiki:version> - <foaf:topic rdf:resource="#obj" /> - </rdf:Description> + <dc:source rdf:resource="[% node_uri %]" /> + wiki:version[% version %]</wiki:version> + <foaf:topic rdf:resource="#obj" />
- <[% obj_type %] rdf:ID="obj" dc:title="[% node_name %]"> + [%- IF redirect %] + <owl:sameAs rdf:resource="[% redirect %]" /> + [%- END %]
- [% IF summary %] - dc:description[% summary %]</dc:description> - [% END %] +</rdf:Description>
- [% IF categories %] - <!-- categories --> +<[% obj_type %] rdf:ID="obj">
- [% FOREACH category = categories %] - dc:subject[% category.name %]</dc:subject> - [% END %] - [% END %] + dc:title[% node_name %]</dc:title> + + [%- IF summary %] + dc:description[% summary %]</dc:description> + [%- END %]
- [% IF is_geospatial %] - <!-- address and geospatial data --> + [%- IF node_image %] + <foaf:depiction rdf:resource="[% node_image %]" /> + [%- END %]
- [% IF address %] - <address>[% address %]</address> - [% END %] - [% IF city %] - <city>[% city %]</city> - [% END %] - [% IF postcode %] - <postalCode>[% postcode %]</postalCode> - [% END %] - [% IF country %] - <country>[% country %]</country> - [% END %] + [%- IF categories %] + <!-- categories -->
- [% IF map_link %] - foaf:page - <map:Map rdf:about="[% map_link %]" /> - </foaf:page> - [% END %] + [%- FOREACH category = categories %] + dc:subject[% category.name %]</dc:subject> + [%- END %] + [%- END %]
- [% FOREACH locale = locales %] - foaf:based_near - <wn:Neighborhood rdf:ID="[% locale.id %]"> - dc:title[% locale.name %]</dc:title> - </wn:Neighborhood> - </foaf:based_near> - [% END %] + [%- IF is_geospatial %] + <!-- address and geospatial data -->
- [% IF wgs84_lat AND wgs84_long %] - geo:lat[% wgs84_lat %]</geo:lat> - geo:long[% wgs84_long %]</geo:long> - [% END %] + wail:location + <wail:Address rdf:nodeID="address"> + [%- IF address %] + wail:streetName[% address %]</wail:streetName> + [%- END %] + [%- IF postcode %] + wail:postalCode[% postcode %]</wail:postalCode> + [%- END %] + [%- IF city %] + wail:locatedIn + <wail:City rdf:nodeID="city"> + wail:name[% city %]</wail:name> + [%- IF country %] + wail:locatedIn + <wail:Country rdf:nodeID="country"> + wail:name[% country %]</wail:name> + </wail:Country> + </wail:locatedIn> + [%- END %] + </wail:City> + </wail:locatedIn> + [%- END %] + </wail:Address> + </wail:location>
- [% IF os_x AND os_y %] - os:x[% os_x %]</os:x> - os:y[% os_y %]</os:y> - [% END %] + [%- IF map_link %] + map:shownBy + <map:Map rdf:about="[% map_link %]" /> + </map:shownBy> + [%- END %]
- [% END %] + [%- FOREACH locale = locales %] + foaf:based_near + <wail:Neighborhood rdf:nodeID="[% locale.id %]"> + wail:name[% locale.name %]</wail:name> + [%- IF city %] + <wail:locatedIn rdf:nodeID="city" /> + [%- END %] + </wail:Neighborhood> + </foaf:based_near> + [%- END %]
- [% IF phone OR fax OR website OR opening_hours_text %] - <!-- contact information --> - [% IF phone %] - <phone>[% phone %]</phone> - [% END %] - [% IF fax %] - <fax>[% fax %]</fax> - [% END %] - [% IF website %] - <foaf:homepage rdf:resource="[% website %]" /> - [% END %] - [% IF opening_hours_text %] - chefmoz:Hours[% opening_hours_text %]</chefmoz:Hours> - [% END %] - [% END %] + [%- IF wgs84_lat AND wgs84_long %] + geo:lat[% wgs84_lat %]</geo:lat> + geo:long[% wgs84_long %]</geo:long> + [%- END %]
- [% IF redirect %] - <owl:sameAs rdf:resource="[% redirect %]" /> - [% END %] + [%- IF os_x AND os_y %] + os:x[% os_x %]</os:x> + os:y[% os_y %]</os:y> + [%- END %]
- </[% obj_type %]> + [%- END %] + + [%- IF phone OR fax OR website OR opening_hours_text %] + <!-- contact information --> + [%- IF phone %] + contact:phone[% phone %]</contact:phone> + [%- END %] + [%- IF fax %] + contact:fax[% fax %]</contact:fax> + [%- END %] + [%- IF website %] + <foaf:homepage rdf:resource="[% website %]" /> + [%- END %] + [%- IF opening_hours_text %] + dc:available[% opening_hours_text %]</dc:available> + [%- END %] + [%- END %] + +</[% obj_type %]> + </rdf:RDF>
openguides-commits@lists.openguides.org