Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cloud_front_helpers

Package Overview
Dependencies
Maintainers
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloud_front_helpers

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
3
Created
Source

CloudfrontInclude

This gem hooks into ActionView::Helpers::AssetTagHelper and provides some asset tags that will replace a local resource with something hosted on a CDN, like Amazon's CloudFront. This is an easy way to use a CDN in your code with only minor effort on your part. Your users will see greatly reduced load time and you'll see happier users.

Installation

Add this line to your application's Gemfile:

gem 'cloud_front_helpers'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cloud_front_helpers

Setup

Set up an initializer at

./config/initializers/cloud_front_helpers.rb

This initializer should look something like:

AssetTagHelper.configure do |config|
  config.cloud_front_url = "https://YOUR_CDN_URL.cloudfront.net" if Rails.env.production?
end

If no initializer exists, your code will still work but it'll just run like normal (off your asset pipeline).

Usage

Once you've set up your initializer, including CDN assets has never been simpler. We've included helpers for image, styles, and scripts.

<%= cf_image_tag "/images/foo.png" %>
<%= cf_javascript_include_tag "/javascripts/spaceCats.js" %>
<%= cf_stylesheet_link_tag "/stylesheets/bar.css" %>

In addition to these asset tag helpers, we've included a sass extension for your background and background-image tags. In any stylesheet, put something like this:

.whatever {
  background: cf_url("/path/to/some/image.jpg");
}

And that's it!

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

FAQs

Package last updated on 05 Sep 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc