How to use Galleria plugin with Rails 4 Pipeline

有些话、适合烂在心里 提交于 2019-12-03 08:00:21

I've just used this in Rails 4.1 as well with Galleria version 1.3.5. Copy the files from the main galleria folder into the various parts. Note that I'm using the classic/default (free) theme.

# app/assets/images
classic-loader.gif
classic-map.png

# app/assets/javascripts
galleria-1.3.5.js
galleria.classic.js

# app/assets/stylesheets (rename with .scss extension)
galleria.classic.css.scss

Open up galleria.classic.js and edit the line css: '...' to be css: false (around line 17 if you don't alter the code).

That's all I had to do in order to get it working with Rails 4. I played around with placing the files in the vendor/assets folders, but that became a nightmare fairly quickly. I found the above solution to be the simplest/cleanest.

Update: 2016-02-02

I'm still using this same setup with a Ruby 2.2.3, Rails 4.2.4, Galleria 1.4.2 setup.

Make sure in your galleria.classic.scss stylesheet you use the image-url("classic-map.png") helpers. No problems with this current setup.

Thank you this was absolutely amazing and exactly what I needed (I wish I'd found this before the 18 hours of hair pulling trying to get this to freaking work)!

I'll add some more things that might be helpful to whomever:

1) I had to change to galleria.css.scss.erb, so that it would interpolate the class-loader like this: background: url(<%= asset_path "/galleria/classic-loader.gif" %>) (not sure why, but the asset_url didn't work for me)

2) Related, I also had to take the classic-map and loader images and put them in app/assets/images

3) Per Galleria, the files I moved were the min.js files, not regular .js

4) In the header of the view, I added:

<script src="<%= asset_path "/galleria-1.3.5.min.js" %>" ></script>
<script src="<%= asset_path "/galleria.flickr.min.js" %>" ></script>
<script src="<%= asset_path "/galleria.classic.min.js" %>" ></script>

5) In the script on each view to load Galleria, I modified their instructions like such:

Galleria.loadTheme("<%= asset_path "/galleria.classic.min.js" %>");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!