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
Kazuhiko Shiozaki
gitlab-ce
Commits
1f0e1656
Commit
1f0e1656
authored
Jan 29, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load contribution calendar via AJAX
parent
c9f18d45
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
17 deletions
+32
-17
app/controllers/users_controller.rb
app/controllers/users_controller.rb
+20
-11
app/views/users/calendar.html.haml
app/views/users/calendar.html.haml
+1
-0
app/views/users/show.html.haml
app/views/users/show.html.haml
+8
-2
config/routes.rb
config/routes.rb
+3
-4
No files found.
app/controllers/users_controller.rb
View file @
1f0e1656
class
UsersController
<
ApplicationController
class
UsersController
<
ApplicationController
skip_before_filter
:authenticate_user!
,
only:
[
:show
,
:activities
]
layout
:determine_layout
layout
:determine_layout
def
show
def
show
@user
=
User
.
find_by_username!
(
params
[
:username
])
unless
current_user
||
@user
.
public_profile?
return
authenticate_user!
end
# Projects user can view
# Projects user can view
visible_projects
=
ProjectsFinder
.
new
.
execute
(
current_user
)
visible_projects
=
ProjectsFinder
.
new
.
execute
(
current_user
)
authorized_projects_ids
=
visible_projects
.
pluck
(
:id
)
authorized_projects_ids
=
visible_projects
.
pluck
(
:id
)
...
@@ -25,6 +18,15 @@ class UsersController < ApplicationController
...
@@ -25,6 +18,15 @@ class UsersController < ApplicationController
@title
=
@user
.
name
@title
=
@user
.
name
respond_to
do
|
format
|
format
.
html
format
.
atom
{
render
layout:
false
}
end
end
def
calendar
visible_projects
=
ProjectsFinder
.
new
.
execute
(
current_user
)
# Get user repositories and collect timestamps for commits
# Get user repositories and collect timestamps for commits
user_repositories
=
visible_projects
.
map
(
&
:repository
)
user_repositories
=
visible_projects
.
map
(
&
:repository
)
calendar
=
Gitlab
::
CommitsCalendar
.
new
(
user_repositories
,
@user
)
calendar
=
Gitlab
::
CommitsCalendar
.
new
(
user_repositories
,
@user
)
...
@@ -32,10 +34,7 @@ class UsersController < ApplicationController
...
@@ -32,10 +34,7 @@ class UsersController < ApplicationController
@starting_year
=
(
Time
.
now
-
1
.
year
).
strftime
(
"%Y"
)
@starting_year
=
(
Time
.
now
-
1
.
year
).
strftime
(
"%Y"
)
@starting_month
=
Date
.
today
.
strftime
(
"%m"
).
to_i
@starting_month
=
Date
.
today
.
strftime
(
"%m"
).
to_i
respond_to
do
|
format
|
render
'calendar'
,
layout:
false
format
.
html
format
.
atom
{
render
layout:
false
}
end
end
end
def
determine_layout
def
determine_layout
...
@@ -45,4 +44,14 @@ class UsersController < ApplicationController
...
@@ -45,4 +44,14 @@ class UsersController < ApplicationController
'public_users'
'public_users'
end
end
end
end
private
def
authenticate_user!
@user
=
User
.
find_by_username!
(
params
[
:username
])
unless
current_user
||
@user
.
public_profile?
return
authenticate_user!
end
end
end
end
app/views/users/
_
calendar.html.haml
→
app/views/users/calendar.html.haml
View file @
1f0e1656
%h4
Calendar:
#cal-heatmap
.calendar
#cal-heatmap
.calendar
:javascript
:javascript
new
calendar
(
new
calendar
(
...
...
app/views/users/show.html.haml
View file @
1f0e1656
...
@@ -19,8 +19,9 @@
...
@@ -19,8 +19,9 @@
=
render
'groups'
,
groups:
@groups
=
render
'groups'
,
groups:
@groups
%hr
%hr
%h4
Calendar:
.user-calendar
%div
=
render
'calendar'
%h4
.center.light
%i
.fa.fa-spinner.fa-spin
%hr
%hr
%h4
%h4
User Activity:
User Activity:
...
@@ -36,3 +37,8 @@
...
@@ -36,3 +37,8 @@
=
render
'profile'
,
user:
@user
=
render
'profile'
,
user:
@user
-
if
@projects
.
present?
-
if
@projects
.
present?
=
render
'projects'
,
projects:
@projects
=
render
'projects'
,
projects:
@projects
:coffeescript
$ ->
$(".user-calendar").load("
#{
user_calendar_path
}
")
config/routes.rb
View file @
1f0e1656
...
@@ -157,10 +157,9 @@ Gitlab::Application.routes.draw do
...
@@ -157,10 +157,9 @@ Gitlab::Application.routes.draw do
end
end
end
end
# route for commits used by the cal-heatmap
get
'u/:username/calendar'
=>
'users#calendar'
,
as: :user_calendar
,
get
'u/:username/activities'
=>
'users#activities'
,
as: :user_activities
,
constraints:
{
username:
/(?:[^.]|\.(?!atom$))+/
,
format:
/atom/
}
constraints:
{
username:
/(?:[^.]|\.(?!atom$))+/
,
format:
/atom/
},
via: :get
get
'/u/:username'
=>
'users#show'
,
as: :user
,
get
'/u/:username'
=>
'users#show'
,
as: :user
,
constraints:
{
username:
/(?:[^.]|\.(?!atom$))+/
,
format:
/atom/
}
constraints:
{
username:
/(?:[^.]|\.(?!atom$))+/
,
format:
/atom/
}
...
...
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