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
16427f4c
Commit
16427f4c
authored
12 years ago
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #880 from NARKOZ/dashboard-feed
Dashboard feed
parents
96308f75
cc3c6ad0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
6 deletions
+69
-6
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+9
-2
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+7
-2
app/views/layouts/_head.html.haml
app/views/layouts/_head.html.haml
+2
-1
app/views/projects/index.atom.builder
app/views/projects/index.atom.builder
+36
-0
spec/requests/projects_spec.rb
spec/requests/projects_spec.rb
+15
-1
No files found.
app/controllers/application_controller.rb
View file @
16427f4c
class
ApplicationController
<
ActionController
::
Base
before_filter
:authenticate_user!
before_filter
:reject_blocked!
before_filter
:set_current_user_for_mailer
before_filter
:set_current_user_for_mailer
,
:check_token_auth
protect_from_forgery
helper_method
:abilities
,
:can?
...
...
@@ -21,9 +21,16 @@ class ApplicationController < ActionController::Base
protected
def
check_token_auth
# Redirect to login page if not atom feed
if
params
[
:private_token
].
present?
&&
params
[
:format
]
!=
'atom'
redirect_to
new_user_session_path
end
end
def
reject_blocked!
if
current_user
&&
current_user
.
blocked
sign_out
current_user
sign_out
current_user
flash
[
:alert
]
=
"Your account was blocked"
redirect_to
new_user_session_path
end
...
...
This diff is collapsed.
Click to expand it.
app/controllers/projects_controller.rb
View file @
16427f4c
...
...
@@ -14,6 +14,11 @@ class ProjectsController < ApplicationController
@projects
=
current_user
.
projects
.
includes
(
:events
).
order
(
"events.created_at DESC"
)
@projects
=
@projects
.
page
(
params
[
:page
]).
per
(
40
)
@events
=
Event
.
where
(
:project_id
=>
current_user
.
projects
.
map
(
&
:id
)).
recent
.
limit
(
20
)
respond_to
do
|
format
|
format
.
html
format
.
atom
{
render
:layout
=>
false
}
end
end
def
new
...
...
@@ -31,7 +36,7 @@ class ProjectsController < ApplicationController
@project
.
save!
@project
.
users_projects
.
create!
(
:project_access
=>
UsersProject
::
MASTER
,
:user
=>
current_user
)
# when project saved no team member exist so
# when project saved no team member exist so
# project repository should be updated after first user add
@project
.
update_repository
end
...
...
@@ -72,7 +77,7 @@ class ProjectsController < ApplicationController
@events
=
@project
.
events
.
recent
.
limit
(
limit
)
respond_to
do
|
format
|
format
.
html
do
format
.
html
do
if
@project
.
repo_exists?
&&
@project
.
has_commits?
render
:show
else
...
...
This diff is collapsed.
Click to expand it.
app/views/layouts/_head.html.haml
View file @
16427f4c
...
...
@@ -8,10 +8,11 @@
=
javascript_include_tag
"application"
-# Atom feed
-
if
controller_name
==
'projects'
&&
action_name
==
'index'
=
auto_discovery_link_tag
:atom
,
projects_url
(
:atom
,
:private_token
=>
current_user
.
private_token
),
:title
=>
"Dashboard feed"
-
if
@project
&&
!
@project
.
new_record?
-
if
current_page?
(
tree_project_ref_path
(
@project
,
@project
.
root_ref
))
||
current_page?
(
project_commits_path
(
@project
))
=
auto_discovery_link_tag
(
:atom
,
project_commits_url
(
@project
,
:atom
,
:ref
=>
@ref
,
:private_token
=>
current_user
.
private_token
),
:title
=>
"Recent commits to
#{
@project
.
name
}
:
#{
@ref
}
"
)
-
if
request
.
path
==
project_issues_path
(
@project
)
=
auto_discovery_link_tag
(
:atom
,
project_issues_url
(
@project
,
:atom
,
:private_token
=>
current_user
.
private_token
),
:title
=>
"
#{
@project
.
name
}
issues"
)
=
csrf_meta_tags
This diff is collapsed.
Click to expand it.
app/views/projects/index.atom.builder
0 → 100644
View file @
16427f4c
xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do
xml.title "Dashboard feed#{" - #{current_user.name}" if current_user.name.present?}"
xml.link :href => projects_url(:atom), :rel => "self", :type => "application/atom+xml"
xml.link :href => projects_url, :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.allowed?
xml.entry do
if event.issue?
event_link = project_issue_url(event.project, event.issue)
event_title = event.issue_title
elsif event.merge_request?
event_link = project_merge_request_url(event.project, event.merge_request)
event_title = event.merge_request_title
elsif event.push?
event_link = project_commits_url(event.project, :ref => event.ref_name)
event_title = event.ref_name
end
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 => gravatar_icon(event.author_email)
xml.author do |author|
xml.name event.author_name
xml.email event.author_email
end
xml.summary event_title
end
end
end
end
This diff is collapsed.
Click to expand it.
spec/requests/projects_spec.rb
View file @
16427f4c
...
...
@@ -18,9 +18,23 @@ describe "Projects" do
page
.
should
have_content
(
"New Project"
)
end
it
"should have project"
do
it
"should have project"
do
page
.
should
have_content
(
@project
.
name
)
end
it
"should render projects atom feed via private token"
do
logout
visit
projects_path
(
:atom
,
:private_token
=>
@user
.
private_token
)
page
.
body
.
should
have_selector
(
"feed title"
)
end
it
"should not render projects page via private token"
do
logout
visit
projects_path
(
:private_token
=>
@user
.
private_token
)
current_path
.
should
==
new_user_session_path
end
end
describe
"GET /projects/new"
do
...
...
This diff is collapsed.
Click to expand it.
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