NAME

Muster::MetaDb - keeping meta-data about pages

VERSION

version 0.92

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_some_pages

Update the meta information for more than one page

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

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. Always EXCLUDE pages starting with _ because they are special hidden pages.

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

pagelist

Query the database, return a list of all pages

non_hidden_pagelist

Query the database, return a list of all pages NOT including _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_binary, filename, parent_page...) links: (page, links_to) deepfields: (page, field, value)

_generate_derived_tables

The flatfields table may or may not need to be re-defined, depending on whether there are new or deleted non-hidden fields since the last time the flatfields table was updated. If the column definitions are unchanged, one does not need to re-define the flatfields table, just update its contents.

$self->_generate_derived_tables();

_update_derived_tables

If the flatfields table definition hasn't been changed, it needs to be updated 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. If the "pages" argument exists, just update those pages rather than all the pages.

$self->_update_derived_tables(pages=>{%the_pages});

_generate_new_derived_tables

If the definition of the flatfields table has changed, it needs to be recreated. 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_new_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_some_entries

Update some pages, adding new ones and updating existing ones. This does NOT delete pages.

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

_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);

_column_names

Get the column names of the given table.

my @col_names = $self->_column_names($table);

_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.

_add_page_data

Add metadata to db for one page.

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