Changeset 1873

Show
Ignore:
Timestamp:
11/28/06 09:07:41
Author:
miyagawa
Message:
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/feature-geo/plagger/lib/Plagger/Plugin/Bundle/Geo.pm

    r1854 r1873  
    88    $context->autoload_plugin({ module => 'Namespace::Geo' }); 
    99    $context->autoload_plugin({ module => 'Namespace::GeoRSS' }); 
     10    $context->autoload_plugin({ module => 'Filter::FindMapLinks' }); 
    1011} 
    1112 
  • branches/feature-geo/plagger/lib/Plagger/Plugin/Filter/FindMapLinks.pm

    r1869 r1873  
    4444 
    4545        my $p = HTML::LinkExtor->new($callback); 
    46         $p->parse($body->html); 
     46        $p->parse($body->data); 
    4747        $p->eof; 
     48    } else { 
     49        my $finder = URI::Find->new(sub { push @links, $_[1] }); 
     50        $finder->find(\$body->data); 
    4851    } 
    4952 
     
    9497=head1 SEE ALSO 
    9598 
    96 L<Plagger>, L<http://www.locapoint.com/jp/links.html> 
     99L<Plagger>, L<http://www.locapoint.com/tool/navito/navi2gwoption.xml> 
    97100 
    98101=cut 
  • branches/feature-geo/plagger/t/plugins/Filter-FindMapLinks/base.t

    r1868 r1873  
    33 
    44sub filter_config { 
     5    my $url = Plagger::Util::encode_xml($_[0]); 
    56    return <<CONF; 
    67plugins: 
     
    910      title: Maps 
    1011      entry: 
    11         - title: Foo 
     12        - title: HTML 
    1213          body: | 
    13             <a href="$_[0]">Foo</a> 
     14            <a href="$url">Foo</a> 
     15        - title: Text 
     16          body: Link to $_[0] 
    1417  - module: Filter::FindMapLinks 
    1518CONF 
    1619} 
    1720 
    18 sub lonlat
     21sub loc
    1922    my $context = shift; 
    20     my $loc = $context->update->feeds->[0]->entries->[0]->location
    21     return $loc ? join(",", $loc->latitude, $loc->longitude) : "NOLOC"
     23    my @loc = map $context->update->feeds->[0]->entries->[$_]->location, 0..1
     24    return \@loc
    2225} 
    2326 
     27test_plugin_deps; 
     28 
    2429filters 'chomp'; 
    25 filters { input => [ 'filter_config', 'config', 'lonlat' ] }; 
     30filters { input => [ 'filter_config', 'config' ] }; 
    2631 
    27 test_plugin_deps; 
    28 plan 'no_plan'; 
    29 run_is; 
     32plan tests => 2 * blocks; 
     33 
     34run { 
     35    my $block = shift; 
     36    my $context = $block->input; 
     37 
     38    for (0..1) { 
     39        my $entry = $context->update->feeds->[0]->entries->[$_]; 
     40        my $loc = $entry->location; 
     41        my $geo = $loc ? join(",", $loc->latitude, $loc->longitude) : "NOLOC"; 
     42        is $geo, $block->expected, $block->name . " " . $entry->title; 
     43    } 
     44}; 
    3045 
    3146__END__ 
     
    4863--- expected 
    4964NOLOC 
     65 
     66=== Google Maps UK 
     67--- input 
     68http://maps.google.co.uk/?q=%2b35.123456,%2b135.123456 
     69--- expected 
     7035.123456,135.123456 
     71 
     72=== Mapion 
     73--- SKIP 
     74--- input 
     75http://www.mapion.co.jp/c/f?uc=1&grp=all&nl=34/37/43.719&el=135/37/08.946&scl=25000&bid=Mlink 
     76--- expected 
     7734/37/43.719,135/37/08.946