2013-11-19 22:38:21 -05:00
|
|
|
# name: emoji
|
|
|
|
# about: emoji support for Discourse
|
2014-12-11 11:08:47 -05:00
|
|
|
# version: 0.2
|
|
|
|
# authors: Sam Saffron, Robin Ward, Régis Hanol
|
|
|
|
|
|
|
|
load File.expand_path('../lib/emoji/engine.rb', __FILE__)
|
2013-11-19 22:38:21 -05:00
|
|
|
|
|
|
|
register_asset('javascripts/emoji.js.erb', :server_side)
|
2014-12-07 20:51:13 -05:00
|
|
|
register_asset('javascripts/emoji-autocomplete.js', :composer)
|
2014-12-09 01:22:54 -05:00
|
|
|
register_asset('javascripts/discourse/templates/emoji-toolbar.raw.hbs', :composer)
|
2014-12-07 20:51:13 -05:00
|
|
|
register_asset('javascripts/emoji-toolbar.js', :composer)
|
2013-11-19 22:38:21 -05:00
|
|
|
register_asset('stylesheets/emoji.css')
|
2013-12-12 10:42:27 -05:00
|
|
|
|
2014-12-11 11:08:47 -05:00
|
|
|
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
|
2013-12-12 10:42:27 -05:00
|
|
|
|
2014-12-11 11:08:47 -05:00
|
|
|
listen_for(:site_setting_saved)
|
|
|
|
|
|
|
|
after_initialize do
|
2013-12-12 10:42:27 -05:00
|
|
|
# whitelist emojis so that new user can post emojis
|
|
|
|
Post::white_listed_image_classes << "emoji"
|
|
|
|
end
|