Changeset 1081
- Timestamp:
- 06/16/07 20:45:04 (18 months ago)
- Location:
- trunk
- Files:
-
- 4 modified
-
Changes (modified) (1 diff)
-
lib/OpenGuides/RDF.pm (modified) (3 diffs)
-
t/21_rdf.t (modified) (4 diffs)
-
templates/node_rdf.tt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Changes
r1070 r1081 20 20 someone tries to view a nonexistent node. 21 21 Validate input geodata (#22) 22 List all contributors in RDF version of nodes (#106). 22 23 23 24 0.60 13 May 2007 -
trunk/lib/OpenGuides/RDF.pm
r1066 r1081 83 83 84 84 foreach my $var ( qw( phone fax website opening_hours_text address 85 postcode city country latitude longitude username85 postcode city country latitude longitude 86 86 os_x os_y summary ) ) { 87 87 my $val = $metadata{$var}[0] || $defaults{$var} || ""; … … 134 134 } 135 135 136 $tt_vars{user_id} = $tt_vars{username};137 $tt_vars{user_id} =~ s/\s/_/g;138 139 136 $tt_vars{node_uri} = $self->{make_node_url}->( $node_name ); 140 137 $tt_vars{node_uri_with_version} … … 158 155 } 159 156 157 my @revisions = $wiki->list_node_all_versions( 158 name => $node_name, 159 with_content => 0, 160 with_metadata => 1, 161 ); 162 163 # We want all users who have edited the page listed as contributors, 164 # but only once each 165 foreach my $rev ( @revisions ) { 166 my $username = $rev->{metadata}{username}; 167 next unless defined $username && length $username; 168 169 my $user_id = $username; 170 $user_id =~ s/\s+/_/g; 171 172 $tt_vars{contributors}{$username} ||= 173 { 174 username => encode_entities_numeric($username), 175 user_id => encode_entities_numeric($user_id), 176 }; 177 } 178 160 179 # OK, we've set all our template variables; now process the template. 161 180 my $template_path = $config->template_path; -
trunk/t/21_rdf.t
r1063 r1081 16 16 } 17 17 18 plan tests => 2 7;18 plan tests => 28; 19 19 20 20 Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } ); … … 25 25 $config->default_city( "London" ); 26 26 $config->default_country( "United Kingdom" ); 27 $config->geo_handler( 3 ); 27 28 28 29 eval { require Wiki::Toolkit::Search::Plucene; }; … … 45 46 46 47 # Test the data for a node that exists. 48 OpenGuides::Test->write_data( 49 guide => $guide, 50 node => "Calthorpe Arms", 51 content => "CAMRA-approved pub near King's Cross", 52 comment => "Stub page, please update!", 53 username => "Anonymous", 54 postcode => "WC1X 8JR", 55 locales => "Bloomsbury\r\nSt Pancras", 56 phone => "test phone number", 57 website => "test website", 58 hours_text => "test hours", 59 latitude => "51.524193", 60 longitude => "-0.114436", 61 summary => "a really nice pub", 62 ); 63 47 64 OpenGuides::Test->write_data( 48 65 guide => $guide, … … 84 101 like( $rdfxml, qr|<foaf:Person rdf:ID="Kake">|, 85 102 "last username to edit used as contributor" ); 103 like( $rdfxml, qr|<foaf:Person rdf:ID="Anonymous">|, 104 "... as well as previous usernames" ); 86 105 87 like( $rdfxml, qr|<wiki:version> 1</wiki:version>|, "version picked up" );106 like( $rdfxml, qr|<wiki:version>2</wiki:version>|, "version picked up" ); 88 107 89 108 like( $rdfxml, qr|<rdf:Description rdf:about="">|, "sets the 'about' correctly" ); -
trunk/templates/node_rdf.tt
r1061 r1081 19 19 <dcterms:modified>[% timestamp %]</dcterms:modified> 20 20 21 [% FOREACH contributor = contributors.values %] 21 22 <dc:contributor> 22 <foaf:Person rdf:ID="[% user_id %]">23 <foaf:nick>[% username %]</foaf:nick>23 <foaf:Person rdf:ID="[% contributor.user_id %]"> 24 <foaf:nick>[% contributor.username %]</foaf:nick> 24 25 </foaf:Person> 25 26 </dc:contributor> 27 [% END %] 26 28 27 29 <dc:source rdf:resource="[% node_uri %]" />
