Changeset 1168
- Timestamp:
- 06/16/08 02:31:05 (4 months ago)
- Location:
- trunk
- Files:
-
- 4 modified
-
Changes (modified) (1 diff)
-
lib/OpenGuides/RDF.pm (modified) (1 diff)
-
t/21_rdf.t (modified) (5 diffs)
-
templates/node_rdf.tt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Changes
r1166 r1168 5 5 6 6 0.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 8 12 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. 9 22 10 23 0.62 8 June 2008 -
trunk/lib/OpenGuides/RDF.pm
r1166 r1168 84 84 foreach my $var ( qw( phone fax website opening_hours_text address 85 85 postcode city country latitude longitude 86 os_x os_y map_link summary ) ) {86 os_x os_y map_link summary node_image ) ) { 87 87 my $val = $metadata{$var}[0] || $defaults{$var} || ""; 88 88 $tt_vars{$var} = $val; 89 89 } 90 90 91 92 91 my @cats = @{ $metadata{category} || [] }; 93 92 @cats = map { { name => $_ } } @cats; -
trunk/t/21_rdf.t
r1166 r1168 16 16 } 17 17 18 plan tests => 2 8;18 plan tests => 29; 19 19 20 20 Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } ); … … 76 76 longitude => "-0.114436", 77 77 summary => "a nice pub", 78 node_image => "http://example.com/calthorpe.jpg", 78 79 ); 79 80 … … 82 83 like( $rdfxml, qr|<\?xml version="1.0"\?>|, "RDF is encoding-neutral" ); 83 84 84 like( $rdfxml, qr|<dc:title>Bloomsbury</dc:title>|, 85 like( $rdfxml, qr|<foaf:depiction rdf:resource="http://example.com/calthorpe.jpg" />|, "Node image"); 86 87 like( $rdfxml, qr|<wail:Neighborhood rdf:nodeID="Bloomsbury">|, 85 88 "finds the first locale" ); 86 like( $rdfxml, qr|< dc:title>St Pancras</dc:title>|,89 like( $rdfxml, qr|<wail:Neighborhood rdf:nodeID="St_Pancras">|, 87 90 "finds the second locale" ); 88 91 89 like( $rdfxml, qr|< phone>test phone number</phone>|,92 like( $rdfxml, qr|<contact:phone>test phone number</contact:phone>|, 90 93 "picks up phone number" ); 91 94 92 like( $rdfxml, qr|< chefmoz:Hours>test hours</chefmoz:Hours>|,95 like( $rdfxml, qr|<dc:available>test hours</dc:available>|, 93 96 "picks up opening hours text" ); 94 97 … … 111 114 "set the dc:source with the version-independent uri" ); 112 115 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" );116 like( $rdfxml, qr|<wail:City rdf:nodeID="city">\n\s+<wail:name>London</wail:name>|, "city" ). 117 like( $rdfxml, qr|<wail:locatedIn>\n\s+<wail:Country rdf:nodeID="country">\n\s+<wail:name>United Kingdom</wail:name>|, "country" ). 118 like( $rdfxml, qr|<wail:postalCode>WC1X 8JR</wail:postalCode>|, "postcode" ); 116 119 like( $rdfxml, qr|<geo:lat>51.524193</geo:lat>|, "latitude" ); 117 120 like( $rdfxml, qr|<geo:long>-0.114436</geo:long>|, "longitude" ); … … 170 173 $rdfxml = $rdf_writer->emit_rdfxml( node => "Nonesuch Stores" ); 171 174 172 like( $rdfxml, qr|<geo:SpatialThing rdf:ID="obj" dc:title="Nonesuch Stores">|,175 like( $rdfxml, qr|<geo:SpatialThing rdf:ID="obj">|, 173 176 "having opening hours marks node as geospatial" ); 174 177 -
trunk/templates/node_rdf.tt
r1167 r1168 1 1 <?xml version="1.0"?> 2 2 <rdf:RDF 3 xmlns:chefmoz = "http://chefmoz.org/rdf/elements/1.0/"4 3 xmlns:dc = "http://purl.org/dc/elements/1.1/" 5 4 xmlns:dcterms = "http://purl.org/dc/terms/" 6 5 xmlns:foaf = "http://xmlns.com/foaf/0.1/" 7 6 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/" 9 8 xmlns:os = "http://downlode.org/Code/RDF/Ordnance_Survey/schema/1#" 10 9 xmlns:owl = "http://www.w3.org/2002/07/owl#" 11 10 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/" 12 13 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#" 15 15 > 16 16 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> 21 21 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 %] 25 25 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" /> 30 29 31 <[% obj_type %] rdf:ID="obj" dc:title="[% node_name %]"> 30 [%- IF redirect %] 31 <owl:sameAs rdf:resource="[% redirect %]" /> 32 [%- END %] 32 33 33 [% IF summary %] 34 <dc:description>[% summary %]</dc:description> 35 [% END %] 34 </rdf:Description> 36 35 37 [% IF categories %] 38 <!-- categories --> 36 <[% obj_type %] rdf:ID="obj"> 39 37 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 %] 44 43 45 [% IF is_geospatial %] 46 <!-- address and geospatial data --> 44 [%- IF node_image %] 45 <foaf:depiction rdf:resource="[% node_image %]" /> 46 [%- END %] 47 47 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 --> 60 50 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 %] 66 55 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 --> 74 58 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> 79 83 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 %] 84 89 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 %] 86 100 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 %] 102 105 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 %] 106 110 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 108 131 </rdf:RDF>
