BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
152a6b86
Commit
152a6b86
authored
Jan 29, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'calendar-via-ajax' into 'master'
User contribution calendar via ajax See merge request !1451
parents
c9f18d45
08582f15
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
22 deletions
+39
-22
users_controller.rb
app/controllers/users_controller.rb
+22
-11
calendar.html.haml
app/views/users/calendar.html.haml
+1
-0
show.html.haml
app/views/users/show.html.haml
+8
-2
routes.rb
config/routes.rb
+3
-4
users_controller_spec.rb
spec/controllers/users_controller_spec.rb
+5
-5
No files found.
app/controllers/users_controller.rb
View file @
152a6b86
class
UsersController
<
ApplicationController
skip_before_filter
:authenticate_user!
,
only:
[
:show
,
:activities
]
skip_before_filter
:authenticate_user!
before_filter
:set_user
layout
:determine_layout
def
show
@user
=
User
.
find_by_username!
(
params
[
:username
])
unless
current_user
||
@user
.
public_profile?
return
authenticate_user!
end
# Projects user can view
visible_projects
=
ProjectsFinder
.
new
.
execute
(
current_user
)
authorized_projects_ids
=
visible_projects
.
pluck
(
:id
)
...
...
@@ -25,6 +20,15 @@ class UsersController < ApplicationController
@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
user_repositories
=
visible_projects
.
map
(
&
:repository
)
calendar
=
Gitlab
::
CommitsCalendar
.
new
(
user_repositories
,
@user
)
...
...
@@ -32,10 +36,7 @@ class UsersController < ApplicationController
@starting_year
=
(
Time
.
now
-
1
.
year
).
strftime
(
"%Y"
)
@starting_month
=
Date
.
today
.
strftime
(
"%m"
).
to_i
respond_to
do
|
format
|
format
.
html
format
.
atom
{
render
layout:
false
}
end
render
'calendar'
,
layout:
false
end
def
determine_layout
...
...
@@ -45,4 +46,14 @@ class UsersController < ApplicationController
'public_users'
end
end
private
def
set_user
@user
=
User
.
find_by_username!
(
params
[
:username
])
unless
current_user
||
@user
.
public_profile?
return
authenticate_user!
end
end
end
app/views/users/
_
calendar.html.haml
→
app/views/users/calendar.html.haml
View file @
152a6b86
%h4
Calendar:
#cal-heatmap
.calendar
:javascript
new
calendar
(
...
...
app/views/users/show.html.haml
View file @
152a6b86
...
...
@@ -19,8 +19,9 @@
=
render
'groups'
,
groups:
@groups
%hr
%h4
Calendar:
%div
=
render
'calendar'
.user-calendar
%h4
.center.light
%i
.fa.fa-spinner.fa-spin
%hr
%h4
User Activity:
...
...
@@ -36,3 +37,8 @@
=
render
'profile'
,
user:
@user
-
if
@projects
.
present?
=
render
'projects'
,
projects:
@projects
:coffeescript
$ ->
$(".user-calendar").load("
#{
user_calendar_path
}
")
config/routes.rb
View file @
152a6b86
...
...
@@ -157,10 +157,9 @@ Gitlab::Application.routes.draw do
end
end
# route for commits used by the cal-heatmap
get
'u/:username/activities'
=>
'users#activities'
,
as: :user_activities
,
constraints:
{
username:
/(?:[^.]|\.(?!atom$))+/
,
format:
/atom/
},
via: :get
get
'u/:username/calendar'
=>
'users#calendar'
,
as: :user_calendar
,
constraints:
{
username:
/(?:[^.]|\.(?!atom$))+/
,
format:
/atom/
}
get
'/u/:username'
=>
'users#show'
,
as: :user
,
constraints:
{
username:
/(?:[^.]|\.(?!atom$))+/
,
format:
/atom/
}
...
...
spec/controllers/users_controller_spec.rb
View file @
152a6b86
...
...
@@ -9,18 +9,18 @@ describe UsersController do
describe
"GET #show"
do
render_views
before
do
get
:show
,
username:
user
.
username
end
it
"renders the show template"
do
get
:show
,
username:
user
.
username
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
).
to
render_template
(
"show"
)
end
end
describe
"GET #calendar"
do
it
"renders calendar"
do
controller
.
prepend_view_path
'app/views/users'
expect
(
response
).
to
render_template
(
"
_
calendar"
)
get
:calendar
,
username:
user
.
username
expect
(
response
).
to
render_template
(
"calendar"
)
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