How to use Galleria plugin with Rails 4 Pipeline

前端 未结 2 1871
礼貌的吻别
礼貌的吻别 2021-02-10 05:07

I\'ve recently had a trouble making Galleria plugin work with Rails 4 Pipeline and it took me a while to figure out how to make it work, so I wanted to share the solution in cas

相关标签:
2条回答
  • 2021-02-10 05:59

    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" %>");
    
    0 讨论(0)
  • 2021-02-10 06:02

    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.

    0 讨论(0)
提交回复
热议问题