Created
September 25, 2012 18:51
-
-
Save ff6347/3783713 to your computer and use it in GitHub Desktop.
creates img list from folder content for jekyll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #gallery.rb | |
| #jekyll plugin | |
| #this code creates the inner image list for twitter-bootstrap carousel | |
| #found here | |
| #https://groups.google.com/forum/?fromgroups=#!topic/jekyll-rb/Z0LZuPxUsy0 | |
| #http://twitter.github.com/bootstrap/javascript.html#carousel | |
| #needs bootstrap-carousel.js | |
| #needs bootstrap-transition.js | |
| # | |
| # you have to embed it into your files with a yaml front matter like this | |
| # <div id="myCarousel" class="carousel slide"> | |
| # <div class="carousel-inner"> | |
| # {{ '' | gallery }} | |
| # </div> | |
| # <a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a> | |
| # <a class="right carousel-control" href="#myCarousel" data-slide="next">›</a> | |
| # </div> | |
| # | |
| #place your files in assets/images/slideshow/ | |
| #jpg only *.jpg | |
| module Jekyll | |
| module Filters | |
| def gallery(output) | |
| Dir.glob('assets/images/slideshow/*.jpg').each { | |
| |i| output << "<div class=\"item\"> | |
| <img src=\"#{i}\" alt=""> | |
| <div class=\"carousel-caption\"> | |
| <p>#{i}</p> | |
| </div> | |
| </div>" | |
| } | |
| output | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment