Skip to content

Commit

Permalink
Merge pull request #66 from phillmv/add-gemoji
Browse files Browse the repository at this point in the history
Added emoji auto complete
  • Loading branch information
phillmv authored Dec 29, 2022
2 parents 72b0cd8 + 155cf0d commit b291e38
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 9 deletions.
15 changes: 8 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ gem 'jbuilder', '~> 2.7'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

gem "commonmarker", '0.23.4'
gem "octicons"
gem "octicons_helper"
gem "html-pipeline"
gem "sanitize", '~> 5.2'
gem "escape_utils", '~> 1.0'
gem 'commonmarker', '0.23.4'
gem 'octicons'
gem 'octicons_helper'
gem 'gemoji'
gem 'html-pipeline'
gem 'sanitize', '~> 5.2'
gem 'escape_utils', '~> 1.0'
gem 'deckar01-task_list'

gem 'whenever'

gem "will_paginate"
gem 'will_paginate'

gem 'icalendar'
gem 'icalendar-recurrence'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ GEM
i18n (>= 1.6, < 2)
ffi (1.11.3)
front_matter_parser (1.0.0)
gemoji (4.0.1)
git (1.7.0)
rchardet (~> 1.8)
globalid (1.0.0)
Expand Down Expand Up @@ -261,6 +262,7 @@ DEPENDENCIES
factory_bot_rails
faker
front_matter_parser
gemoji
git
html-pipeline
icalendar
Expand Down
18 changes: 18 additions & 0 deletions app/controllers/notebooks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ def subjects
render json: response
end

# TODO: test
def emoji
if params[:query]
query = Set.new

if lookup = Emoji.find_by_alias(params[:query])
query << lookup
end

query = query + Emoji.all.find_all { |e| e.name.index(params[:query]) }.take(8).to_set
else
query = Emoji.all.take(8)
end

render json: query.map { |e| {id: e.raw, name: "#{e.raw} #{e.name}"} }
end


def update
if params[:colours]
colour = nil;
Expand Down
4 changes: 4 additions & 0 deletions app/javascript/text_expanding.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ function text_expand_pls(){
fetch_textexpand_menu("_contacts", text, provide)
} else if (key == "[[") {
fetch_textexpand_menu("_subjects", text, provide);
} else if (key == ":") {
fetch_textexpand_menu("_emoji", text, provide);
}
});

Expand All @@ -25,6 +27,8 @@ function text_expand_pls(){
event.detail.value = `@${item.textContent}`
} else if (key == "[[") {
event.detail.value = `[[${item.identifier}]]`
} else if (key == ":") {
event.detail.value = item.identifier
}
});

Expand Down
2 changes: 1 addition & 1 deletion app/views/entries/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

<div class="form-group" style="position: relative;">
<%# <%= form.text_field :subject, class: "form-control input-block mb-2 col-12" %>
<text-expander keys="# @ [[" multiword="[[">
<text-expander keys="# @ [[ :" multiword="[[">
<% if bookmark %>
<%= form.text_area :body, class: "form-control input-block", autofocus: true, "data-paste-markdown" => true %>
<% else %>
Expand Down
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@
get "_tags/", to: "notebooks#tags"
get "_subjects/", to: "notebooks#subjects"
get "_subjects/:query", to: "notebooks#subjects"

get "_emoji/", to: "notebooks#emoji"
get "_emoji/:query", to: "notebooks#emoji"
get "_contacts/:query", to: "notebooks#contacts"
get "_contacts/", to: "notebooks#contacts"

Expand Down
Binary file added vendor/cache/gemoji-4.0.1.gem
Binary file not shown.

0 comments on commit b291e38

Please sign in to comment.