# Uriji Emoji Picker
#### Simple integration of emoji picker with your rails application.
[](https://rubygems.org/gems/uriji-emoji-picker)
## Preview
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'uriji_emoji_picker'
```
## Usage
Run command
```bash
rails g uriji_emoji_picker:install
```
It copies emoji images to your `/assets/images` directory
##### Add emoji picker js file
`application.js`
```js
//= require jquery
//= require uriji_emoji_picker
//= require_tree .
```
##### And styles
`application.css`
```css
/*
*= require_tree .
*= require uriji_emoji_picker
*= require bootstrap
*= require_self
*/
```
`application.scss or sass`
```scss
@import 'uriji_emoji_picker'
```
Next step, wrap your text input with css class `emoji-picker-container`
And add data-attribte `data: { emojiable: true }` to your input/text_area.
```erb
<%= f.text_field :title, class: 'form-control', data: { emojiable: true } %>
``` To see emoji in views, wrap your text with helper `emojify`. ```erb <%= emojify(@post.title) %> ``` If you interpolate string, you need to call `html_safe`, because it's another string. ```erb <%= "Post body: #{emojify(@post.body)}".html_safe %> ``` Also, you can render emojis with a javascript helper. ```js emojify(text) ``` ## Emoji Asset Host By default when used with Rails, this gem will inherit Rails configured `Rails.asset_host`. Otherwise, you will need to manually configure the `Emoji.asset_host` as a string URL or a lambda/proc. ```ruby # String URL Emoji.asset_host = 'http://mysite.com' # Custom Host Proc, takes asset path as a param Emoji.asset_host = lambda {|path| path.size % 2 == 0 ? 'http://even.com' : 'http://odd.com'} ``` ## Advices ##### Precompile emoji images in development for fast loading ##### Use github (or your hosting) as a CDN, to serve images. Example: ```ruby # => /initializers/emoji_picker.rb Emoji.asset_host = 'https://raw.githubusercontent.com' Emoji.asset_path = '/ID25/uriji_emoji_picker/master/lib/generators/uriji_emoji_picker/emoji/' ``` That's all! :smiley_cat: ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/uriji/uriji-emoji-picker. ## License The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).