Commit a6dfd065 authored by Douwe Maan's avatar Douwe Maan

Add atom feed for project activity.

parent 72b090b8
...@@ -66,8 +66,6 @@ class ProjectsController < ApplicationController ...@@ -66,8 +66,6 @@ class ProjectsController < ApplicationController
return return
end end
limit = (params[:limit] || 20).to_i
@show_star = !(current_user && current_user.starred?(@project)) @show_star = !(current_user && current_user.starred?(@project))
respond_to do |format| respond_to do |format|
...@@ -85,11 +83,14 @@ class ProjectsController < ApplicationController ...@@ -85,11 +83,14 @@ class ProjectsController < ApplicationController
end end
format.json do format.json do
@events = @project.events.recent load_events
@events = event_filter.apply_filter(@events).with_associations
@events = @events.limit(limit).offset(params[:offset] || 0)
pager_json('events/_events', @events.count) pager_json('events/_events', @events.count)
end end
format.atom do
load_events
render layout: false
end
end end
end end
...@@ -167,6 +168,13 @@ class ProjectsController < ApplicationController ...@@ -167,6 +168,13 @@ class ProjectsController < ApplicationController
current_user ? 'projects' : 'public_projects' current_user ? 'projects' : 'public_projects'
end end
def load_events
@events = @project.events.recent
@events = event_filter.apply_filter(@events).with_associations
limit = (params[:limit] || 20).to_i
@events = @events.limit(limit).offset(params[:offset] || 0)
end
def project_params def project_params
params.require(:project).permit( params.require(:project).permit(
:name, :path, :description, :issues_tracker, :tag_list, :name, :path, :description, :issues_tracker, :tag_list,
......
xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do
xml.title "Project feed - #{@project.name}"
xml.link href: namespace_project_path(@project.namespace, @project, :atom), rel: "self", type: "application/atom+xml"
xml.link href: namespace_project_path(@project.namespace, @project), 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|
event_to_atom(xml, event)
end
end
= content_for :meta_tags do
- if current_user
= auto_discovery_link_tag(:atom, namespace_project_path(@project.namespace, @project, format: :atom, private_token: current_user.private_token), title: "#{@group.name} activity")
- if current_user && can?(current_user, :download_code, @project) - if current_user && can?(current_user, :download_code, @project)
= render 'shared/no_ssh' = render 'shared/no_ssh'
= render 'shared/no_password' = render 'shared/no_password'
...@@ -39,6 +43,14 @@ ...@@ -39,6 +43,14 @@
%i.fa.fa-angle-left %i.fa.fa-angle-left
%section.col-md-9 %section.col-md-9
= render "events/event_last_push", event: @last_push = render "events/event_last_push", event: @last_push
- if current_user
%ul.nav.nav-pills.event_filter.pull-right
%li
= link_to namespace_project_path(@project.namespace, @project, format: :atom, private_token: current_user.private_token), title: "Feed", class: 'rss-btn' do
%i.fa.fa-rss
News Feed
= render 'shared/event_filter' = render 'shared/event_filter'
%hr %hr
.content_list .content_list
......
...@@ -236,7 +236,7 @@ Gitlab::Application.routes.draw do ...@@ -236,7 +236,7 @@ Gitlab::Application.routes.draw do
constraints: { username: /.*/ } constraints: { username: /.*/ }
get '/u/:username' => 'users#show', as: :user, get '/u/:username' => 'users#show', as: :user,
constraints: { username: /(?:[^.]|\.(?!atom$))+/, format: /atom/ } constraints: { username: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }
# #
# Dashboard Area # Dashboard Area
...@@ -263,7 +263,7 @@ Gitlab::Application.routes.draw do ...@@ -263,7 +263,7 @@ Gitlab::Application.routes.draw do
# #
# Groups Area # Groups Area
# #
resources :groups, constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ } do resources :groups, constraints: { id: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ } do
member do member do
get :issues get :issues
get :merge_requests get :merge_requests
...@@ -295,7 +295,7 @@ Gitlab::Application.routes.draw do ...@@ -295,7 +295,7 @@ Gitlab::Application.routes.draw do
# Project Area # Project Area
# #
resources :namespaces, path: '/', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only: [] do resources :namespaces, path: '/', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only: [] do
resources(:projects, constraints: { id: /[a-zA-Z.0-9_\-]+/ }, except: resources(:projects, constraints: { id: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }, except:
[:new, :create, :index], path: "/") do [:new, :create, :index], path: "/") do
member do member do
put :transfer put :transfer
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment