如何在Rails 4 Pipeline中使用Galleria插件 [英] How to use Galleria plugin with Rails 4 Pipeline

查看:97
本文介绍了如何在Rails 4 Pipeline中使用Galleria插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在使Galleria插件与Rails 4 Pipeline一起使用时遇到了麻烦,花了我一段时间才弄清楚如何使其工作,所以我想分享解决方案,以防有人遇到类似问题.

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 case somebody has the similar problem.

1)下载插件后,将galleria-1.3.3.js(这是我写这篇文章时的当前版本)和galleria.classic.js(或其他样式js文件)放入vendor/assets/javascripts

1) After downloading the plugin, put galleria-1.3.3.js ( it's the current version on the day I write it ) and galleria.classic.js ( or other style js file ) to vendor/assets/javascripts

2)将galleria.classic.css(或其他主题样式表)放入vendor/assets/stylesheets

2) Put galleria.classic.css ( or other theme stylesheet) to vendor/assets/stylesheets

3)将//= require galleria-1.3.3//= require galleria.classic添加到application.js文件中,并将*= require galleria.classic添加到application.css文件中

3)Add //= require galleria-1.3.3 and //= require galleria.classic to your application.js file and *= require galleria.classic to application.css file

4)资产管道将指纹添加到图像,这使得很难通过普通的CSS访问它们,因此需要将"scss"添加到您的Galleria样式表中,例如galleria.classic.css.scss并将url(classic-map.png)更改为与第二张图片相同.

4) Asset pipeline adds fingerprints to the images and that makes it difficult to access them via usual css, so it's needed to add 'scss' to your galleria stylesheet, like this galleria.classic.css.scss and change url(classic-map.png) to asset_url("classic-map.png");and the same with the second image.

5)打开galleria.classic.js文件,在其中找到css:"galleria.classic.css"或类似名称,然后将其更改为css: false

5)Open galleria.classic.js file and find there css:"galleria.classic.css" or something like that, and change it to css: false

6)现在,您只需要在某些js文件中添加Galleria.run('#galleria');或其他元素的其他内容即可,这应该可以:)

6) Now you just need to add Galleria.run('#galleria'); or something different for other elements in some js file` and that should work :)

PS,我是Rails的菜鸟,可能犯了一些愚蠢的错误,但我希望这对任何人都有用:)

PS I am a noob in Rails and might have made some foolish mistakes, but I hope this will be helpful for anybody :)

推荐答案

我刚刚在Rails 4.1和Galleria版本1.3.5中使用了它.将文件从主Galleria文件夹复制到各个部分.请注意,我使用的是经典/默认(免费)主题.

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

打开galleria.classic.js并将css: '...'行编辑为css: false(如果不更改代码,则在第17行附近).

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

我要做的就是让它与Rails 4一起工作.我将文件放置在vendor/assets文件夹中,但是很快就变成了噩梦.我发现上述解决方案是最简单/最干净的.

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.

更新时间:2016-02-02

我仍然在Ruby 2.2.3,Rails 4.2.4,Galleria 1.4.2设置中使用相同的设置.

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

确保在galleria.classic.scss样式表中使用image-url("classic-map.png")帮助器.当前的设置没有问题.

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

这篇关于如何在Rails 4 Pipeline中使用Galleria插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆