Coder Social home page Coder Social logo

whoteaches / fontawesome-rails-cdn Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cbrito/fontawesome-rails-cdn

0.0 1.0 0.0 349 KB

Ruby gem for dasily adding Font Awesome to your Rails project backed by the Bootstrap CDN.

License: MIT License

Ruby 100.00%

fontawesome-rails-cdn's Introduction

fontawesome-rails-cdn

Easily add Font Awesome to your Rails 3 or 4 project leveraging a CDN.

  • Supports Rails 3.x and 4.x
  • Supports Font Awesome 4.0.3 and 3.2.1

Benefits

  • Offloads loading of the Font Awesome assets from your host, allowing your browser to execute more HTTP requests in parallel so your pages render faster.
  • Leverages the cached copy on a client so your page will load faster if a user already has visited a site using Font Awesome.

Features

  • Support for the latest version of Font Awesome.
  • Falls back to local static assets when running in development mode. (This can be overridden.)

Installation

Gemfile

Update your Gemfile to include this gem:

...
gem 'fontawesome-rails-cdn'

Run bundle install to update your local gems. Restart your Rails server if necessary.

Layout

The gem will add the fontawesome_stylesheet_link_tag helper. Add this to your layout files inside the head section to automatically include.

<!DOCTYPE html>
<html>
  <head>
    ...
    <%= fontawesome_stylesheet_link_tag %>
    ...
  </head>
 ...

Changing Default Behavior

Forcing development mode to use the CDN

You can ensure the development environment follows the same behavior as production by using the force: true parameter in the fontawesome_stylesheet_link_tag.

    <%= fontawesome_stylesheet_link_tag :netdna, force: true %>

Using a specific Font Awesome Version

Passing the version parameter in the fontawesome_stylesheet_link_tag allows you to override the default behavior. If a specific version is not included in the gem, it will be pulled from the CDN even if in development mode.

    <%= fontawesome_stylesheet_link_tag :netdna, version: "3.2.1" %>

Versioning

The gem follows the versioning used by Font Awesome. I.e., the 3.2.1 version of the gem defaults to version 3.2.1 of Font Awesome. the 4.0.3 version of the gem points to the 4.0.3 version of Font Awesome.

All gems can point to a specific version of Font Awesome hosted on the CDN by passing the version option into the fontawesome_stylesheet_link_tag.

    <%= fontawesome_stylesheet_link_tag :netdna, version: "3.2.1" %>

License

(c) 2014 Christopher Brito

MIT License - reference LICENSE file

fontawesome-rails-cdn's People

Contributors

cbrito avatar

Watchers

WT avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.