Skip to content

standardgalactic/Mojolicious-Plugin-Export

 
 

Repository files navigation

Build Status Coverage Status

NAME

Mojolicious::Plugin::Export - Export a Mojolicious website to static files

VERSION

version 0.008

SYNOPSIS

use Mojolicious::Lite;
get '/' => 'index';
get '/secret' => 'secret';
plugin Export => {
    pages => [qw( / /secret )],
};
app->start;

DESCRIPTION

Deploy a Mojolicious webapp to static files.

Configuration

Default values for the command's options can be specified in the configuration using one of Mojolicious's configuration plugins.

# myapp.conf
{
    export => {
        # Configure the default pages to export
        pages => [ '/', '/hidden' ],
        # The directory to export to
        to => '/var/www/html',
        # Rewrite URLs to include base directory
        base => '/',
    }
}

ATTRIBUTES

pages

The pages to export by default. This can be overridden by the arguments to "export".

# Add pages to export by default
push @{ $app->export->pages }, '/blog';

to

The path to export to by default.

base

The base URL, if URLs need to be rewritten.

quiet

If true, will not report every action taken by the plugin. Defaults to true.

METHODS

export

app->export->export( $override );

Export the site. $override is a hash reference to override the object attributes (keys are attribute names, values are the overridden value).

HELPERS

export

The export helper returns the Mojolicious::Plugin::Export object.

EVENTS

before_write

Emitted after all the content has been loaded and prepared for export. The event is given two arguments: The Mojolicious::Plugin::Export object and a hashref of paths mapped to content to be exported. The content can be either a Mojo::DOM object for HTML pages or the content to be exported. This event may modify the hashref or the DOM objects to change the content before it is written.

app->export->on( before_write => sub {
    my ( $export, $pages ) = @_;
    for my $path ( keys %$pages ) {
        my $content = $pages->{ $path };
        # ...
    }
} );

SEE ALSO

Mojolicious::Command::export, Mojolicious::Plugin::Export::Git, Mojolicious::Plugin

AUTHOR

Doug Bell preaction@cpan.org

COPYRIGHT AND LICENSE

This software is copyright (c) 2018 by Doug Bell.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

About

Export a Mojolicious webapp to static files

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Raku 72.3%
  • Perl 27.7%