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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
96cbad23
Commit
96cbad23
authored
Mar 06, 2017
by
Eric Eastwood
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix up @DouweM review
parent
f602efea
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
38 deletions
+38
-38
app/assets/javascripts/copy_as_gfm.js
app/assets/javascripts/copy_as_gfm.js
+3
-0
app/models/concerns/awardable.rb
app/models/concerns/awardable.rb
+1
-1
db/fixtures/development/15_award_emoji.rb
db/fixtures/development/15_award_emoji.rb
+1
-1
lib/gitlab/award_emoji.rb
lib/gitlab/award_emoji.rb
+0
-15
lib/gitlab/emoji.rb
lib/gitlab/emoji.rb
+23
-5
lib/tasks/gemojione.rake
lib/tasks/gemojione.rake
+10
-12
spec/lib/gitlab/award_emoji_spec.rb
spec/lib/gitlab/award_emoji_spec.rb
+0
-4
No files found.
app/assets/javascripts/copy_as_gfm.js
View file @
96cbad23
...
@@ -46,6 +46,9 @@ require('./lib/utils/common_utils');
...
@@ -46,6 +46,9 @@ require('./lib/utils/common_utils');
},
},
},
},
EmojiFilter
:
{
EmojiFilter
:
{
'
img.emoji
'
(
el
,
text
)
{
return
el
.
getAttribute
(
'
alt
'
);
},
'
gl-emoji
'
(
el
,
text
)
{
'
gl-emoji
'
(
el
,
text
)
{
return
`:
${
el
.
getAttribute
(
'
data-name
'
)}
:`
;
return
`:
${
el
.
getAttribute
(
'
data-name
'
)}
:`
;
},
},
...
...
app/models/concerns/awardable.rb
View file @
96cbad23
...
@@ -101,6 +101,6 @@ module Awardable
...
@@ -101,6 +101,6 @@ module Awardable
private
private
def
normalize_name
(
name
)
def
normalize_name
(
name
)
Gitlab
::
Award
Emoji
.
normalize_emoji_name
(
name
)
Gitlab
::
Emoji
.
normalize_emoji_name
(
name
)
end
end
end
end
db/fixtures/development/15_award_emoji.rb
View file @
96cbad23
require
'./spec/support/sidekiq'
require
'./spec/support/sidekiq'
Gitlab
::
Seeder
.
quiet
do
Gitlab
::
Seeder
.
quiet
do
emoji
=
Gitlab
::
Award
Emoji
.
emojis
.
keys
emoji
=
Gitlab
::
Emoji
.
emojis
.
keys
Issue
.
order
(
Gitlab
::
Database
.
random
).
limit
(
Issue
.
count
/
2
).
each
do
|
issue
|
Issue
.
order
(
Gitlab
::
Database
.
random
).
limit
(
Issue
.
count
/
2
).
each
do
|
issue
|
project
=
issue
.
project
project
=
issue
.
project
...
...
lib/gitlab/award_emoji.rb
deleted
100644 → 0
View file @
f602efea
module
Gitlab
class
AwardEmoji
def
self
.
normalize_emoji_name
(
name
)
aliases
[
name
]
||
name
end
def
self
.
emojis
Gitlab
::
Emoji
.
emojis
end
def
self
.
aliases
Gitlab
::
Emoji
.
emojis_aliases
end
end
end
lib/gitlab/emoji.rb
View file @
96cbad23
module
Gitlab
module
Gitlab
module
Emoji
module
Emoji
extend
self
extend
self
@emoji_unicode_version
=
JSON
.
parse
(
File
.
read
(
File
.
absolute_path
(
File
.
dirname
(
__FILE__
)
+
'/../../node_modules/emoji-unicode-version/emoji-unicode-version-map.json'
)))
@emoji_aliases
=
JSON
.
parse
(
File
.
read
(
File
.
join
(
Rails
.
root
,
'fixtures'
,
'emojis'
,
'aliases.json'
)))
def
emojis
def
emojis
Gemojione
.
index
.
instance_variable_get
(
:@emoji_by_name
)
Gemojione
.
index
.
instance_variable_get
(
:@emoji_by_name
)
...
@@ -21,7 +19,7 @@ module Gitlab
...
@@ -21,7 +19,7 @@ module Gitlab
end
end
def
emojis_aliases
def
emojis_aliases
@emoji_aliases
@emoji_aliases
||=
JSON
.
parse
(
File
.
read
(
Rails
.
root
.
join
(
'fixtures'
,
'emojis'
,
'aliases.json'
)))
end
end
def
emoji_filename
(
name
)
def
emoji_filename
(
name
)
...
@@ -33,7 +31,12 @@ module Gitlab
...
@@ -33,7 +31,12 @@ module Gitlab
end
end
def
emoji_unicode_version
(
name
)
def
emoji_unicode_version
(
name
)
@emoji_unicode_version
[
name
]
@emoji_unicode_versions_by_name
||=
JSON
.
parse
(
File
.
read
(
Rails
.
root
.
join
(
'node_modules'
,
'emoji-unicode-version'
,
'emoji-unicode-version-map.json'
)))
@emoji_unicode_versions_by_name
[
name
]
end
def
normalize_emoji_name
(
name
)
emojis_aliases
[
name
]
||
name
end
end
def
emoji_image_tag
(
name
,
src
)
def
emoji_image_tag
(
name
,
src
)
...
@@ -46,7 +49,22 @@ module Gitlab
...
@@ -46,7 +49,22 @@ module Gitlab
emoji_info
=
emojis
[
emoji_name
]
emoji_info
=
emojis
[
emoji_name
]
emoji_fallback_image_source
=
ActionController
::
Base
.
helpers
.
url_to_image
(
"emoji/
#{
emoji_info
[
'name'
]
}
.png"
)
emoji_fallback_image_source
=
ActionController
::
Base
.
helpers
.
url_to_image
(
"emoji/
#{
emoji_info
[
'name'
]
}
.png"
)
emoji_fallback_sprite_class
=
"emoji-
#{
emoji_name
}
"
emoji_fallback_sprite_class
=
"emoji-
#{
emoji_name
}
"
"<gl-emoji
#{
force_fallback
&&
sprite
?
"class='emoji-icon
#{
emoji_fallback_sprite_class
}
'"
:
""
}
data-name='
#{
emoji_name
}
'
#{
image
?
"data-fallback-src='
#{
emoji_fallback_image_source
}
'"
:
""
}
#{
sprite
?
"data-fallback-sprite-class='
#{
emoji_fallback_sprite_class
}
'"
:
""
}
data-unicode-version='
#{
emoji_unicode_version
(
emoji_name
)
}
'>
#{
force_fallback
&&
sprite
===
false
?
emoji_image_tag
(
emoji_name
,
emoji_fallback_image_source
)
:
emoji_info
[
'moji'
]
}
</gl-emoji>"
data
=
{
name:
emoji_name
,
unicode_version:
emoji_unicode_version
(
emoji_name
)
}
data
[
:fallback_src
]
=
emoji_fallback_image_source
if
image
data
[
:fallback_sprite_class
]
=
emoji_fallback_sprite_class
if
sprite
ActionController
::
Base
.
helpers
.
content_tag
'gl-emoji'
,
class:
(
"emoji-icon
#{
emoji_fallback_sprite_class
}
"
if
force_fallback
&&
sprite
),
data:
data
do
if
force_fallback
&&
!
sprite
emoji_image_tag
(
emoji_name
,
emoji_fallback_image_source
)
else
emoji_info
[
'moji'
]
end
end
end
end
end
end
end
end
lib/tasks/gemojione.rake
View file @
96cbad23
...
@@ -7,7 +7,7 @@ namespace :gemojione do
...
@@ -7,7 +7,7 @@ namespace :gemojione do
dir
=
Gemojione
.
images_path
dir
=
Gemojione
.
images_path
resultant_emoji_map
=
{}
resultant_emoji_map
=
{}
Gitlab
::
Emoji
.
emojis
.
map
do
|
name
,
emoji_hash
|
Gitlab
::
Emoji
.
emojis
.
each
do
|
name
,
emoji_hash
|
# Ignore aliases
# Ignore aliases
unless
Gitlab
::
Emoji
.
emojis_aliases
.
key?
(
name
)
unless
Gitlab
::
Emoji
.
emojis_aliases
.
key?
(
name
)
fpath
=
File
.
join
(
dir
,
"
#{
emoji_hash
[
'unicode'
]
}
.png"
)
fpath
=
File
.
join
(
dir
,
"
#{
emoji_hash
[
'unicode'
]
}
.png"
)
...
@@ -56,11 +56,11 @@ namespace :gemojione do
...
@@ -56,11 +56,11 @@ namespace :gemojione do
SPRITESHEET_HEIGHT
=
840
SPRITESHEET_HEIGHT
=
840
# Setup a map to rename image files
# Setup a map to rename image files
emoji_un
c
icode_string_to_name_map
=
{}
emoji_unicode_string_to_name_map
=
{}
Gitlab
::
Emoji
.
emojis
.
map
do
|
name
,
emoji_hash
|
Gitlab
::
Emoji
.
emojis
.
each
do
|
name
,
emoji_hash
|
# Ignore aliases
# Ignore aliases
unless
Gitlab
::
Emoji
.
emojis_aliases
.
key?
(
name
)
unless
Gitlab
::
Emoji
.
emojis_aliases
.
key?
(
name
)
emoji_un
c
icode_string_to_name_map
[
emoji_hash
[
'unicode'
]]
=
name
emoji_unicode_string_to_name_map
[
emoji_hash
[
'unicode'
]]
=
name
end
end
end
end
...
@@ -69,11 +69,9 @@ namespace :gemojione do
...
@@ -69,11 +69,9 @@ namespace :gemojione do
FileUtils
.
rm_rf
(
emoji_dir
)
FileUtils
.
rm_rf
(
emoji_dir
)
FileUtils
.
mkdir_p
(
emoji_dir
,
mode:
0700
)
FileUtils
.
mkdir_p
(
emoji_dir
,
mode:
0700
)
FileUtils
.
cp_r
(
File
.
join
(
Gemojione
.
images_path
,
'.'
),
emoji_dir
)
FileUtils
.
cp_r
(
File
.
join
(
Gemojione
.
images_path
,
'.'
),
emoji_dir
)
Dir
.
chdir
(
emoji_dir
)
do
Dir
[
File
.
join
(
emoji_dir
,
"**/*.png"
)].
each
do
|
png
|
Dir
[
"**/*.png"
].
each
do
|
png
|
image_path
=
png
image_path
=
File
.
join
(
Dir
.
pwd
,
png
)
rename_to_named_emoji_image!
(
emoji_unicode_string_to_name_map
,
image_path
)
rename_to_named_emoji_image!
(
emoji_uncicode_string_to_name_map
,
image_path
)
end
end
end
Dir
.
mktmpdir
do
|
tmpdir
|
Dir
.
mktmpdir
do
|
tmpdir
|
...
@@ -181,18 +179,18 @@ namespace :gemojione do
...
@@ -181,18 +179,18 @@ namespace :gemojione do
end
end
EMOJI_IMAGE_PATH_RE
=
/(.*?)(([0-9a-f]-?)+)\.png$/i
EMOJI_IMAGE_PATH_RE
=
/(.*?)(([0-9a-f]-?)+)\.png$/i
def
rename_to_named_emoji_image!
(
emoji_un
c
icode_string_to_name_map
,
image_path
)
def
rename_to_named_emoji_image!
(
emoji_unicode_string_to_name_map
,
image_path
)
# Rename file from unicode to emoji name
# Rename file from unicode to emoji name
matches
=
EMOJI_IMAGE_PATH_RE
.
match
(
image_path
)
matches
=
EMOJI_IMAGE_PATH_RE
.
match
(
image_path
)
preceding_path
=
matches
[
1
]
preceding_path
=
matches
[
1
]
unicode_string
=
matches
[
2
]
unicode_string
=
matches
[
2
]
name
=
emoji_un
c
icode_string_to_name_map
[
unicode_string
]
name
=
emoji_unicode_string_to_name_map
[
unicode_string
]
if
name
if
name
new_png_path
=
File
.
join
(
preceding_path
,
"
#{
name
}
.png"
)
new_png_path
=
File
.
join
(
preceding_path
,
"
#{
name
}
.png"
)
FileUtils
.
mv
(
image_path
,
new_png_path
)
FileUtils
.
mv
(
image_path
,
new_png_path
)
new_png_path
new_png_path
else
else
puts
"Warning: emoji_un
c
icode_string_to_name_map missing entry for
#{
unicode_string
}
. Full path:
#{
image_path
}
"
puts
"Warning: emoji_unicode_string_to_name_map missing entry for
#{
unicode_string
}
. Full path:
#{
image_path
}
"
end
end
end
end
end
end
spec/lib/gitlab/award_emoji_spec.rb
deleted
100644 → 0
View file @
f602efea
require
'spec_helper'
describe
Gitlab
::
AwardEmoji
do
end
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