Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
52be0404
Commit
52be0404
authored
Sep 16, 2021
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor codebase to use unicode_version from TanukiEmoji
parent
1a1c5adb
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
25 additions
and
2418 deletions
+25
-2418
app/presenters/award_emoji_presenter.rb
app/presenters/award_emoji_presenter.rb
+1
-1
fixtures/emojis/emoji-unicode-version-map.json
fixtures/emojis/emoji-unicode-version-map.json
+0
-2377
lib/gitlab/emoji.rb
lib/gitlab/emoji.rb
+1
-12
lib/tasks/tanuki_emoji.rake
lib/tasks/tanuki_emoji.rake
+19
-16
spec/helpers/emoji_helper_spec.rb
spec/helpers/emoji_helper_spec.rb
+3
-2
spec/lib/gitlab/emoji_spec.rb
spec/lib/gitlab/emoji_spec.rb
+0
-9
spec/presenters/award_emoji_presenter_spec.rb
spec/presenters/award_emoji_presenter_spec.rb
+1
-1
No files found.
app/presenters/award_emoji_presenter.rb
View file @
52be0404
...
...
@@ -16,7 +16,7 @@ class AwardEmojiPresenter < Gitlab::View::Presenter::Delegated
end
def
unicode_version
Gitlab
::
Emoji
.
emoji_unicode_version
(
award_emoji
.
name
)
as_emoji
&
.
unicode_version
end
private
...
...
fixtures/emojis/emoji-unicode-version-map.json
deleted
100644 → 0
View file @
1a1c5adb
This diff is collapsed.
Click to expand it.
lib/gitlab/emoji.rb
View file @
52be0404
...
...
@@ -24,10 +24,6 @@ module Gitlab
TanukiEmoji
.
find_by_codepoints
(
moji
).
image_name
end
def
emoji_unicode_version
(
name
)
emoji_unicode_versions_by_name
[
name
]
end
def
normalize_emoji_name
(
name
)
emojis_aliases
[
name
]
||
name
end
...
...
@@ -58,7 +54,7 @@ module Gitlab
data
=
{
name:
emoji
.
name
,
unicode_version:
emoji
_unicode_version
(
emoji
.
name
)
unicode_version:
emoji
.
unicode_version
}
options
=
{
title:
emoji
.
description
,
data:
data
}.
merge
(
options
)
...
...
@@ -74,12 +70,5 @@ module Gitlab
emoji_image_tag
(
name
,
image_source
).
html_safe
end
end
private
def
emoji_unicode_versions_by_name
@emoji_unicode_versions_by_name
||=
Gitlab
::
Json
.
parse
(
File
.
read
(
Rails
.
root
.
join
(
'fixtures'
,
'emojis'
,
'emoji-unicode-version-map.json'
)))
end
end
end
lib/tasks/tanuki_emoji.rake
View file @
52be0404
...
...
@@ -3,7 +3,7 @@
namespace
:tanuki_emoji
do
desc
'Generates Emoji SHA256 digests'
task
aliases:
%w[environment]
do
task
aliases:
:environment
do
aliases
=
{}
TanukiEmoji
.
index
.
all
.
each
do
|
emoji
|
...
...
@@ -18,12 +18,8 @@ namespace :tanuki_emoji do
end
end
task
digests:
[
'yarn:check'
,
'environment'
]
do
task
digests:
:environment
do
require
'digest/sha2'
require
'json'
# We don't have `node_modules` available in built versions of GitLab
FileUtils
.
cp_r
(
Rails
.
root
.
join
(
'node_modules'
,
'emoji-unicode-version'
,
'emoji-unicode-version-map.json'
),
File
.
join
(
Rails
.
root
,
'fixtures'
,
'emojis'
))
digest_emoji_map
=
{}
emojis_map
=
{}
...
...
@@ -35,7 +31,7 @@ namespace :tanuki_emoji do
category:
emoji
.
category
,
moji:
emoji
.
codepoints
,
description:
emoji
.
description
,
unicodeVersion:
Gitlab
::
Emoji
.
emoji_unicode_version
(
emoji
.
name
)
,
unicodeVersion:
emoji
.
unicode_version
,
digest:
Digest
::
SHA256
.
file
(
emoji_path
).
hexdigest
}
...
...
@@ -46,7 +42,7 @@ namespace :tanuki_emoji do
c:
emoji
.
category
,
e:
emoji
.
codepoints
,
d:
emoji
.
description
,
u:
Gitlab
::
Emoji
.
emoji_unicode_version
(
emoji
.
name
)
u:
emoji
.
unicode_version
}
emojis_map
[
emoji
.
name
]
=
emoji_entry
...
...
@@ -71,7 +67,10 @@ namespace :tanuki_emoji do
# occasionally, such as when new Emojis are added to Gemojione.
task
sprite: :environment
do
begin
require
'mini_magick'
require
'sprite_factory'
# Sprite-Factory still requires rmagick, but maybe could be migrated to support minimagick
# Upstream issue: https://github.com/jakesgordon/sprite-factory/issues/47#issuecomment-929302890
require
'rmagick'
rescue
LoadError
# noop
...
...
@@ -94,7 +93,7 @@ namespace :tanuki_emoji do
TanukiEmoji
.
index
.
all
.
each
do
|
emoji
|
source
=
File
.
join
(
TanukiEmoji
.
images_path
,
emoji
.
image_name
)
destination
=
File
.
join
(
emoji_dir
,
TanukiEmoji
.
name
,
'.png'
)
destination
=
File
.
join
(
emoji_dir
,
"
#{
emoji
.
name
}
.png"
)
FileUtils
.
cp
(
source
,
destination
)
end
...
...
@@ -179,7 +178,7 @@ namespace :tanuki_emoji do
end
def
check_requirements!
return
if
defined?
(
SpriteFactory
)
&&
defined?
(
Magick
)
return
if
defined?
(
Magick
)
puts
<<-
MSG
.
strip_heredoc
This task is disabled by default and should only be run when the TanukiEmoji
...
...
@@ -188,8 +187,12 @@ namespace :tanuki_emoji do
To enable this task, *temporarily* add the following lines to Gemfile and
re-bundle:
gem 'sprite-factory'
gem 'rmagick'
gem 'rmagick', '~> 3.2'
It depends on ImageMagick 6, which can be installed via HomeBrew with:
brew unlink imagemagick
brew install imagemagick@6 && brew link imagemagick@6 --force
MSG
exit
1
...
...
@@ -197,9 +200,9 @@ namespace :tanuki_emoji do
def
resize!
(
image_path
,
size
)
# Resize the image in-place, save it, and free the object
image
=
M
agick
::
Image
.
read
(
image_path
).
first
image
.
resize!
(
size
,
size
)
image
.
write
(
image_path
)
{
self
.
quality
=
100
}
image
.
destroy!
image
=
M
iniMagick
::
Image
.
open
(
image_path
)
image
.
quality
(
100
)
image
.
resize
(
"
#{
size
}
x
#{
size
}
"
)
image
.
write
(
image_path
)
end
end
spec/helpers/emoji_helper_spec.rb
View file @
52be0404
...
...
@@ -6,6 +6,7 @@ RSpec.describe EmojiHelper do
describe
'#emoji_icon'
do
let
(
:options
)
{
{}
}
let
(
:emoji_text
)
{
'rocket'
}
let
(
:emoji_version
)
{
'6.0'
}
let
(
:aria_hidden_option
)
{
"aria-hidden=
\"
true
\"
"
}
subject
{
helper
.
emoji_icon
(
emoji_text
,
options
)
}
...
...
@@ -14,7 +15,7 @@ RSpec.describe EmojiHelper do
is_expected
.
to
include
(
'<gl-emoji'
,
"title=
\"
#{
emoji_text
}
\"
"
,
"data-name=
\"
#{
emoji_text
}
\"
"
,
"data-unicode-version=
\"
#{
::
Gitlab
::
Emoji
.
emoji_unicode_version
(
emoji_text
)
}
\"
"
)
"data-unicode-version=
\"
#{
emoji_version
}
\"
"
)
is_expected
.
not_to
include
(
aria_hidden_option
)
end
...
...
@@ -25,7 +26,7 @@ RSpec.describe EmojiHelper do
is_expected
.
to
include
(
'<gl-emoji'
,
"title=
\"
#{
emoji_text
}
\"
"
,
"data-name=
\"
#{
emoji_text
}
\"
"
,
"data-unicode-version=
\"
#{
::
Gitlab
::
Emoji
.
emoji_unicode_version
(
emoji_text
)
}
\"
"
,
"data-unicode-version=
\"
#{
emoji_version
}
\"
"
,
aria_hidden_option
)
end
end
...
...
spec/lib/gitlab/emoji_spec.rb
View file @
52be0404
...
...
@@ -4,7 +4,6 @@ require 'spec_helper'
RSpec
.
describe
Gitlab
::
Emoji
do
let_it_be
(
:emojis_by_moji
)
{
TanukiEmoji
.
index
.
all
.
index_by
(
&
:codepoints
)
}
let_it_be
(
:emoji_unicode_versions_by_name
)
{
Gitlab
::
Json
.
parse
(
File
.
read
(
Rails
.
root
.
join
(
'fixtures'
,
'emojis'
,
'emoji-unicode-version-map.json'
)))
}
let_it_be
(
:emojis_aliases
)
{
Gitlab
::
Json
.
parse
(
File
.
read
(
Rails
.
root
.
join
(
'fixtures'
,
'emojis'
,
'aliases.json'
)))
}
describe
'.emojis_aliases'
do
...
...
@@ -32,14 +31,6 @@ RSpec.describe Gitlab::Emoji do
end
end
describe
'.emoji_unicode_version'
do
it
'returns emoji unicode version by name'
do
emoji_unicode_version
=
described_class
.
emoji_unicode_version
(
'100'
)
expect
(
emoji_unicode_version
).
to
eq
(
emoji_unicode_versions_by_name
[
'100'
])
end
end
describe
'.normalize_emoji_name'
do
it
'returns same name if not found in aliases'
do
emoji_name
=
described_class
.
normalize_emoji_name
(
'random'
)
...
...
spec/presenters/award_emoji_presenter_spec.rb
View file @
52be0404
...
...
@@ -17,7 +17,7 @@ RSpec.describe AwardEmojiPresenter do
end
describe
'#unicode_version'
do
it
{
expect
(
presenter
.
unicode_version
).
to
eq
Gitlab
::
Emoji
.
emoji_unicode_version
(
emoji_name
)
}
it
{
expect
(
presenter
.
unicode_version
).
to
eq
(
'6.0'
)
}
end
describe
'#emoji'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment