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
- Host: GitHub
- URL: https://github.com/preaction/mojolicious-plugin-export
- Owner: preaction
- License: other
- Created: 2018-11-07T06:33:58.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-03-21T20:45:28.000Z (over 5 years ago)
- Last Synced: 2024-04-17T21:17:02.577Z (about 2 years ago)
- Language: Raku
- Homepage:
- Size: 59.6 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.mkdn
- Changelog: CHANGES
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/preaction/Mojolicious-Plugin-Export)
[](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.