Table of Content
Adding swipejs library
How about creating a slideshow in the home page? For slideshow, we will use the SwipeJS library.
Let’s find it at: https://github.com/bradbirdsall/Swipe
Then put the swipe.js in the vendor/assets/javascripts/
folder.
And we need to include it in the application.js
file.
//= require jquery
//= require jquery_ujs
//= require swipe
//= require_tree .
From the SwipeJS doc, we copy and paste the styling to app/assets/stylesheets/pages.css.scss
file.
And then the logic to get it started. pages.js.coffee
file:
It would be best to create a dedicate cropping ratio for our slideshow, so we will add it to our paperclip-based model — photo.rb
file.
has_attached_file :file, styles: {
cover: "1000x600#",
medium: "300x300>",
thumb: "100x100>" },
default_url: "/images/:style/missing.png"
Then we would refresh the cropping thumbnail generation with the paperclip command.
1$ rake paperclip:refresh CLASS=Photo
Now we need some photos for the home page. In the pages controller:
And we can use the following code in view pages/indeb.html.erb
for the related @slide_photos
collection.
Until now, we got a slideshow in the home page.
It is not looking good. What we want is a full layout. In the next session, we will build the entire layout for the gallery.
What’s next? We’re going to take a look at “Building gallery website layout”.