App-MojoSlides

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

  - Fix tests failing since Mojolicious 7.0

0.10 2014-05-21
  - Fixed missing dependency in Build.PL

0.09 2014-05-17
  - fixed compatibility with newer Mojolicious version
    - bumped required Mojolicious version to 4.77

0.08 2013-11-10
  - fixed ms_overlay bug preventing more than 9 increments
  - column can now take an array reference of classes

0.07 2013-11-10
  - added finally key for further flexibility
  - added more diagnostics for some Heisenbugs seen on CPANTesters for v0.06

0.06 2013-11-06
  - renamed msOverlay attribute to ms_overlay for case-invariance (html compliance)
  - added "incremental" helper, especially useful for building incrementing lists

0.05 2013-11-05
  - added vspace helper
  - handle msOverlay with a single number correctly
  - added extra_css and extra_js config keys
  - added header_template and footer_template config keys

0.04 2013-11-03
  - Simplified specification of slides in configuration.

README.pod  view on Meta::CPAN

 %= column [3, 'offset-3'] => begin
   column contents
 % end


Creates a div of a given width (a number out of 12, see Bootstrap).
Takes that width and a string or template block, though again, you probably mean block.
To give more than one class, pass an array reference.
Each class is prepended by C<col-md->.

=item overlay

 %= overlay '2-4' => begin
  Stuff to show only on increments 2 through 4
 % end

Creates a div with the attribute C<ms_overlay> which the css/js bits of the system use for incrementing slides.
The syntax of the specification follows LaTeX Beamer, which is like C<2-> to show an item from increment 2 onwards and so on.

N.B. adding C<ms_overlay="2-4"> to nearly any HTML tag will work as expect too!

=item vspace

 %= vspace '50px'
 <div style="min-height: 50px;"></div>

Adds a section of vertical space of a given height.

=back

ex/goodbye.html.ep  view on Meta::CPAN

% title 'Goodbye';

%= p q{That's all folks}
%= overlay '2-' => begin
  %= p '.center' => '(why are you still staring?)'
% end

ex/hello.html.ep  view on Meta::CPAN

% title 'Hello World';

%= row begin
  %= column 6 => begin
    %= p 'Column 1'
  % end
  %= column [6, 'offset-3'] => begin
    %= p 'Column 2'
    %= p ms_overlay => '1-' => 'Overlay 1-'
    %= p ms_overlay => '2-' => 'Overlay 2-'
    %= overlay '3-' => begin
      %= p 'Overlay 3- via helper'
    % end
  % end
% end

lib/App/MojoSlides.pm  view on Meta::CPAN

  $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,
  );

lib/App/MojoSlides.pm  view on Meta::CPAN

 %= column [3, 'offset-3'] => begin
   column contents
 % end


Creates a div of a given width (a number out of 12, see Bootstrap).
Takes that width and a string or template block, though again, you probably mean block.
To give more than one class, pass an array reference.
Each class is prepended by C<col-md->.

=item overlay

 %= overlay '2-4' => begin
  Stuff to show only on increments 2 through 4
 % end

Creates a div with the attribute C<ms_overlay> which the css/js bits of the system use for incrementing slides.
The syntax of the specification follows LaTeX Beamer, which is like C<2-> to show an item from increment 2 onwards and so on.

N.B. adding C<ms_overlay="2-4"> to nearly any HTML tag will work as expect too!

=item vspace

 %= vspace '50px'
 <div style="min-height: 50px;"></div>

Adds a section of vertical space of a given height.

=back

lib/App/MojoSlides/MoreTagHelpers.pm  view on Meta::CPAN


  $text = $text->() if eval { ref $text eq 'CODE' };

  require Mojo::DOM;
  my $dom = Mojo::DOM->new($text);
  my $children = $dom->children;
  if ($children->size == 1) {
    $children = $children->[0]->children;
  }
  $children->each(sub{
    $_->{ms_overlay} = $i++ . '-';
  });

  require Mojo::ByteStream;
  return Mojo::ByteStream->new($dom->to_string);
}
  
1;

__END__

lib/App/MojoSlides/MoreTagHelpers.pm  view on Meta::CPAN

     %= li 'Shown after one click'
   % end
 % end

 %= incremental ul begin
   %= li 'Always shown'
   %= li 'Shown after one click'
 % end

  <ul>
    <li ms_overlay="1-">Always shown</li>
    <li ms_overlay="2-">Shown after one click</li>
  </ul>
  

Adds ms_overlay attributes to a sequence of elements with increasing start number.
Note that if passed an html element which has only one element, the attributes will be applied to the children of that attribute.
Because of this, the two templates above result in the same shown output.

=back

=head1 ELEMENTS

This module wraps lots of the HTML tags (though not all) into helpers.
If the helper gets a first argument that starts with C<#> or C<.>, that argument is parsed like a selector.
Note that only one id (the first) will be used if multiple are given.

lib/App/MojoSlides/files/public/mojoslides.css  view on Meta::CPAN


/* Set the fixed height of the footer here */
#footer {
  height: 60px;
  background-color: #f5f5f5;
}

/* Other styling
-------------------------------------------------- */

[ms_overlay] { display: none }

.center { text-align: center; }

lib/App/MojoSlides/files/public/mojoslides.js  view on Meta::CPAN

    if (current < last) {
      current += 1;
      refreshOverlays()
    } else {
      window.location = next;
    }
  });
}

function findLastOverlay () {
  var all = $('[ms_overlay]').map(function(){ 
    return $(this).attr('ms_overlay').split('-');
  }).map(function(){
    return this.length ? parseInt(this) : null;
  }).toArray();
  return all.sort(function(a,b){return b-a})[0];
}

function getCurrent () {
  var hash = window.location.hash.slice(1);
  if (! hash) {
    return 1;

lib/App/MojoSlides/files/public/mojoslides.js  view on Meta::CPAN

  }
  if (a[1] === ''){
    a[1] = last;
  }
  a[0] = parseInt(a[0]);
  a[1] = parseInt(a[1]);
  return a;
}

function refreshOverlays () {
  $('[ms_overlay]').each(function(){
    spec = parseOverlaySpec($(this).attr('ms_overlay'));
    if ( current >= spec[0] && current <= spec[1] ) {
      $(this).show();
    } else {
      $(this).hide();
    }
  });
}

$(function(){
  last = findLastOverlay();

t/more_tag_helpers.t  view on Meta::CPAN

  ->text_is('div.find #me' => 'Gotcha');

$t->get_ok('/s')
  ->text_is('#foo' => 'hi')
  ->text_is('.baz' => 'hi')
  ->text_is('.bat' => 'hi')
  ->text_is('#foo.baz.bat' => 'hi')
  ->element_exists_not('#bar');

$t->get_ok('/i_parent')
  ->text_is('li[ms_overlay="1-"]' => 'One')->or($diag)
  ->text_is('li[ms_overlay="2-"]' => 'Two')->or($diag);

$t->get_ok('/i_items')
  ->text_is('li[ms_overlay="1-"]' => 'First')->or($diag)
  ->text_is('li[ms_overlay="2-"]' => 'Second')->or($diag);

done_testing;

__DATA__

@@ index.html.ep

%= h2 'Hello World'

%= div class => 'find' => begin



( run in 0.471 second using v1.01-cache-2.11-cpan-49f99fa48dc )