Skip to content

Commit cdf643f

Browse files
committed
Real world example: photo gallery carousel
1 parent 516d693 commit cdf643f

10 files changed

+130
-0
lines changed

lib/dancer_bootstrap_fontawesome_template.pm

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use examples::simple_form;
88
use examples::navbar_login;
99
use examples::tabs;
1010
use examples::show_file;
11+
use examples::photo_carousel;
1112

1213
our $VERSION = '0.1';
1314

lib/examples/photo_carousel.pm

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package examples::photo_carousel;
2+
use Dancer ':syntax';
3+
use strict;
4+
use warnings;
5+
6+
=pod
7+
Example of using Bootstrap's Photo-Carousel component.
8+
9+
NOTE:
10+
The images are stored in "./public/images/gallery",
11+
which is available as "[% request.uri_base %]/images/gallery/" URL.
12+
If you put them in a different location, modify the template accordingly.
13+
=cut
14+
15+
my @photos = (
16+
{
17+
file => "cshl13.jpg",
18+
caption => "Fall",
19+
text => "View from accross Cold Spring Harbor",
20+
},
21+
{
22+
file => "cshl12.jpg",
23+
caption => "Fall",
24+
text => "Cold Spring Harbor Campus",
25+
},
26+
{
27+
file => "cshl11.jpg",
28+
caption => "Winter",
29+
text => "View of the Cold Spring (frozen) harbor",
30+
},
31+
{
32+
file => "cshl3.jpg",
33+
caption => "Summer Dusk",
34+
text => "Cold Spring Harbor",
35+
},
36+
{
37+
file => "cshl6.jpg",
38+
caption => "Spring",
39+
text => "Cold Spring Harbor Campus",
40+
},
41+
{
42+
file => "cshl8.jpg",
43+
caption => "Onley House",
44+
text => "Cold Spring Harbor Campus",
45+
},
46+
);
47+
48+
get '/photo_carousel' => sub {
49+
template 'examples/photo_carousel', { photos => \@photos };
50+
};
51+
52+
true;

public/images/gallery/cshl11.jpg

67.7 KB
Loading

public/images/gallery/cshl12.jpg

81.7 KB
Loading

public/images/gallery/cshl13.jpg

75.6 KB
Loading

public/images/gallery/cshl3.jpg

56.8 KB
Loading

public/images/gallery/cshl6.jpg

118 KB
Loading

public/images/gallery/cshl8.jpg

104 KB
Loading

views/examples/photo_carousel.tt

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<!-- BootStrap NavBar -->
2+
<div class="navbar">
3+
<div class="navbar-inner">
4+
<div class="container">
5+
<h3><a class="brand" href="[% request.uri_base %]"><img src="images/dancer_man.png"> Perl Dancer</a></h3>
6+
</div>
7+
</div>
8+
</div>
9+
10+
<div class="container">
11+
12+
<div class="page-header">
13+
<div class="row">
14+
<div class="span12">
15+
<h2>Dancer + Bootstrap Exapmles<//h2>
16+
<h1>Photo Gallery - Carousel</h1>
17+
</div>
18+
</div>
19+
</div>
20+
21+
<div class="row">
22+
<div class="span12">
23+
Example of using <a target="_blank" href="http://twitter.github.com/bootstrap/javascript.html#carousel">Bootstrap's Carousel</a> with Dancer.
24+
<br/>
25+
<br/>
26+
<br/>
27+
28+
<h3>Code Highlights</h3>
29+
<ul>
30+
<li>The Dancer code is in
31+
<a href="[% request.uri_for("/show_file",file => "photo_carousel.pm", example => "photo carousel", url => request.uri_for("/photo_carousel") ) %]">
32+
<code>./lib/examples/phot_carousel.pm</code> <i class="icon-eye-open"></i> </a>.
33+
</li>
34+
35+
<li>This HTML tempate is in
36+
<a href="[% request.uri_for("/show_file",file => "photo_carousel.tt", example => "photo carousel", url => request.uri_for("/photo_carousel") ) %]">
37+
<code>./views/examples/photo_carousel.tt</code> <i class="icon-eye-open"></i> </a>.
38+
</li>
39+
<li>The photos to display are degined in the <code>@photos</code> variable in the Dancer module.</li>
40+
</ul>
41+
42+
</div>
43+
</div>
44+
45+
<br/>
46+
<br/>
47+
48+
[%#################################
49+
Photo Carousel Example Starts Here
50+
#################################%]
51+
52+
<div class="row">
53+
<h2>Example Photo Carousel</h2>
54+
<p>Enjoy the show!</p>
55+
56+
<div style="max-width: 800px;" class="carousel slide" id="dancing_carousel">
57+
58+
<div class="carousel-inner">
59+
[%### loop over the "photos" list, and create HTML for each photo %]
60+
[% FOREACH photo IN photos %]
61+
<div class="item [% IF loop.index==0 %]active[% END %]">
62+
<img src="[% request.uri_base %]/images/gallery/[% photo.file %]"
63+
alt="[% photo.caption | html %]" />
64+
<div class="carousel-caption">
65+
<h4>[% photo.caption | html %]</h4>
66+
<p>[% photo.text | html %]</p>
67+
</div>
68+
</div>
69+
[% END %]
70+
</div>
71+
72+
<!-- Carousel's Next/Prev buttons -->
73+
<a class="left carousel-control" href="#dancing_carousel" data-slide="prev">&lsaquo;</a>
74+
<a class="right carousel-control" href="#dancing_carousel" data-slide="next">&rsaquo;</a>
75+
</div>
76+
</div>

views/index.tt

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
<li><a href="[% request.uri_for("/simple_form")%]">Simple &lt;FORM&gt; processing</a></li>
8989
<li><a href="[% request.uri_for("/navbar_login")%]">Login form embedded in a NavBar</a></li>
9090
<li><a href="[% request.uri_for("/tabs")%]">Tabs/Pills</a></li>
91+
<li><a href="[% request.uri_for("/photo_carousel")%]">Photo Gallery Carousel</a></li>
9192
</ul>
9293
</div>
9394
</div>

0 commit comments

Comments
 (0)