discourse/plugins/emoji/plugin.rb
Régis Hanol e6e7948617 FEATURE: support for emoji sets
Added following emoji sets
  - Apple/International
  - Emoji One (default)
  - Android/Google
  - Twitter

FIX: translations from plugins weren't properly merged with default translations
FEATURE: new 'site_setting_changed' event
2014-12-11 17:08:47 +01:00

33 lines
1.1 KiB
Ruby

# name: emoji
# about: emoji support for Discourse
# version: 0.2
# authors: Sam Saffron, Robin Ward, Régis Hanol
load File.expand_path('../lib/emoji/engine.rb', __FILE__)
register_asset('javascripts/emoji.js.erb', :server_side)
register_asset('javascripts/emoji-autocomplete.js', :composer)
register_asset('javascripts/discourse/templates/emoji-toolbar.raw.hbs', :composer)
register_asset('javascripts/emoji-toolbar.js', :composer)
register_asset('stylesheets/emoji.css')
def site_setting_saved(site_setting)
return unless site_setting.name.to_s == "emoji_set"
return unless site_setting.value_changed?
before = "/plugins/emoji/images/#{site_setting.value_was}/"
after = "/plugins/emoji/images/#{site_setting.value}/"
Scheduler::Defer.later "Fix Emoji Links" do
Post.exec_sql("UPDATE posts SET cooked = REPLACE(cooked, :before, :after) WHERE cooked LIKE :like",
before: before,
after: after,
like: "%#{before}%"
)
end
end
listen_for(:site_setting_saved)
after_initialize do
# whitelist emojis so that new user can post emojis
Post::white_listed_image_classes << "emoji"
end