NAME
WWW::Dilbert - Dilbert of the day comic strip archive and retieval module
VERSION
$VERSON
SYNOPSYS
use WWW::Dilbert;
my $dilbert = new WWW::Dilbert;
my $strip = $dilbert->get_todays_strip_from_website();
use WWW::Dilbert;
my $dilbert = new WWW::Dilbert(
dbi_dsn => 'DBI:mysql:nicolaw:localhost',
dbi_user => 'username',
dbi_pass => 'password'
);
chdir '/home/albert/my_dilbert_archive_directory';
if (opendir(DH,'.')) {
for (grep(/dilbert[0-9]{10,14}\.gif$/, readdir(DH))) {
my $strip = $dilbert->get_strip_from_filename($_);
$strip->insert_into_database();
}
}
DESCRIPTION
This module will download the latest Dilbert of the Day cartoon strip from the Dilbert website and return an object which can be either stored in a database or output to a browser, disk or whatever. It allows importing of Dilbert strips from disk or alternate URLs, and has a random strip interface to return strips from the database.
METHODS
WWW::Dilbert Object Methods
Strip retrieval object.
- new()
-
Create a new WWW::Dilbert strip retrieval object. Accepts the following key-value pairs:
dbi_dns => 'DBI:mysql:database:hostname', dbi_user => 'username', dbi_pass => 'password'
- get_todays_strip_from_website()
-
Returns a strip object containing todays Dilbert of the Day cartoon strip.
- get_strip_from_website($strip_id)
-
Returns a strip object containing a specific Dilbert cartoon strip as downloaded from the Dilbert website.
- get_strip_from_filename($filename)
-
Returns a strip object containing a specific Dilbert cartoon strip from a Dilbert comic stip file on disk.
- get_strip_from_database($strip_id)
- get_random_strip_from_database()
WWW::Dilbert::Strip Object Methods
Strip object returned by WWW::Dilbert get methods.
- insert_into_database()
-
Inserts the strip in to a database via the DBI database defined by the parent WWW::Dilbert object.
- width()
-
Returns the width of the comic strip image.
- height()
-
Returns the height of the comic strip image.
- file_ext
-
Returns the file extension for the comic strip image format.
- file_media_type
-
Returns the MIME type for the comic strip image format.
- bytes()
-
Returns the total number of bytes of the comic strip image.
- strip_blob()
-
Returns the binary image data of the comic strip image.
- strip_id()
-
Returns the comic strip id.
SQL SCHEMA
CREATE TABLE dilbert_character (
id int unsigned not null primary key auto_increment,
name char(100) not null,
regular_character bool default null,
notes text,
photo_blob blob
);
CREATE TABLE dilbert_strip (
id bigint(14) unsigned not null primary key,
strip_blob mediumblob not null,
bytes int unsigned not null,
width int(4) unsigned not null,
height int(4) unsigned not null,
colour bool default null,
cells enum('3','6','-1') default "3" not null,
text text
);
CREATE TABLE dilbert_character2dilbert_strip (
dilbert_character_id int unsigned not null,
dilbert_strip_id bigint(14) unsigned not null,
primary key (dilbert_character_id, dilbert_strip_id)
);
SEE ALSO
Dev::Bollocks
TODO
Complete the database search facility, and add retrieval of strips from the last 30 day online archive.
BUGS
Probably.
LICENSE
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
AUTHOR
Nicola Worthington <nicolaworthington@msn.com>
Copyright (C) 2004 Nicola Worthington.
http://www.nicolaworthington.com