You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to integrate Emoji for your Rails project, Twemoji would be a good choice, gemoji is also available. They're all open sourced and free to use if you properly attribute.
Twemoji provides set of Emoji Keywords (Names) like :heart:, :man::skin-tone-2:, :man-woman-boy::
So you can let your users type these keywords and store the simple string in your database instead of storing the real Unicodes which may be troublesome for some database (read: older version of MySQL).
If you want to integrate Emoji for your Rails project, Twemoji would be a good choice, gemoji is also available. They're all open sourced and free to use if you properly attribute.
Twemoji provides set of Emoji Keywords (Names) like
:heart:
,:man::skin-tone-2:
,:man-woman-boy:
:So you can let your users type these keywords and store the simple string in your database instead of storing the real Unicodes which may be troublesome for some database (read: older version of MySQL).
Integrate with Rails
Install Twemoji:
View
And just add a simple View Helper:
Then in where your content contains emoji, apply this view helper:
In the
post.body
that all occurrences of emoji keywords will be replaced into Twemoji image.Twemoji by Twitter provides you scalable SVG images that powered by kind folks from MaxCDN, e.g.:
https://twemoji.maxcdn.com/2/svg/1f60d.svg
PNG is also available of size
72x72
: https://twemoji.maxcdn.com/2/72x72/1f60d.png.Add a little CSS:
and make sure your HTML is unicode-friendly:
Voilà, very simple.
Mailer
In your mailer, you can fallback the SVG images to PNG format by passing in
file_ext
option:Front-end
Provide a json which contains all "emoji name to unicode" mappings for your front-end:
Twemoji gem also provides mappings for SVG and PNG, but they are not loaded by default:
If above data fits your use, you can require and use them:
With this json in place, you can then use a autocomplete JavaScript library to implement the autocomlpete feature:
Twemoji also plays nicely if you implement markdown with html-pipeline.
Add a
EmojiFilter
:and include the
EmojiFilter
in your filter chain:That's bascially all about integrating Twemoji in Rails.
The text was updated successfully, but these errors were encountered: