Module::Build::IkiWiki - Extension for develop Ikiwiki plugins


Module-Build-IkiWiki documentation Contained in the Module-Build-IkiWiki distribution.

Index


Code Index:

NAME

Top

Module::Build::IkiWiki - Extension for develop Ikiwiki plugins

VERSION

Top

This document describes Module::Build::IkiWiki version 0.0.2

SYNOPSIS

Top

    #!/usr/bin/perl 

    use Module::Build::IkiWiki;

    my $build = Module::Build::IkiWiki->new(
                    module_name     =>  'xxxx',
                    license         =>  'gpl',
                    ...
                    ikiwiki_paths       =>  {
                        'templates' =>  q(/usr/share/ikiwiki/templates),
                        'css'       =>  q(/usr/share/ikiwiki/basewiki),
                        },
                    ikiwiki_templates   =>  [ glob('extras/*.tmpl') ],
                    ikiwiki_stylesheets =>  [ glob('extras/*.css') ],
                );

    $build->create_build_script();

DESCRIPTION

Top

The goal of this module is build and install IkiWiki plugins in Perl, subclassing the Module::Build and adding some extra funcionalites to it.

For a description of the interface see Module::Build::API.

This is a list of a new parameters in the Module::Build::new method:

ikiwiki_paths

Define the install paths of the components using a hash with the following keys:

templates

The default value is /usr/share/ikiwiki/templates.

css

The default value is /usr/share/ikiwiki/basewiki.

ikiwiki_templates

List of templates for install.

ikiwiki_stylesheets

List of css stylesheets files to install.

SUBROUTINES/METHODS

Top

new( )

Override the new method in the base class and check the special parameters for ikiwiki.

ACTION_install( )

Install the template and css files of the package.

ACTION_fakeinstall( )

Show the install actions to the standard output.

DIAGNOSTICS

Top

The error messages are from the base class. This package don't generate any exceptions.

CONFIGURATION AND ENVIRONMENT

Top

Module::Build::IkiWiki requires no configuration files or environment variables.

DEPENDENCIES

Top

Module::Build

INCOMPATIBILITIES

Top

None reported.

BUGS AND LIMITATIONS

Top

No bugs have been reported.

Please report any bugs or feature requests to bug-module-build-ikiwiki@rt.cpan.org, or through the web interface at http://rt.cpan.org.

AUTHOR

Top

Víctor Moral <victor@taquiones.net>

LICENSE AND COPYRIGHT

Top


Module-Build-IkiWiki documentation Contained in the Module-Build-IkiWiki distribution.

package Module::Build::IkiWiki;
use base qw(Module::Build);
use warnings;
use strict;
use Carp;

use File::Basename;
use File::Spec;

our $VERSION    =   '0.0.3';

# flag for fake installations
my  $_fake_install  =   0;

# Module implementation here
sub new {
    my  ($class,@params)    = @_;
    my  $self               = $class->SUPER::new( @params );
    my  $prop               = $self->_get_prop();
    
    my  %ikiwiki_paths  =   (
            'templates' =>  q(/usr/share/ikiwiki/templates),
            'css'       =>  q(/usr/share/ikiwiki/basewiki),
    );

    # checking default values 
    if (not defined ($prop->{ ikiwiki_paths } )) {
        $prop->{ ikiwiki_paths } = \%ikiwiki_paths;
    }
    foreach my $other qw(ikiwiki_templates ikiwiki_css) {
        if (not exists $prop->{ $other }) {
            $prop->{ $other } = [];
        }
    }

    return $self;
}

sub ACTION_install {
    my  ($self,@params)     =   @_;
    my  $prop               =   $self->_get_prop();

    if (not $_fake_install) {
        $self->SUPER::ACTION_install( @params );
    }

    # process the new file types 
    foreach my $category qw(templates css) {
        # get the final list
        my @source_files = @{ $prop->{ "ikiwiki_${category}" } };
        my $dest_dir    =   $self->destdir() || '';

        if (@source_files) {
            # get the target directory 
            my $target_dir = File::Spec->catdir( 
                                    $dest_dir,
                                    $prop->{ikiwiki_paths}->{$category}
                                );

            # install the source files 
            foreach my $source (@source_files) {
                my $to_file = File::Spec->catdir($target_dir, 
                                    scalar fileparse( $source ) );

                if ($_fake_install) {
                    print "Installing ${to_file}\n";
                }
                else {
                    $self->copy_if_modified( from => $source,
                                            to   => $to_file );
                }                                        
            }
        }
    }            

    return;
}

sub ACTION_fakeinstall {
    my  ($self,@params)     =   @_;
    
    # first dispatch to up 
    $self->SUPER::ACTION_fakeinstall( @params );

    # and now show our files
    $_fake_install = 1;
    $self->ACTION_install( @params );
    $_fake_install = 0;

    return;
}

sub _get_prop {
    my  $self   =   shift;

    return $self->{ properties };   ##Violates 'ProhibitAccessOfPrivateData'
}

1; # Magic true value required at end of module
__END__