Commit 2b04c2a6 authored by Nihad Abbasov's avatar Nihad Abbasov

create atom feed for commits

parent 3f70316c
......@@ -13,7 +13,7 @@ class CommitsController < ApplicationController
load_refs # load @branch, @tag & @ref
@repo = project.repo
limit, offset = (params[:limit] || 20), (params[:offset] || 0)
limit, offset = (params[:limit] || 20), (params[:offset] || 0)
if params[:path]
@commits = @repo.log(@ref, params[:path], :max_count => limit, :skip => offset)
......@@ -24,6 +24,7 @@ class CommitsController < ApplicationController
respond_to do |format|
format.html # index.html.erb
format.js
format.atom { render :layout => false }
end
end
......@@ -32,7 +33,7 @@ class CommitsController < ApplicationController
@notes = project.notes.where(:noteable_id => @commit.id, :noteable_type => "Commit").order("created_at DESC").limit(20)
@note = @project.notes.new(:noteable_id => @commit.id, :noteable_type => "Commit")
respond_to do |format|
respond_to do |format|
format.html
format.js { respond_with_notes }
end
......
xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do
xml.title "Recent commits to #{@project.name}:#{@ref}"
xml.link :href => project_commits_url(@project, :atom, :ref => @ref), :rel => "self", :type => "application/atom+xml"
xml.link :href => project_commits_url(@project), :rel => "alternate", :type => "text/html"
xml.id project_commits_url(@project)
xml.updated @commits.first.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") if @commits.any?
@commits.each do |commit|
xml.entry do
xml.id project_commit_url(@project, :id => commit.id)
xml.link :href => project_commit_url(@project, :id => commit.id)
xml.title truncate(commit.safe_message, :length => 80)
xml.updated commit.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ")
xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(commit.author_email)
xml.author do |author|
xml.name commit.author_name
xml.email commit.author_email
end
xml.summary commit.safe_message
end
end
end
......@@ -5,6 +5,8 @@
GitLab #{" - #{@project.name}" if @project && !@project.new_record?}
= stylesheet_link_tag "application"
= javascript_include_tag "application"
- if current_page?(tree_project_path(@project)) || current_page?(project_commits_path(@project))
= auto_discovery_link_tag(:atom, project_commits_url(@project, :atom, :ref => @ref), :title => "Recent commits to #{@project.name}:#{@ref}")
= csrf_meta_tags
= javascript_tag do
REQ_URI = "#{request.env["REQUEST_URI"]}";
......
......@@ -25,6 +25,15 @@ describe "Commits" do
page.should have_content(commit.author)
page.should have_content(commit.message)
end
it "should render atom feed" do
visit project_commits_path(project, :atom)
page.response_headers['Content-Type'].should have_content("application/atom+xml")
page.body.should have_selector("title", :text => "Recent commits to #{project.name}")
page.body.should have_selector("author email", :text => commit.author_email)
page.body.should have_selector("entry summary", :text => commit.message)
end
end
describe "GET /commits/:id" do
......
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