Gergely Nagy > Babble > Babble::DataSource::FlatFile

Download:
Babble-0.07.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Babble::DataSource::FlatFile - Flat file source fetcher for Babble

SYNOPSIS ^

 use Babble;
 use Babble::DataSource::FlatFile;

 my $babble = Babble->new ();
 $babble->add_sources (
        Babble::DataSource::FlatFile->new (
                -location => "/home/me/blog/data",
                -extension => "\.blog",
                -permalink_base => 'http://example.org/~me/blog/'
        )
 );
 ...

DESCRIPTION ^

Babble::DataSource::FlatFile implements a Babble data source class that fetches documents directly from the filesystem.

METHODS ^

new (%params)

This method creates a new object. The recognised arguments are -location, which specifies the directory where documents should be collected from; -extension, a regexp that will be used to find out which files are documents, and which are not (defaults to \.txt); -permalink_base, the base URL for the collection (used by the permanent link generator, see later); and -permalink_gen, a code reference that is used to generate links to documents.

The method specified in -permalink_gen takes four arguments: base, file, date and ext. All of them are string scalar references. Base is what we specified using -permalink_base, file is the full path to the filename we're currently operating on, date is its submission date, and ext is its extension.

collect ()

This function finds all the files in the data directory (recursively) which have the specified extension, and makes a Babble::Document out of them. The title is the first line of the file, the date is its modification time, subject is the subdirectory under which it was found (or main, if it was in the top-level directory), author is the user owning the file, content is the file content, save the first line.

It's id property contains a pointer to the entry (eg, to one's weblog). This is generated by the $source->{permalink_gen} function, explained above.

For the Babble::Document::Collection object to return, some information will be gathered from the Babble object which calls this method, or from the parameters passed to us. Namely, the meta_title, meta_desc, meta_link, meta_owner, meta_owner_email, meta_subject, meta_image and meta_feed_link keys will be used, if present.

AUTHOR ^

Gergely Nagy, algernon@bonehunter.rulez.org

Bugs should be reported at http://bugs.bonehunter.rulez.org/babble.

SEE ALSO ^

Babble::Document(3pm), Babble::Document::Collection(3pm), Babble::DataSource(3pm)

syntax highlighting: