From 54778d222b7f031237a986bddd5ec4ff96bd517d Mon Sep 17 00:00:00 2001 From: ViditChitkara Date: Fri, 15 Jun 2018 01:29:06 +0530 Subject: [PATCH 1/7] basic emoji autocomplete --- app/assets/javascripts/application.js | 1 + app/helpers/application_helper.rb | 15 ++++++++++++++ app/views/comments/_edit.html.erb | 27 ++++++++++++++++++++++++ app/views/comments/_form.html.erb | 30 ++++++++++++++++++++++++++- config/initializers/assets.rb | 4 +++- 5 files changed, 75 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 7d08ac2406..5d4820ed63 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -51,6 +51,7 @@ //= require short-code-forms/dist/short-code-prompts.js //= require wikis.js //= require chart.js/dist/Chart.js +//= require horsey.js //= require header_footer.js // require turbolinks // Temporarily removed while fixing diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index abf2e74b76..379923753b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -27,6 +27,21 @@ def emojify(content) end if content.present? end + def get_emoji_names + emojis = [] + image_map = Hash.new + Emoji.all.each do |e| + val = ":#{e.name}:" + emojis<<{value: val ,text: e.name} + if e.raw + image_map[e.name] = e.raw + else + image_map[e.name] = %(#$1) + end + end + return {emojis: emojis, image_map: image_map} + end + def feature(title) features = Node.where(type: 'feature', title: title) if !features.empty? diff --git a/app/views/comments/_edit.html.erb b/app/views/comments/_edit.html.erb index 9576cf8e2a..b251108324 100644 --- a/app/views/comments/_edit.html.erb +++ b/app/views/comments/_edit.html.erb @@ -43,6 +43,7 @@ + <%= javascript_include_tag "horsey" %>