Skip to content

Instantly share code, notes, and snippets.

@frankie-loves-jesus
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankie-loves-jesus/d1be3ccd556a5fe9fef4 to your computer and use it in GitHub Desktop.
Save frankie-loves-jesus/d1be3ccd556a5fe9fef4 to your computer and use it in GitHub Desktop.
Forem with Gemoji
# Gemoji
config.assets.paths << Emoji.images_path
config.assets.precompile << "emoji/*.png"
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
<%#= forem_format(post.text) %>
<%= add_emojify_and_kramdown(post.text) %>
gem 'kramdown'
gem 'gemoji', github: 'github/gemoji'
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