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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
a46fe875
Commit
a46fe875
authored
Dec 04, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feature: atom feed for user activity
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
05d713be
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
90 additions
and
4 deletions
+90
-4
CHANGELOG
CHANGELOG
+1
-1
app/controllers/users_controller.rb
app/controllers/users_controller.rb
+6
-1
app/views/users/show.atom.builder
app/views/users/show.atom.builder
+29
-0
app/views/users/show.html.haml
app/views/users/show.html.haml
+9
-1
config/routes.rb
config/routes.rb
+2
-1
spec/features/atom/users_spec.rb
spec/features/atom/users_spec.rb
+43
-0
No files found.
CHANGELOG
View file @
a46fe875
...
@@ -20,7 +20,7 @@ v 7.6.0
...
@@ -20,7 +20,7 @@ v 7.6.0
- In the docker directory is a container template based on the Omnibus packages.
- In the docker directory is a container template based on the Omnibus packages.
- Update Sidekiq to version 2.17.8
- Update Sidekiq to version 2.17.8
-
-
-
-
Atom feed for user activity
v 7.5.2
v 7.5.2
- Don't log Sidekiq arguments by default
- Don't log Sidekiq arguments by default
...
...
app/controllers/users_controller.rb
View file @
a46fe875
...
@@ -20,9 +20,14 @@ class UsersController < ApplicationController
...
@@ -20,9 +20,14 @@ class UsersController < ApplicationController
# Get user activity feed for projects common for both users
# Get user activity feed for projects common for both users
@events
=
@user
.
recent_events
.
@events
=
@user
.
recent_events
.
where
(
project_id:
authorized_projects_ids
).
limit
(
2
0
)
where
(
project_id:
authorized_projects_ids
).
limit
(
3
0
)
@title
=
@user
.
name
@title
=
@user
.
name
respond_to
do
|
format
|
format
.
html
format
.
atom
{
render
layout:
false
}
end
end
end
def
determine_layout
def
determine_layout
...
...
app/views/users/show.atom.builder
0 → 100644
View file @
a46fe875
xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do
xml.title "Activity feed for #{@user.name}"
xml.link :href => user_url(@user, :atom), :rel => "self", :type => "application/atom+xml"
xml.link :href => user_url(@user), :rel => "alternate", :type => "text/html"
xml.id projects_url
xml.updated @events.maximum(:updated_at).strftime("%Y-%m-%dT%H:%M:%SZ") if @events.any?
@events.each do |event|
if event.proper?
xml.entry do
event_link = event_feed_url(event)
event_title = event_feed_title(event)
event_summary = event_feed_summary(event)
xml.id "tag:#{request.host},#{event.created_at.strftime("%Y-%m-%d")}:#{event.id}"
xml.link :href => event_link
xml.title truncate(event_title, :length => 80)
xml.updated event.created_at.strftime("%Y-%m-%dT%H:%M:%SZ")
xml.media :thumbnail, :width => "40", :height => "40", :url => avatar_icon(event.author_email)
xml.author do |author|
xml.name event.author_name
xml.email event.author_email
end
xml.summary(:type => "xhtml") { |x| x << event_summary unless event_summary.nil? }
end
end
end
end
app/views/users/show.html.haml
View file @
a46fe875
...
@@ -18,7 +18,15 @@
...
@@ -18,7 +18,15 @@
%h4
Groups:
%h4
Groups:
=
render
'groups'
,
groups:
@groups
=
render
'groups'
,
groups:
@groups
%hr
%hr
%h4
User Activity:
%h4
User Activity:
-
if
current_user
%span
.rss-icon.pull-right
=
link_to
user_path
(
@user
,
:atom
,
{
private_token:
current_user
.
private_token
})
do
%strong
%i
.fa.fa-rss
=
render
@events
=
render
@events
.col-md-4
.col-md-4
=
render
'profile'
,
user:
@user
=
render
'profile'
,
user:
@user
...
...
config/routes.rb
View file @
a46fe875
...
@@ -137,7 +137,8 @@ Gitlab::Application.routes.draw do
...
@@ -137,7 +137,8 @@ Gitlab::Application.routes.draw do
end
end
end
end
match
"/u/:username"
=>
"users#show"
,
as: :user
,
constraints:
{
username:
/.*/
},
via: :get
match
"/u/:username"
=>
"users#show"
,
as: :user
,
constraints:
{
username:
/(?:[^.]|\.(?!atom$))+/
,
format:
/atom/
},
via: :get
#
#
# Dashboard Area
# Dashboard Area
...
...
spec/features/atom/users_spec.rb
0 → 100644
View file @
a46fe875
require
'spec_helper'
describe
"User Feed"
,
feature:
true
do
describe
"GET /"
do
let!
(
:user
)
{
create
(
:user
)
}
context
"user atom feed via private token"
do
it
"should render user atom feed"
do
visit
user_path
(
user
,
:atom
,
private_token:
user
.
private_token
)
body
.
should
have_selector
(
"feed title"
)
end
end
context
'feed content'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
,
author:
user
,
description:
''
)
}
let
(
:note
)
{
create
(
:note
,
noteable:
issue
,
author:
user
,
note:
'Bug confirmed'
,
project:
project
)
}
before
do
project
.
team
<<
[
user
,
:master
]
issue_event
(
issue
,
user
)
note_event
(
note
,
user
)
visit
user_path
(
user
,
:atom
,
private_token:
user
.
private_token
)
end
it
"should have issue opened event"
do
body
.
should
have_content
(
"
#{
user
.
name
}
opened issue #
#{
issue
.
iid
}
"
)
end
it
"should have issue comment event"
do
body
.
should
have_content
(
"
#{
user
.
name
}
commented on issue #
#{
issue
.
iid
}
"
)
end
end
end
def
issue_event
(
issue
,
user
)
EventCreateService
.
new
.
open_issue
(
issue
,
user
)
end
def
note_event
(
note
,
user
)
EventCreateService
.
new
.
leave_note
(
note
,
user
)
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