Last active
August 29, 2015 14:05
-
-
Save frankie-loves-jesus/d1be3ccd556a5fe9fef4 to your computer and use it in GitHub Desktop.
Forem with Gemoji
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gemoji | |
config.assets.paths << Emoji.images_path | |
config.assets.precompile << "emoji/*.png" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def add_emojify_and_kramdown(text) | |
raw(Kramdown::Document.new(emojify(text)).to_html) | |
end | |
def emojify(text) | |
h(text).to_str.gsub(/:([a-z0-9\+\-_]+):/) do |match| | |
if emoji = Emoji.find_by_alias($1) | |
# Insert emojis as Kramdown links | |
# http://kramdown.gettalong.org/syntax.html#images | |
'![' + $1 + '](' + asset_path("emoji/#{emoji.image_filename}") + ')' | |
else | |
match | |
end | |
end.html_safe if text.present? | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%#= forem_format(post.text) %> | |
<%= add_emojify_and_kramdown(post.text) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'kramdown' | |
gem 'gemoji', github: 'github/gemoji' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Forem::Category.create!(:name => 'General') | |
user = User.create( | |
:email => "admin@example.com", | |
:password => "admin1234" | |
) | |
user.forem_admin = true | |
user.save! | |
user.update_attribute(:forem_state, 'approved') | |
unless user.nil? | |
forum = Forem::Forum.create(:category_id => Forem::Category.first.id, :name => "Default", :description => "Default forem created by install") | |
topic1 = forum.topics.build({ :subject => "Apples", :posts_attributes => [:text => "Eat apples :smile:"] }) | |
topic1.user = user | |
topic1.save! | |
topic2 = forum.topics.build({ :subject => "Bananas", :posts_attributes => [:text => "Eat bananas :smile:"] }) | |
topic2.user = user | |
topic2.save! | |
topic3 = forum.topics.build({ :subject => "Oranges", :posts_attributes => [:text => "Eat oranges :smile:"] }) | |
topic3.user = user | |
topic3.save! | |
topic4 = forum.topics.build({ :subject => "Mangos", :posts_attributes => [:text => "Eat mangos :smile:"] }) | |
topic4.user = user | |
topic4.save! | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment