Rails Blueimp Gallery

This is a rails implementation of the blueimp gallery. Available here: github.com/blueimp/Gallery

Upgrading to 1.x.x

Starting with 1.0.0 we do not longer include the blueimp gallery js and css anymore.

You will have to load it from a cdn.

HAML:

# app/layouts/application.html.haml
/ Blueimp Gallery CSS
%link{:crossorigin => "anonymous", :href => "https://cdnjs.cloudflare.com/ajax/libs/blueimp-gallery/2.44.0/css/blueimp-gallery.min.css", :integrity => "sha256-Xqlh2kNfwlaYIadGK+AV287kAwoqLxYd+MoOvCykFoc=", :rel => "stylesheet"}/
/ Blueimp Gallery JS
%script{:crossorigin => "anonymous", :integrity => "sha256-Iwpd2qB3c+LqT25lxnW2SI84aABYcOxdz8StYme/fx0=", :src => "https://cdnjs.cloudflare.com/ajax/libs/blueimp-gallery/2.44.0/js/jquery.blueimp-gallery.min.js"}

ERB:

# app/layouts/application.html.erb
<!-- Blueimp Gallery CSS -->
<link crossorigin="anonymous" href="https://cdnjs.cloudflare.com/ajax/libs/blueimp-gallery/2.44.0/css/blueimp-gallery.min.css" integrity="sha256-Xqlh2kNfwlaYIadGK+AV287kAwoqLxYd+MoOvCykFoc=" rel="stylesheet">/</link>
<!-- Blueimp Gallery JS -->
<script crossorigin="anonymous" integrity="sha256-Iwpd2qB3c+LqT25lxnW2SI84aABYcOxdz8StYme/fx0=" src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-gallery/2.44.0/js/jquery.blueimp-gallery.min.js"></script>

Installation

Add it to you Gemfile:

# Gemfile
gem 'rails-blueimp-gallery'

Generate the initializer:

$ rails g blueimp:gallery:install

Add the javascripts to your assets:

# ./app/assets/javascripts/application.js
//= require blueimp-gallery

Add the stylesheets to your assets:

# ./app/assets/stylesheets/application.css
/*
 *= require blueimp-gallery
 */

Add the blueimp gallery JS/CSS from CDN:

HAML:

# app/layouts/application.html.haml
/ Blueimp Gallery CSS
%link{:crossorigin => "anonymous", :href => "https://cdnjs.cloudflare.com/ajax/libs/blueimp-gallery/2.44.0/css/blueimp-gallery.min.css", :integrity => "sha256-Xqlh2kNfwlaYIadGK+AV287kAwoqLxYd+MoOvCykFoc=", :rel => "stylesheet"}/
/ Blueimp Gallery JS
%script{:crossorigin => "anonymous", :integrity => "sha256-Iwpd2qB3c+LqT25lxnW2SI84aABYcOxdz8StYme/fx0=", :src => "https://cdnjs.cloudflare.com/ajax/libs/blueimp-gallery/2.44.0/js/jquery.blueimp-gallery.min.js"}

ERB:

# app/layouts/application.html.erb
<!-- Blueimp Gallery CSS -->
<link crossorigin="anonymous" href="https://cdnjs.cloudflare.com/ajax/libs/blueimp-gallery/2.44.0/css/blueimp-gallery.min.css" integrity="sha256-Xqlh2kNfwlaYIadGK+AV287kAwoqLxYd+MoOvCykFoc=" rel="stylesheet">/</link>
<!-- Blueimp Gallery JS -->
<script crossorigin="anonymous" integrity="sha256-Iwpd2qB3c+LqT25lxnW2SI84aABYcOxdz8StYme/fx0=" src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-gallery/2.44.0/js/jquery.blueimp-gallery.min.js"></script>

Add the helper to your ApplicationController:

# ./app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
  view_helper Blueimp::Gallery::ApplicationViewHelper, as: :blueimp_gallery_helper
end

Add a call to the modal_gallery helper to your layout:

# app/views/layouts/application.html.erb:
<%= blueimp_gallery_helper(self).prepare_modal %>

License

This project rocks and uses MIT-LICENSE.