Joshua Peek 6723776d77 Merge pull request #21 from rsenk330/rakefile-desc
Add a description to the emoji rake task.
2012-12-05 05:59:25 -08:00
2012-11-29 11:08:46 -06:00
2012-11-16 13:17:54 -06:00
2012-11-14 17:38:51 -06:00
2012-11-29 11:30:57 -06:00

gemoji

Emoji images and names. See the LICENSE for copyright information.

Installation

Add gemoji to you Gemfile.

gem 'gemoji'

Sync images

Images can be copied to your public directory with rake emoji in your Rails app. This is the recommended approach since the images will be available at a consistent location. This works best with cached formatted user content generated by tools like html-pipeline.

# Rakefile
load 'tasks/emoji.rake'
$ rake emoji

Assets Precompiling

If you must, you can manually add all the images to your asset load path.

# config/application.rb
config.assets.paths << Emoji.images_path

Then have them compiled to public on deploy.

# config/application.rb
config.assets.precompile << "emoji/*.png"

WARNING Since there are a ton of images, just adding the path may slow down other lookups if you aren't using it. Compiling all the emojis on deploy will add overhead to your deploy if even the images haven't changed. Theres just so many more superfluous files to iterate over. Also, the urls will be fingerprinted which many not be ideal for referencing from cached content.

Example Rails Helper

This would allow emojifying content such as: it's raining :cats: and :dogs:!

See the Emoji cheat sheet for more examples.

module EmojiHelper
 def emojify(content)
    h(content).to_str.gsub(/:([a-z0-9\+\-_]+):/) do |match|
      if Emoji.names.include?($1)
        '<img alt="' + $1 + '" height="20" src="' + asset_path("emoji/#{$1}.png") + '" style="vertical-align:middle" width="20" />'
      else
        match
      end
    end.html_safe if content.present?
  end
end
octocat, squirrel, shipit
Copyright (c) 2012 GitHub Inc. All rights reserved.

bowtie, neckbeard
Copyright (c) 2012 37signals, LLC. All rights reserved.

feelsgood, finnadie, goberserk, godmode, hurtrealbad, rage 1-4, suspect
Copyright (c) 2012 id Software. All rights reserved.

trollface
Copyright (c) 2012 whynne@deviantart. All rights reserved.

All other images
Copyright (c) 2012 Apple Inc. All rights reserved.
Description
Emoji library
Readme MIT 45 MiB
Languages
Ruby 85.7%
HTML 9.5%
Shell 4.8%