App-MojoSlides
view release on metacpan or search on metacpan
lib/App/MojoSlides.pm view on Meta::CPAN
extra_js => undef,
header_template => 'ms_header',
footer_template => 'ms_footer',
finally => sub {},
},
});
# should this be optional?
$self->include_data_handle_from_file(scalar $self->presentation_file);
$self->plugin('App::MojoSlides::MoreTagHelpers') if $self->config->{more_tag_helpers};
if (my $path = $self->config->{templates}) {
unshift @{ $self->renderer->paths }, ref $path ? @$path : $path;
}
if (my $path = $self->config->{static}) {
unshift @{ $self->static->paths }, ref $path ? @$path : $path;
}
if (my $ppi = $self->config->{ppi}) {
my $args = {};
$args->{src_folder} = $ppi if -d $ppi;
$self->plugin(PPI => $args);
}
$self->helper( prev_slide => sub {
my $c = shift;
return $c->app->slides->prev($c->stash('slide'));
});
$self->helper( next_slide => sub {
my $c = shift;
return $c->app->slides->next($c->stash('slide'));
});
$self->helper( first_slide => sub { shift->app->slides->first } );
$self->helper( last_slide => sub { shift->app->slides->last } );
$self->helper( row => sub { shift->tag( 'div', class => 'row', @_ ) } );
$self->helper( column => \&_column );
$self->helper( overlay => sub { shift->tag( 'div', ms_overlay => shift, @_ ) } );
$self->helper( vspace => sub { shift->tag( 'div', style => "min-height: @{[shift]};" => '') } );
my $r = $self->routes;
$r->any(
'/:slide',
{ slide => $self->slides->first },
[ slide => qr/\b\d+\b/ ],
\&_action,
);
my $finally = $self->config->{finally};
$self->$finally();
}
sub _action {
my $c = shift;
my $slides = $c->app->slides;
my $slide = $slides->template_for($c->stash('slide'))
or return $c->render_not_found;
$c->render($slide, layout => 'basic') || $c->render_not_found;
}
sub _column {
my $c = shift;
my $cols = ref $_[0] ? shift : [ shift ];
my $class = join ' ', map { "col-md-$_" } @$cols;
return $c->tag( div => class => $class, @_ );
}
# hic sunt dracones
sub include_data_handle_from_file {
my ($self, $file) = @_;
require Mojo::Util;
my $string = Mojo::File->new($file)->slurp;
open my $handle, '<', \$string;
while (<$handle>) {
last if /^__DATA__/; # seek to __DATA__
}
state $i = 0;
my $class = 'App::MojoSlides::TextOfFile' . $i++;
{
no strict 'refs';
*{$class.'::DATA'} = $handle;
}
unshift @{ $self->renderer->classes }, $class;
}
1;
__END__
=head1 NAME
App::MojoSlides - DEPRECATED Write your presentations in Perl and Mojolicious!
=head1 SYNOPSIS
$ mojo_slides mypresentation.pl daemon
=head1 DESCRIPTION
This application lets you write presentations using the simple Perlish syntax that
L<Mojo::Template> provides for L<Mojolicious>. It follows a similar model to LaTeX Beamer
in structure and usage, though it is not nearly as full featured.
=head1 WARNING
This software is in alpha form at best. It may eat baby kittens at any moment.
Indeed it never really got better than this, that's why:
=head1 DEPRECATED
This module is now officially deprecated.
I will give it no further effort.
If someone would like to adopt it, please contact me.
=head1 USAGE
( run in 1.488 second using v1.01-cache-2.11-cpan-39bf76dae61 )