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
Boxiang Sun
gitlab-ce
Commits
2029be03
Commit
2029be03
authored
Dec 11, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'emoji_aliases' into 'master'
Emoji aliases problem Fixes #3850 See merge request !2064
parents
cd97dba2
72b7d1f5
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
3 deletions
+55
-3
CHANGELOG
CHANGELOG
+1
-0
app/assets/javascripts/awards_handler.coffee
app/assets/javascripts/awards_handler.coffee
+6
-1
app/models/note.rb
app/models/note.rb
+2
-1
app/views/votes/_votes_block.html.haml
app/views/votes/_votes_block.html.haml
+2
-1
lib/award_emoji.rb
lib/award_emoji.rb
+35
-0
spec/models/note_spec.rb
spec/models/note_spec.rb
+9
-0
No files found.
CHANGELOG
View file @
2029be03
...
...
@@ -43,6 +43,7 @@ v 8.3.0 (unreleased)
- Prevent possible XSS attack with award-emoji
- Upgraded Sidekiq to 4.x
- Accept COPYING,COPYING.lesser, and licence as license file (Zeger-Jan van de Weg)
- Fix emoji aliases problem
v 8.2.3
- Fix application settings cache not expiring after changes (Stan Hu)
...
...
app/assets/javascripts/awards_handler.coffee
View file @
2029be03
class
@
AwardsHandler
constructor
:
(
@
post_emoji_url
,
@
noteable_type
,
@
noteable_id
)
->
constructor
:
(
@
post_emoji_url
,
@
noteable_type
,
@
noteable_id
,
@
aliases
)
->
addAward
:
(
emoji
)
->
emoji
=
@
normilizeEmojiName
(
emoji
)
@
postEmoji
emoji
,
=>
@
addAwardToEmojiBar
(
emoji
)
addAwardToEmojiBar
:
(
emoji
,
custom_path
=
''
)
->
emoji
=
@
normilizeEmojiName
(
emoji
)
if
@
exist
(
emoji
)
if
@
isActive
(
emoji
)
@
decrementCounter
(
emoji
)
...
...
@@ -94,3 +96,6 @@ class @AwardsHandler
$
(
'body, html'
).
animate
({
scrollTop
:
$
(
'.awards'
).
offset
().
top
-
80
},
200
)
normilizeEmojiName
:
(
emoji
)
->
@
aliases
[
emoji
]
||
emoji
app/models/note.rb
View file @
2029be03
...
...
@@ -377,6 +377,7 @@ class Note < ActiveRecord::Base
end
def
award_emoji_name
note
.
match
(
Gitlab
::
Markdown
::
EmojiFilter
.
emoji_pattern
)[
1
]
original_name
=
note
.
match
(
Gitlab
::
Markdown
::
EmojiFilter
.
emoji_pattern
)[
1
]
AwardEmoji
.
normilize_emoji_name
(
original_name
)
end
end
app/views/votes/_votes_block.html.haml
View file @
2029be03
...
...
@@ -19,7 +19,8 @@
post_emoji_url = "
#{
award_toggle_namespace_project_notes_path
(
@project
.
namespace
,
@project
)
}
"
noteable_type = "
#{
votable
.
class
.
name
.
underscore
}
"
noteable_id = "
#{
votable
.
id
}
"
window.awards_handler = new AwardsHandler(post_emoji_url, noteable_type, noteable_id)
aliases =
#{
AwardEmoji
::
ALIASES
.
to_json
}
window.awards_handler = new AwardsHandler(post_emoji_url, noteable_type, noteable_id, aliases)
$(".awards-menu li").click (e)->
emoji = $(this).data("emoji")
...
...
lib/award_emoji.rb
View file @
2029be03
...
...
@@ -6,7 +6,42 @@ class AwardEmoji
"ambulance"
,
"anguished"
,
"two_hearts"
,
"wink"
]
ALIASES
=
{
pout:
"rage"
,
satisfied:
"laughing"
,
hankey:
"shit"
,
poop:
"shit"
,
collision:
"boom"
,
thumbsup:
"+1"
,
thumbsdown:
"-1"
,
punch:
"facepunch"
,
raised_hand:
"hand"
,
running:
"runner"
,
ng_woman:
"no_good"
,
shoe:
"mans_shoe"
,
tshirt:
"shirt"
,
honeybee:
"bee"
,
flipper:
"dolphin"
,
paw_prints:
"feet"
,
waxing_gibbous_moon:
"moon"
,
telephone:
"phone"
,
knife:
"hocho"
,
envelope:
"email"
,
pencil:
"memo"
,
open_book:
"book"
,
sailboat:
"boat"
,
red_car:
"car"
,
lantern:
"izakaya_lantern"
,
uk:
"gb"
,
heavy_exclamation_mark:
"exclamation"
,
squirrel:
"shipit"
}.
with_indifferent_access
def
self
.
path_to_emoji_image
(
name
)
"emoji/
#{
Emoji
.
emoji_filename
(
name
)
}
.png"
end
def
self
.
normilize_emoji_name
(
name
)
ALIASES
[
name
]
||
name
end
end
spec/models/note_spec.rb
View file @
2029be03
...
...
@@ -159,4 +159,13 @@ describe Note, models: true do
expect
(
note
.
editable?
).
to
be_falsy
end
end
describe
"set_award!"
do
let
(
:issue
)
{
create
:issue
}
it
"converts aliases to actual name"
do
note
=
create
:note
,
note:
":thumbsup:"
,
noteable:
issue
expect
(
note
.
reload
.
note
).
to
eq
(
"+1"
)
end
end
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