Changeset 1821

Show
Ignore:
Timestamp:
05/18/06 05:04:04
Author:
bricas
Message:

applied Adam's pod patch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WWW-OpenSearch/branches/WWW-OpenSearch-rewrite/lib/WWW/OpenSearch.pm

    r1802 r1821  
    1414 
    1515our $VERSION = '0.06'; 
     16 
     17=head1 NAME 
     18 
     19WWW::OpenSearch - Search A9 OpenSearch compatible engines 
     20 
     21=head1 SYNOPSIS 
     22 
     23    use WWW::OpenSearch; 
     24     
     25    my $url = "http://bulkfeeds.net/opensearch.xml"; 
     26    my $engine = WWW::OpenSearch->new($url); 
     27     
     28    my $name = $engine->description->ShortName; 
     29    my $tags = $engine->description->Tags; 
     30     
     31    # Perform search for "iPod" 
     32    my $response = $engine->search("iPod"); 
     33    for my $item (@{$response->feed->items}) { 
     34        print $item->{description}; 
     35    } 
     36     
     37    # Retrieve the next page of results 
     38    my $next_page = $response->next_page; 
     39    for my $item (@{$next_page->feed->items}) { 
     40        print $item->{description}; 
     41    } 
     42 
     43=head1 DESCRIPTION 
     44 
     45WWW::OpenSearch is a module to search A9's OpenSearch compatible search engines. See http://opensearch.a9.com/ for details. 
     46 
     47=head1 CONSTRUCTOR 
     48 
     49=head2 new( $url ) 
     50 
     51Constructs a new instance of WWW::OpenSearch using the given 
     52URL as the location of the engine's OpenSearch Description 
     53document (retrievable via the description_url accessor). 
     54 
     55=head1 METHODS 
     56 
     57=head2 fetch_description( [ $url ] ) 
     58 
     59Fetches the OpenSearch Descsription found either at the given URL 
     60or at the URL specified by the description_url accessor. Fetched 
     61description may be accessed via the description accessor. 
     62 
     63=head2 search( $query [, \%params] ) 
     64 
     65Searches the engine for the given query using the given  
     66search parameters. Valid search parameters include: 
     67 
     68=over 4 
     69 
     70=item * startPage 
     71 
     72=item * totalResults 
     73 
     74=item * startIndex 
     75 
     76=item * itemsPerPage 
     77 
     78=back 
     79 
     80See http://opensearch.a9.com/spec/1.1/response/#elements for details. 
     81 
     82=head2 do_search( $url [, $method] ) 
     83 
     84Performs a request for the given URL and returns a 
     85WWW::OpenSearch::Response object. Method defaults to 'GET'. 
     86 
     87=head1 ACCESSORS 
     88 
     89=head2 description_url( [$description_url] ) 
     90 
     91=head2 agent( [$agent] ) 
     92 
     93=head2 description( [$description] ) 
     94 
     95=head1 AUTHOR 
     96 
     97=over 4 
     98 
     99=item * Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt> 
     100 
     101=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt> 
     102 
     103=back 
     104 
     105=head1 COPYRIGHT AND LICENSE 
     106 
     107Copyright 2006 by Tatsuhiko Miyagawa and Brian Cassidy 
     108 
     109This library is free software; you can redistribute it and/or modify 
     110it under the same terms as Perl itself.  
     111 
     112=cut 
    16113 
    17114sub new { 
  • WWW-OpenSearch/branches/WWW-OpenSearch-rewrite/lib/WWW/OpenSearch/Description.pm

    r1802 r1821  
    1818 
    1919__PACKAGE__->mk_accessors( qw( version ns ), map { lc } @columns ); 
     20 
     21=head1 NAME 
     22 
     23WWW::OpenSearch::Description - Encapsulate an OpenSearch Description 
     24provided by an A9 OpenSearch compatible engine 
     25 
     26=head1 SYNOPSIS 
     27     
     28    use WWW::OpenSearch; 
     29     
     30    my $url = "http://bulkfeeds.net/opensearch.xml"; 
     31    my $engine = WWW::OpenSearch->new($url); 
     32    my $description = $engine->description; 
     33     
     34    my $format   = $description->Format;   # or $description->format 
     35    my $longname = $description->LongName; # or $description->longname 
     36     
     37=head1 DESCRIPTION 
     38 
     39WWW::OpenSearch::Description is a module designed to encapsulate an 
     40OpenSearch Description provided by an A9 OpenSearch compatible engine. 
     41See http://opensearch.a9.com/spec/1.1/description/ for details. 
     42 
     43=head1 CONSTRUCTOR 
     44 
     45=head2 new( [ $xml ] ) 
     46 
     47Constructs a new instance of WWW::OpenSearch::Description. If scalar 
     48parameter $xml is provided, data will be automatically loaded from it 
     49using load( $xml ). 
     50 
     51=head1 METHODS 
     52 
     53=head2 load( $xml ) 
     54 
     55Loads description data by parsing provided argument using XML::LibXML. 
     56 
     57=head2 get_best_url( ) 
     58 
     59Attempts to retrieve the best URL associated with this description, based 
     60on the following content types (from most preferred to least preferred): 
     61 
     62=over 4 
     63 
     64=item * application/atom+xml 
     65 
     66=item * application/rss+xml 
     67 
     68=item * text/xml 
     69 
     70=back 
     71 
     72=head2 get_url_by_type( $type ) 
     73 
     74Retrieves the first WWW::OpenSearch::URL associated with this description 
     75whose type is equal to $type. 
     76 
     77=head1 ACCESSORS 
     78 
     79=head2 version( ) 
     80 
     81=head2 ns( ) 
     82 
     83=head2 AdultContent( ) 
     84 
     85=head2 Contact( ) 
     86 
     87=head2 Description( ) 
     88 
     89=head2 Developer( ) 
     90 
     91=head2 Format( ) 
     92 
     93=head2 Image( ) 
     94 
     95=head2 LongName( ) 
     96 
     97=head2 Query( ) 
     98 
     99=head2 SampleSearch( ) 
     100 
     101=head2 ShortName( ) 
     102 
     103=head2 SyndicationRight( ) 
     104 
     105=head2 Tags( ) 
     106 
     107=head2 Url( ) 
     108 
     109=head1 AUTHOR 
     110 
     111=over 4 
     112 
     113=item * Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt> 
     114 
     115=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt> 
     116 
     117=back 
     118 
     119=head1 COPYRIGHT AND LICENSE 
     120 
     121Copyright 2006 by Tatsuhiko Miyagawa and Brian Cassidy 
     122 
     123This library is free software; you can redistribute it and/or modify 
     124it under the same terms as Perl itself.  
     125 
     126=cut 
    20127 
    21128for( @columns ) { 
  • WWW-OpenSearch/branches/WWW-OpenSearch-rewrite/lib/WWW/OpenSearch/Response.pm

    r1802 r1821  
    1010 
    1111__PACKAGE__->mk_accessors( qw( feed pager parent ) ); 
     12 
     13=head1 NAME 
     14 
     15WWW::OpenSearch::Response - Encapsulate a response received from 
     16an A9 OpenSearch compatible engine 
     17 
     18=head1 SYNOPSIS 
     19     
     20    use WWW::OpenSearch; 
     21     
     22    my $url = "http://bulkfeeds.net/opensearch.xml"; 
     23    my $engine = WWW::OpenSearch->new($url); 
     24     
     25    # Retrieve page 4 of search results for "iPod" 
     26    my $response = $engine->search("iPod",{ startPage => 4 }); 
     27    for my $item (@{$response->feed->items}) { 
     28        print $item->{description}; 
     29    } 
     30     
     31    # Retrieve page 3 of results 
     32    $response = $response->previous_page; 
     33     
     34    # Retrieve page 5 of results 
     35    $response = $response->next_page; 
     36     
     37=head1 DESCRIPTION 
     38 
     39WWW::OpenSearch::Response is a module designed to encapsulate a 
     40response received from an A9 OpenSearch compatible engine. 
     41See http://opensearch.a9.com/spec/1.1/response/ for details. 
     42 
     43=head1 CONSTRUCTOR 
     44 
     45=head2 new( $parent, $response ) 
     46 
     47Constructs a new instance of WWW::OpenSearch::Response. Arguments 
     48include the WWW::OpenSearch object which initiated the search (parent) 
     49and the HTTP::Response returned by the search request. 
     50 
     51=head1 METHODS 
     52 
     53=head2 parse_response( ) 
     54 
     55Parses the content of the HTTP response using XML::Feed. If successful, 
     56parse_feed( ) is also called. 
     57 
     58=head2 parse_feed( ) 
     59 
     60Parses the XML::Feed originally parsed from the HTTP response content. 
     61Sets the pager object appropriately. 
     62 
     63=head2 previous_page( ) / next_page( ) 
     64 
     65Performs another search on the parent object, returning a 
     66WWW::OpenSearch::Response instance containing the previous/next page 
     67of results. If the current response includes a &lt;link rel="previous/next" 
     68href="..." /&gt; tag, the page will simply be the parsed content of the URL 
     69specified by the tag's href attribute. However, if the current response does not 
     70include the appropriate link, a new query is constructed using the startPage 
     71or startIndex query arguments. 
     72 
     73=head2 _get_link( $type ) 
     74 
     75Gets the href attribute of the first link whose rel attribute 
     76is equal to $type. 
     77 
     78=head1 ACCESSORS 
     79 
     80=head2 feed( ) 
     81 
     82=head2 pager( ) 
     83 
     84=head2 parent( ) 
     85 
     86=head1 AUTHOR 
     87 
     88=over 4 
     89 
     90=item * Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt> 
     91 
     92=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt> 
     93 
     94=back 
     95 
     96=head1 COPYRIGHT AND LICENSE 
     97 
     98Copyright 2006 by Tatsuhiko Miyagawa and Brian Cassidy 
     99 
     100This library is free software; you can redistribute it and/or modify 
     101it under the same terms as Perl itself.  
     102 
     103=cut 
    12104 
    13105sub new { 
     
    73165 
    74166# TODO 
    75 # handle pervious/next page on POST 
     167# handle previous/next page on POST 
    76168 
    77169sub next_page { 
  • WWW-OpenSearch/branches/WWW-OpenSearch-rewrite/lib/WWW/OpenSearch/Url.pm

    r1802 r1821  
    77 
    88__PACKAGE__->mk_accessors( qw( type template method macros ) ); 
     9 
     10=head1 NAME 
     11 
     12WWW::OpenSearch::URL 
     13 
     14=head1 SYNOPSIS 
     15 
     16=head1 DESCRIPTION 
     17 
     18=head1 CONSTRUCTOR 
     19 
     20=head2 new( [%options] ) 
     21 
     22=head1 METHODS 
     23 
     24=head2 parse_macros( ) 
     25 
     26=head2 prepare_query( [ \%params ] ) 
     27 
     28=head1 ACCESSORS 
     29 
     30=head1 AUTHOR 
     31 
     32=over 4 
     33 
     34=item * Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt> 
     35 
     36=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt> 
     37 
     38=back 
     39 
     40=head1 COPYRIGHT AND LICENSE 
     41 
     42Copyright 2006 by Tatsuhiko Miyagawa and Brian Cassidy 
     43 
     44This library is free software; you can redistribute it and/or modify 
     45it under the same terms as Perl itself.  
     46 
     47=cut 
    948 
    1049sub new {