9 Star 16 Fork 3

桔子 / perl6doc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
app.pl 1.39 KB
一键复制 编辑 原始数据 按行查看 历史
Zoffix Znet 提交于 2017-05-30 13:38 . Debitrot Mojolicious app
#!/usr/bin/env perl
use File::Spec::Functions 'catfile';
use Mojolicious 7.31;
use Mojolicious::Lite;
use Mojo::File qw/path/;
app->static->paths(['html']);
if ( eval { require Mojolicious::Plugin::AssetPack; 1; } ) {
unless ( eval { require CSS::Sass } ) {
app->log->debug('CSS::Sass not loaded. Relying on `sass` program'
. ' to process SASS');
}
plugin AssetPack => { pipes => [qw/Sass JavaScript Combine/] };
app->asset->process('app.css' => 'sass/style.scss' );
my $style_sheet = catfile qw{html css style.css};
app->log->debug(
"Processing SASS and copying the results over to $style_sheet..."
);
path($style_sheet)->spurt(
app->asset->processed('app.css')->map("content")->join);
app->log->debug('...Done');
}
else {
app->log->debug( 'Install Mojolicious::Plugin::AssetPack to enable SASS'
. ' processor. You will also need CSS::Sass module or have `sass`'
. ' command working'
);
}
app->hook(
before_dispatch => sub {
my $c = shift;
$c->req->url->path( $c->req->url->path =~ s/::/\$COLON\$COLON/gr )
if $c->req->url->path =~ m{^/type/} and $^O =~ m/MSWin/i;
}
);
## ROUTES
get '/' => sub { shift->reply->static('/index.html') };
get '*dir' => sub {
my $self = shift;
( my $dir = $self->param('dir') ) =~ s{/$}{};
$self->reply->static("/$dir.html");
};
app->start;
Perl
1
https://gitee.com/ijz/perl6doc.git
git@gitee.com:ijz/perl6doc.git
ijz
perl6doc
perl6doc
master

搜索帮助