NAME

WWW::Mixi::OO::Page - WWW::Mixi::OO's Pages base class

SYNOPSIS

package WWW::Mixi::OO::Foo;
use base qw(WWW::Mixi::OO::Page);
sub uri {
    shift->absolute_uri('foo.pl');
}
# some implementations...

DESCRIPTION

pages base class.

METHODS

new
# subclass
sub new {
    my $this = shift->SUPER::new(@_);
    # some initializations...
}

# call
my $page = $pkg->new($session);

constructor of page. please override if you need some initializations.

uri
  # subclass
  sub uri {
      my ($this, %options) = @_;
      $this->SUPER::uri(_path => 'foo',
			_params => {
			    a => b,
			},
			%options);
  }

  # call
  my $uri = $page->uri([opt => val], ...);

return URI of page.

parse_uri
  # subclass
  sub parse_uri {
      my ($this, $data, %options) = @_;
      $this->copy_hash_val($data->{params}, \%options, 'page');
      if ($data->{path} eq "show_friend") {
	  # blah...
      }
      if ($data->{uri}->...) {
	  # maybe you won't use this
      }
      $this->SUPER::uri($data, %options);
  }

  # call
  my %options = $page->analyze_uri($uri);

return page information of URI.

parse
# subclass
sub parse {
    my ($this, %options) = @_;
    # parse...
    my $part = $this->parse_extract_parts(qw/.../);
    return () unless defined $part;
    # return
    return ({ a => b, c => d }, { a => e, c => f }, ...);
}

# call
my @datas = $page->parse;

page parser. please return hashref array.

parse_banner
my $data = $page->parse_banner;

parse banner. structure:

link:    link to ad page.
subject: subject of ad(banner's alt text).
image:   image of banner
height:  height of image
width:   width of image
parse_mainmenu
my @data = $page->parse_mainmenu;

parse mainmenu. structure:

link:    link to page
subject: subject of page
parse_tool_bar
my @data = $page->parse_tool_bar;

parse toolbar. structure:

link:    link to page
subject: subject of page
image:   image of toolbar.
height:  height of image
width:   width of image
get
$page->get([opt => val], ...);

handy method. call ->set_content and ->parse.

set_content
$page->set_content($uri);

or

$page->set_content(%options);

set content to specified by uri or options.

UTILITY METHODS

methods to useful for subclass implementations

parse_extract_parts
# array
my @parts = $this->parse_extract_parts(qr|....|);
return () unless @parts;
# more parse with @parts

or

# scalar
my $part = $this->parse_extract_parts(qr|....|);
return () unless defined $part;
# more parse with $part

extract part(s) from current content.

html_attr_to_uri
$page->html_attr_to_uri('src', 'src="foobar" ...');

parse html attrs string(->html_attrs_to_hash) and extract attr(->generate_ignore_case_hash()->{$attrname}) and resolve to absolute URI(->absolute_linked_uri).

html_anchor_to_uri
$page->html_anchor_to_uri("href='...'...");

handy method. call ->html_attr_to_uri with 'href'.

cache
my $cache = $pkg->cache;
if (defined $cache->{foo}) {
    return $cache->{foo};
}
...

get modules's cache storage.

mk_cached_parser
# from subclass
__PACKAGE__->mk_cached_parser(qw(foo bar));
sub _parse_foo {
    # ...
    return $foo; # please return scalar value.
}

generate cached parser (proxy) method. use _parse_(name) to real parser method.

mk_get_method
# from subclass
__PACKAGE__->mk_get_method(qw(foo bar));

generate get handy method.

ACCESSOR

session

parent WWW::Mixi::OO object.

PROXY METHODS

relative_uri
absolute_uri
absolute_linked_uri
refresh_content
post
response
content
page
class_to_page
page_to_class
analyze_uri
convert_from_http_content
convert_to_http_content
convert_login_time
convert_time

see WWW::Mixi::OO::Session.

SEE ALSO

WWW::Mixi::OO

for listed content: WWW::Mixi::OO::ListPage

AUTHOR

Topia <topia@clovery.jp>

COPYRIGHT AND LICENSE

Copyright (C) 2005 by Topia.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.