Skip to content

Commit 2e6664d

Browse files
committed
Use emoji unicode instead of images
1 parent 46efb51 commit 2e6664d

File tree

5 files changed

+9
-42
lines changed

5 files changed

+9
-42
lines changed

Gemfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ PATH
22
remote: .
33
specs:
44
auto_html (2.0.2)
5-
gemoji (~> 2.1)
5+
gemoji (~> 4.0.0.rc2)
66
redcarpet (~> 3.5)
77
rinku (~> 2.0)
88

@@ -11,14 +11,14 @@ GEM
1111
specs:
1212
ast (2.4.2)
1313
diff-lcs (1.4.4)
14-
gemoji (2.1.0)
14+
gemoji (4.0.0.rc3)
1515
parallel (1.21.0)
1616
parser (3.0.3.1)
1717
ast (~> 2.4.1)
1818
rainbow (3.0.0)
1919
rake (13.0.6)
2020
redcarpet (3.5.1)
21-
regexp_parser (2.1.1)
21+
regexp_parser (2.2.0)
2222
rexml (3.2.5)
2323
rinku (2.0.6)
2424
rspec (3.10.0)
@@ -33,7 +33,7 @@ GEM
3333
rspec-mocks (3.10.2)
3434
diff-lcs (>= 1.2.0, < 2.0)
3535
rspec-support (~> 3.10.0)
36-
rspec-support (3.10.2)
36+
rspec-support (3.10.3)
3737
rspec_junit_formatter (0.4.1)
3838
rspec-core (>= 2, < 4, != 2.12.0)
3939
rubocop (1.23.0)
@@ -45,7 +45,7 @@ GEM
4545
rubocop-ast (>= 1.12.0, < 2.0)
4646
ruby-progressbar (~> 1.7)
4747
unicode-display_width (>= 1.4.0, < 3.0)
48-
rubocop-ast (1.13.0)
48+
rubocop-ast (1.14.0)
4949
parser (>= 3.0.1.1)
5050
ruby-progressbar (1.11.0)
5151
unicode-display_width (2.1.0)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ comment_format.call("Hello!\n\n Checkout out my blog: http://rors.org :point_lef
5656

5757
Bellow is the list of bundled filters along with their optional arguments on initialization and their default values.
5858

59-
* `AutoHtml::Emoji`, width: 20, height: 20, asset_root: '/images'
59+
* `AutoHtml::Emoji`
6060
* `AutoHtml::HtmlEscape`
6161
* `AutoHtml::Image`, proxy: nil, alt: nil
6262
* `AutoHtml::Link`, target: nil, rel: nil

auto_html.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
1212
gem.homepage = 'https://github.com/dejan/auto_html'
1313
gem.license = 'MIT'
1414

15-
gem.add_dependency 'gemoji', '~> 2.1'
15+
gem.add_dependency 'gemoji', '~> 4.0.0.rc2'
1616
gem.add_dependency 'redcarpet', '~> 3.5'
1717
gem.add_dependency 'rinku', '~> 2.0'
1818

lib/auto_html/emoji.rb

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,10 @@
55
module AutoHtml
66
# Emoji filter
77
class Emoji
8-
def initialize(asset_root: '/images', width: 20, height: 20)
9-
@asset_root = asset_root
10-
@width = width
11-
@height = height
12-
end
13-
148
def call(text)
159
text.gsub(self.class.emoji_pattern) do
1610
name = Regexp.last_match(1)
17-
alt = ":#{name}:"
18-
html_options = {
19-
src: emoji_url(name),
20-
class: 'emoji',
21-
title: alt,
22-
alt: alt,
23-
height: @width,
24-
witdh: @height,
25-
align: 'absmiddle'
26-
}
27-
TagHelper.tag(:img, html_options)
11+
::Emoji.find_by_alias(name).raw
2812
end
2913
end
3014

@@ -36,19 +20,5 @@ def self.emoji_pattern
3620
def self.emoji_names
3721
::Emoji.all.map(&:aliases).flatten.sort
3822
end
39-
40-
private
41-
42-
def emoji_url(name)
43-
File.join(@asset_root, asset_path(name))
44-
end
45-
46-
def asset_path(name)
47-
File.join('emoji', emoji_filename(name))
48-
end
49-
50-
def emoji_filename(name)
51-
::Emoji.find_by_alias(name).image_filename
52-
end
5323
end
5424
end

spec/auto_html/emoji_spec.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
RSpec.describe AutoHtml::Emoji do
66
it 'converts emoji to HTML' do
7-
expect(subject.call(':joy:')).to eq(
8-
'<img src="/images/emoji/unicode/1f602.png" class="emoji" title=":joy:" '\
9-
'alt=":joy:" height="20" witdh="20" align="absmiddle" />'
10-
)
7+
expect(subject.call(':joy:')).to eq('😂')
118
end
129
end

0 commit comments

Comments
 (0)