This file is indexed.

/usr/share/perl5/WWW/Mechanize/AutoPager.pm is in libwww-mechanize-autopager-perl 0.02-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package WWW::Mechanize::AutoPager;

use strict;
use 5.8.1;
our $VERSION = '0.02';

use HTML::AutoPagerize;
use Scalar::Util qw( weaken );
use WWW::Mechanize;
use JSON;

sub WWW::Mechanize::autopager {
    my $mech = shift;
    $mech->{autopager} ||= WWW::Mechanize::AutoPager->new($mech);
}

sub WWW::Mechanize::next_link {
    my $mech = shift;
    $mech->{autopager}->next_link;
}

sub WWW::Mechanize::page_element {
    my $mech = shift;
    $mech->{autopager}->page_element;
}

sub new {
    my($class, $mech) = @_;
    my $self = bless {
        mech => $mech,
        autopager => HTML::AutoPagerize->new,
    }, $class;

    weaken($self->{mech}); # don't make it a circular reference
    $self;
}

sub load_siteinfo {
    my $self = shift;
    my $url  = shift || "http://wedata.net/databases/AutoPagerize/items.json";

    my $res = $self->{mech}->get($url);

    if (my $content = $self->{mech}->content) {
        if ($res->content_type =~ m{text/html}) { # backward compatibility
            while ($content =~ m!<textarea class="autopagerize_data".*?>\s*(.*?)\s*</textarea>!gs) {
                my $site = $self->parse_siteinfo($1);
                $self->{autopager}->add_site(%$site);
            }
        } else {
            for my $row ( @{ from_json( $content ) } ) {
                $self->{autopager}->add_site(%{ $row->{data} });
            }
        }
    }
}

sub add_site {
    my $self = shift;
    $self->{autopager}->add_site(@_);
}

sub parse_siteinfo {
    my($self, $config) = @_;
    my $site;
    while ($config =~ /^(\w+):\s+(.*?)\s*$/mg) {
        $site->{$1} = $2;
    }
    return $site;
}

sub next_link {
    my $self = shift;

    my $res = $self->{autopager}->handle($self->{mech}->uri, $self->{mech}->content)
        or return;

    return $res->{next_link};
}

sub page_element {
    my $self = shift;

    my $res = $self->{autopager}->handle($self->{mech}->uri, $self->{mech}->content)
        or return;

    return $res->{page_element};
}


1;
__END__

=for stopwords AutoPagerize siteinfo

=head1 NAME

WWW::Mechanize::AutoPager - Automatic Pagination using AutoPagerize

=head1 SYNOPSIS

  use WWW::Mechanize::AutoPager;

  my $mech = WWW::Mechanize->new;

  # Load siteinfo from http://swdyh.infogami.com/autopagerize
  $mech->autopager->load_siteinfo();

  # Or, load manually
  $mech->autopager->add_site(
      url => 'http://.+\.tumblr\.com/',
      nextLink => ...,
  );

  $mech->get('http://otsune.tumblr.com/');

  if (my $link = $mech->next_link) {
      $mech->get($link);
      $mech->page_element; # HTML snippet
  }

=head1 DESCRIPTION

WWW::Mechanize::AutoPager is a plugin for WWW::Mechanize to do
automatic pagination using AutoPagerize user script.

B<THIS MODULE IS CONSIDERED EXPERIMENTAL AND ITS API WILL BE LIKELY TO CHANGE>

=head1 AUTHOR

Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt>

=head1 LICENSE

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=head1 SEE ALSO

L<HTML::AutoPagerize>, L<http://swdyh.infogami.com/autopagerize>

=cut