Code Monkey home page Code Monkey logo

rails-env-favicon's Introduction

Rails Env Favicon

Gem Version

Made changes in the code to debug and do not understand what's wrong. Hell, I'm on the debug production! This happened to you? To me several times. Library offers one of the ways to solve this problem.

Most everyone will understand from one picture:

ScreenShot

This means that on the first tab we have development environment, on second stage, and third it's production(we don't need change this favicon).

It uses Tinycon - A small library for manipulating the favicon.

And one more option:

ScreenShot

Icon will be gray on non production environment.

It you need this separately you can use Grayscale-Favicon - adopted for node package managers version.

Js usage for this task justified by the fact that more often than not have to worry about favicon caching, because favicon changes on the fly after it's loaded. However, if you do not like to use js for this problem, you may use alternative version of gem which uses https://github.com/rmagick/rmagick, follow to branch rmagick

Installation

Add this line to your application's Gemfile:

gem 'rails-env-favicon'

And then execute:

$ bundle

Setup:

# adds initializer
rails g rails_env_favicon:install

In your JavaScript manifest (e.g. application.js):

//= require rails_env_favicon

Config

In config/initializers/rails_env_favicon.rb

RailsEnvFavicon.setup do |config|
  # If true then favicon will be gray on non production env
  config.make_grayscale = false
  # or if make_grayscale = false then draw badge on favicon with this options:
  config.text_color = '#ffffff'
  config.background_color = '#549a2f'
end

You can also configure the condition of changing favicon and badge label, just override RailsEnvFavicon module methods. For example:

module RailsEnvFavicon
  def self.badge_label
    ENV['TEATRO'].present? ? 'T' : ::Rails.env.first.upcase
  end

  def self.applicable?
    !::Rails.env.production? || ENV['TEATRO'].present?
  end
end

Issues

  • If you change a configuration to apply changes, you have to:

    • Execute rm -rf tmp/cache/* in app directory, for assets cache cleaning.
    • Restart web server.

Contributing

  1. Fork it ( http://github.com/accessd/rails_env_favicon/fork )
  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

rails-env-favicon's People

Contributors

accessd avatar asiniy avatar hartator avatar khusnetdinov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rails-env-favicon's Issues

Config ignored

I have this in config/initializers/rails_env_favicon.rb

require 'rails-env-favicon'
RailsEnvFavicon.setup do |config|
  config.make_grayscale = true
end

And it continues to be in color with the green "D" badge. I've tried restarting, removing and re-adding the js requires, deleting the js file in Chrome and opening on a new tab.

The js is:

Tinycon.setOptions({
  width: 8,
  height: 9,
  colour: '#ffffff',
  background: '#549a2f',
  fallback: true
});

Tinycon.setBubble("D");

Create middleware

I have an idea to create a middleware instead use js, but need help to prevent caching favicon. That commit 89ac677

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.