Kathryn Andersen
and 1 contributors

NAME

Muster::MetaDb - keeping meta-data about pages

VERSION

version 0.62

SYNOPSIS

    use Muster::MetaDb;;

DESCRIPTION

Content Management System keeping meta-data about pages.

METHODS

init

Set the defaults for the object if they are not defined already.

update_one_page

Update the meta information for one page

    $self->update_one_page($page, %meta);

update_all_pages

Update the meta information for all pages.

delete_one_page

Delete the meta information for one page

    $self->delete_one_page($page);

update_derived_tables

Update the derived tables for all pages.

page_or_file_info

Get the info about one page. Returns undef if the page isn't there.

    my $meta = $self->page_or_file_info($pagename);

query

Do a freeform query. This returns a reference to the first column of results.

    my $results = $self->query($query);

pagespec_translate

Attempt to translate an IkiWiki-style pagespec into an SQL condition.

query_pagespec

Do a query using an IkiWiki-style pagespec.

    my $results = $self->query($spec);

pagelist

Query the database, return a list of pages

Query the database, return a list of all pages' pagelinks. This does not include _Header or _Footer pages.

total_pages

Query the database, return the total number of records.

page_exists

Does this page/file exist in the database?

Which page does the given link match, when linked from the given page?

my $linkedpage = $self->bestlink($page,$link);

Helper Functions

These are functions which are NOT exported by this plugin.

_connect

Connect to the database If we've already connected, do nothing.

_prepare

Retrieve or create prepared statement handles.

    my $sth = $self->_prepare($q);

_create_tables

Create the initial tables in the database:

pagefiles: (page, title, name, filetype, is_page, filename, parent_page) links: (page, links_to) deepfields: (page, field, value)

_generate_derived_tables

Create and populate the flatfields table using the data from the deepfields table. Expects the deepfields table to be up to date, so this needs to be called at the end of the scanning pass.

    $self->_generate_derived_tables();

_drop_main_tables

Drop all the tables in the database except the flatfields table (which will be done just before it is recreated) If one is doing a scan-all-pages pass, dropping and re-creating may be quicker than updating.

_update_all_entries

Update all pages, adding new ones and deleting non-existent ones. This expects that the pages passed in are the DEFINITIVE list of pages, and if a page isn't in this list, it no longer exists.

    $self->_update_all_entries($page=>{...},$page2=>{}...);

_commit

Commit a pending transaction.

    $self->_commit();

_get_all_pagefiles

List of all pagefiles

$dbtable->_get_all_pagefiles(%args);

_get_all_pagenames

List of all pagenames

$dbtable->_get_all_pagenames();

_get_all_nonhidden_fieldnames

List of the unique non-hidden field-names from the deepfields table. Hidden field names start with '_' and are not supposed to be put into the flatfields table, though they can be queried from the deepfields table.

    @fieldnames = $self->_get_all_nonhidden_fieldnames();

_get_fields_for_page

Get the field-value pairs for a single page from the deepfields table.

    $meta = $self->_get_fields_for_page($page);

_get_children_for_page

Get the "child" pages for this page from the pagefiles table.

    $meta = $self->_get_children_for_page($page);

_get_attachments_for_page

Get the "attachments" non-pages for this page from the pagefiles table.

    $meta = $self->_get_attachments_for_page($page);

Get the "links" pages for this page from the links table.

    $meta = $self->_get_links_for_page($page);

_get_page_meta

Get the meta-data for a single page.

    $meta = $self->_get_page_meta($page);

_do_one_col_query

Do a SELECT query, and return the first column of results. This is a freeform query, so the caller must be careful to formulate it correctly.

my $results = $self->_do_one_col_query($query);

_total_pagefiles

Find the total records in the database.

$dbtable->_total_pagefiles();

_total_pages

Find the total number of pages.

$dbtable->_total_pages();

_find_pagename

Does this page exist in the database? This does a case-insensitive check if there isn't an exact match. Returns the real pagename if it is found, otherwise empty string.

The page as if it were a html link. This does things like add a route-prefix or trailing slash if it is needed.

It's okay to hardcode the route-prefix into the database, because it isn't as if one is going to be mounting the same config multiple times with different route-prefixes. If you have a different config, you're going to need a different database.

_add_page_data

Add metadata to db for one page.

    $self->_add_page_data($page, %meta);