Rails gem for EmojiOne Area https://github.com/mervick/emojionearea
Add this line to your application's Gemfile:
gem 'emojionearea-rails', '~> 3.4.1'
And then execute:
$ bundle
Or install it yourself as:
$ gem install emojionearea-rails
Note : On bundling this gem,
rumoji
,emoji
, andgemojione
gems are also bundled as dependencies.
assets/javascripts/application.js
://= require emojionearea.min
assets/javascripts/emojionearea_init.coffee
:#message_content
selector is id
property for your textarea tag.
$(document).on 'turbolinks:load', ->
$("#message_content").emojioneArea
autoHideFilters: true
events: keypress: (editor, event) ->
if event.which is 13 && !event.shiftKey
$("#message_content").val $('#message_content').data('emojioneArea').getText()
$('#new_message').submit()
$('#message_content').data('emojioneArea').setText ""
event.preventDefault()
return
assets/javascripts/application.js
://= require emojionearea_init
//= require emojionearea.min
assets/stylesheets/application.scss
:@import "emojionearea.min";
config/initializers/asset.rb
:
Rails.application.config.assets.precompile += %w( png_64/* )
views/messages/_form.html.erb
:<%= simple_form_for @message, remote: true do | f | %>
<%= f.input :content, as: :text, label: false, input_html: { class: 'emojionearea', rows: 5 } %>
<%= f.submit class: 'btn btn-outline-primary' %>
<% end %>
gemojify
helper methodAfter bundling this gem, you can use gemojify
helper method out of box. This is for showing all emoji characters graphically in show
action view template.
<div class='message'>
<div class='user'><%= message.user.user_name %> : </div>
<div class='content'>
<%=sanitize gemojify( message.content ) %>
</div>
</div>
gemojione_cdn
helper methodAfter bundling this gem, you can also use gemojione_cdn
helper method out of box. This is to use Gemojione in order to support all emojiones and upgrade to v3.1 cdn in show
action view template.
config/application.rb
:
config.assets.paths << Gemojione.images_path
config.assets.precompile << "emoji/*.png"
Install emoji image library assets:
$ rake gemojione:install_assets
====================================================================
= emoji image assets install
= Target: /Users/user/src/rails-app/app/assets/images/emoji
= Source: /Users/user/src/emoji/assets
====================================================================
- Creating /Users/user/src/rails-app/app/assets/images/emoji...
- Installing assets...
config/initializers/gemojione.rb
:
Gemojione.asset_host = "emoji.cdn.com"
Gemojione.asset_path = '/assets/emoji'
Gemojione.default_size = '64px'
Gemojione.use_svg = true
Gemojione.use_sprite = true
To customize the emojione size,
.emojione {
transform: scale(0.3);
margin: -20px !important;
}
In view file,
<div class='message'>
<div class='user'><%= message.user.user_name %> : </div>
<div class='content'>
<%=sanitize gemojione_cdn( message.content ) %>
</div>
</div>
That's it.
gemojify
helper method add_development_dependency.gemojify
helper to link built-in imagesgemojify_cdn
helper to link cdn imagesgemojify_wp
helper to link wp imagesemojify_code
helper to show emoji text charactersconfig/initializers/asset.rb
:
Rails.application.config.assets.precompile += %w( png_64/* )
gemojify
helper method (removed asset_path)gemojione_cdn
helper method issued by Matias FernandezAfter checking out the repo, run bin/setup
to install dependencies. Then, run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
to create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)