An open API service indexing awesome lists of open source software.

https://github.com/preaction/mojolicious-plugin-export

Export a Mojolicious webapp to static files
https://github.com/preaction/mojolicious-plugin-export

Last synced: 8 months ago
JSON representation

Export a Mojolicious webapp to static files

Awesome Lists containing this project

README

          

[![Build Status](https://travis-ci.org/preaction/Mojolicious-Plugin-Export.svg?branch=master)](https://travis-ci.org/preaction/Mojolicious-Plugin-Export)
[![Coverage Status](https://coveralls.io/repos/preaction/Mojolicious-Plugin-Export/badge.svg?branch=master)](https://coveralls.io/r/preaction/Mojolicious-Plugin-Export?branch=master)

# 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"](#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](https://metacpan.org/pod/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](https://metacpan.org/pod/Mojolicious::Command::export), [Mojolicious::Plugin::Export::Git](https://metacpan.org/pod/Mojolicious::Plugin::Export::Git), [Mojolicious::Plugin](https://metacpan.org/pod/Mojolicious::Plugin)

# AUTHOR

Doug Bell

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