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
412ff80b
Commit
412ff80b
authored
Sep 04, 2016
by
Z.J. van de Weg
Committed by
Fatih Acet
Sep 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start Frontend work, fix routing problem
parent
fe043398
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
937 additions
and
11 deletions
+937
-11
app/controllers/concerns/toggle_award_emoji.rb
app/controllers/concerns/toggle_award_emoji.rb
+1
-1
app/controllers/projects/snippets_controller.rb
app/controllers/projects/snippets_controller.rb
+4
-1
app/helpers/award_emoji_helper.rb
app/helpers/award_emoji_helper.rb
+13
-0
app/models/concerns/awardable.rb
app/models/concerns/awardable.rb
+6
-0
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+0
-4
app/models/note.rb
app/models/note.rb
+0
-4
app/views/award_emoji/_awards_block.html.haml
app/views/award_emoji/_awards_block.html.haml
+1
-1
app/views/projects/snippets/show.html.haml
app/views/projects/snippets/show.html.haml
+2
-0
app/views/snippets/show.html.haml
app/views/snippets/show.html.haml
+2
-0
routes.txt
routes.txt
+908
-0
No files found.
app/controllers/concerns/toggle_award_emoji.rb
View file @
412ff80b
...
@@ -10,7 +10,7 @@ module ToggleAwardEmoji
...
@@ -10,7 +10,7 @@ module ToggleAwardEmoji
if
awardable
.
user_can_award?
(
current_user
,
name
)
if
awardable
.
user_can_award?
(
current_user
,
name
)
awardable
.
toggle_award_emoji
(
name
,
current_user
)
awardable
.
toggle_award_emoji
(
name
,
current_user
)
todoable
=
to_todoable
(
awardable
)
todoable
=
to_todoable
(
awardable
)
TodoService
.
new
.
new_award_emoji
(
todoable
,
current_user
)
if
todoable
TodoService
.
new
.
new_award_emoji
(
todoable
,
current_user
)
if
todoable
...
...
app/controllers/projects/snippets_controller.rb
View file @
412ff80b
class
Projects::SnippetsController
<
Projects
::
ApplicationController
class
Projects::SnippetsController
<
Projects
::
ApplicationController
include
ToggleAwardEmoji
before_action
:module_enabled
before_action
:module_enabled
before_action
:snippet
,
only:
[
:show
,
:edit
,
:destroy
,
:update
,
:raw
]
before_action
:snippet
,
only:
[
:show
,
:edit
,
:destroy
,
:update
,
:raw
,
:toggle_award_emoji
]
# Allow read any snippet
# Allow read any snippet
before_action
:authorize_read_project_snippet!
,
except:
[
:new
,
:create
,
:index
]
before_action
:authorize_read_project_snippet!
,
except:
[
:new
,
:create
,
:index
]
...
@@ -80,6 +82,7 @@ class Projects::SnippetsController < Projects::ApplicationController
...
@@ -80,6 +82,7 @@ class Projects::SnippetsController < Projects::ApplicationController
def
snippet
def
snippet
@snippet
||=
@project
.
snippets
.
find
(
params
[
:id
])
@snippet
||=
@project
.
snippets
.
find
(
params
[
:id
])
end
end
alias_method
:awardable
,
:snippet
def
authorize_read_project_snippet!
def
authorize_read_project_snippet!
return
render_404
unless
can?
(
current_user
,
:read_project_snippet
,
@snippet
)
return
render_404
unless
can?
(
current_user
,
:read_project_snippet
,
@snippet
)
...
...
app/helpers/award_emoji_helper.rb
0 → 100644
View file @
412ff80b
module
AwardEmojiHelper
def
toggle_award_url
(
awardable
)
unless
awardable
.
is_a?
(
Snippet
)
return
url_for
([
:toggle_award_emoji
,
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
awardable
])
end
if
awardable
.
is_a?
(
ProjectSnippet
)
toggle_award_emoji_namespace_project_snippet_path
(
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
awardable
)
else
toggle_award_emoji_snippet_url
(
awardable
)
end
end
end
app/models/concerns/awardable.rb
View file @
412ff80b
...
@@ -71,6 +71,12 @@ module Awardable
...
@@ -71,6 +71,12 @@ module Awardable
end
end
end
end
def
user_authored?
(
current_user
)
author
=
self
.
respond_to?
(
:author
)
?
self
.
author
:
self
.
user
author
==
current_user
end
def
awarded_emoji?
(
emoji_name
,
current_user
)
def
awarded_emoji?
(
emoji_name
,
current_user
)
award_emoji
.
where
(
name:
emoji_name
,
user:
current_user
).
exists?
award_emoji
.
where
(
name:
emoji_name
,
user:
current_user
).
exists?
end
end
...
...
app/models/concerns/issuable.rb
View file @
412ff80b
...
@@ -196,10 +196,6 @@ module Issuable
...
@@ -196,10 +196,6 @@ module Issuable
end
end
end
end
def
user_authored?
(
user
)
user
==
author
end
def
subscribed_without_subscriptions?
(
user
)
def
subscribed_without_subscriptions?
(
user
)
participants
(
user
).
include?
(
user
)
participants
(
user
).
include?
(
user
)
end
end
...
...
app/models/note.rb
View file @
412ff80b
...
@@ -223,10 +223,6 @@ class Note < ActiveRecord::Base
...
@@ -223,10 +223,6 @@ class Note < ActiveRecord::Base
end
end
end
end
def
user_authored?
(
user
)
user
==
author
end
def
award_emoji?
def
award_emoji?
can_be_award_emoji?
&&
contains_emoji_only?
can_be_award_emoji?
&&
contains_emoji_only?
end
end
...
...
app/views/award_emoji/_awards_block.html.haml
View file @
412ff80b
-
grouped_emojis
=
awardable
.
grouped_awards
(
with_thumbs:
inline
)
-
grouped_emojis
=
awardable
.
grouped_awards
(
with_thumbs:
inline
)
.awards.js-awards-block
{
class:
(
"hidden"
if
!
inline
&&
grouped_emojis
.
empty?
),
data:
{
award_url:
url_for
([
:toggle_award_emoji
,
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
awardable
]
)
}
}
.awards.js-awards-block
{
class:
(
"hidden"
if
!
inline
&&
grouped_emojis
.
empty?
),
data:
{
award_url:
toggle_award_url
(
awardable
)
}
}
-
awards_sort
(
grouped_emojis
).
each
do
|
emoji
,
awards
|
-
awards_sort
(
grouped_emojis
).
each
do
|
emoji
,
awards
|
%button
.btn.award-control.js-emoji-btn.has-tooltip
{
type:
"button"
,
class:
(
award_active_class
(
awards
,
current_user
)),
data:
{
placement:
"bottom"
,
title:
award_user_list
(
awards
,
current_user
)
}
}
%button
.btn.award-control.js-emoji-btn.has-tooltip
{
type:
"button"
,
class:
(
award_active_class
(
awards
,
current_user
)),
data:
{
placement:
"bottom"
,
title:
award_user_list
(
awards
,
current_user
)
}
}
=
emoji_icon
(
emoji
,
sprite:
false
)
=
emoji_icon
(
emoji
,
sprite:
false
)
...
...
app/views/projects/snippets/show.html.haml
View file @
412ff80b
...
@@ -11,4 +11,6 @@
...
@@ -11,4 +11,6 @@
=
link_to
'Raw'
,
raw_namespace_project_snippet_path
(
@project
.
namespace
,
@project
,
@snippet
),
class:
"btn btn-sm"
,
target:
"_blank"
=
link_to
'Raw'
,
raw_namespace_project_snippet_path
(
@project
.
namespace
,
@project
,
@snippet
),
class:
"btn btn-sm"
,
target:
"_blank"
=
render
'shared/snippets/blob'
=
render
'shared/snippets/blob'
=
render
'award_emoji/awards_block'
,
awardable:
@snippet
,
inline:
true
%div
#notes
=
render
"projects/notes/notes_with_form"
%div
#notes
=
render
"projects/notes/notes_with_form"
app/views/snippets/show.html.haml
View file @
412ff80b
...
@@ -10,3 +10,5 @@
...
@@ -10,3 +10,5 @@
=
clipboard_button
(
clipboard_target:
".blob-content[data-blob-id='
#{
@snippet
.
id
}
']"
)
=
clipboard_button
(
clipboard_target:
".blob-content[data-blob-id='
#{
@snippet
.
id
}
']"
)
=
link_to
'Raw'
,
raw_snippet_path
(
@snippet
),
class:
"btn btn-sm"
,
target:
"_blank"
=
link_to
'Raw'
,
raw_snippet_path
(
@snippet
),
class:
"btn btn-sm"
,
target:
"_blank"
=
render
'shared/snippets/blob'
=
render
'shared/snippets/blob'
=
render
'award_emoji/awards_block'
,
awardable:
@snippet
,
inline:
true
\ No newline at end of file
routes.txt
0 → 100644
View file @
412ff80b
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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