Skip to content

Commit

Permalink
[api] make the latest_commits feed valid and link it
Browse files Browse the repository at this point in the history
w3 demands an id and feeder.co requires a link to be present to make use of it
  • Loading branch information
coolo committed Dec 2, 2013
1 parent db15c39 commit f43be0e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/api/app/views/webui/feeds/commits.atom.builder
Expand Up @@ -2,6 +2,7 @@
feed_opts = { "xml:lang" => "en-US",
"xmlns" => 'http://www.w3.org/2005/Atom' }
schema_date = "2013-11-22"
obs_host = URI.parse(::Configuration.first.obs_url).host

xml.feed(feed_opts) do |feed|
feed.id "tag:#{request.host},#{schema_date}:#{request.fullpath.split(".")[0]}"
Expand All @@ -16,6 +17,7 @@ xml.feed(feed_opts) do |feed|
user = commit.user_name
reqid = commit.bs_request_id
datetime = commit.datetime
url = ''

title = "In #{package}"
title += " (request #{reqid})" unless reqid.blank?
Expand All @@ -27,14 +29,17 @@ xml.feed(feed_opts) do |feed|
div.dl do |dl|
dl.dt "Package"
dl.dd do |dd|
dd.a package, href: url_for(:only_path => false, :controller => 'package', :action => 'revisions', :project => @project.name, :package => package, :format => :html, :showall => 1)
url = url_for(:only_path => false, :controller => 'package', :action => 'revisions', :project => @project.name, :package => package, :format => :html, :showall => 1)
dd.a package, href: url
end
dl.dt "User"
dl.dd user
dl.dt "Request"
if reqid
# prefer the request url
url = request_show_url(reqid)
dl.dd do |dd|
dd.a reqid, href: request_show_url(reqid)
dd.a reqid, href: url
end
else
dl.dd reqid
Expand All @@ -55,6 +60,8 @@ xml.feed(feed_opts) do |feed|
end

entry.published(datetime.iso8601)
entry.id("tag:#{obs_host},2013-12-01:#{@project.name}/#{commit.id}")
entry.link(href: url)
entry.updated(datetime.iso8601)
end
end
Expand Down
4 changes: 4 additions & 0 deletions src/api/app/views/webui/project/show.html.erb
Expand Up @@ -2,6 +2,10 @@
<% @layouttype = 'custom' %>
<% project_bread_crumb 'Overview' %>
<% content_for :content_for_head do -%>
<%= auto_discovery_link_tag(:atom, commits_feed_path(project: @project, format: 'atom'), {title: "Commits for #{@project}"}) %>
<% end %>

<div class="grid_16 alpha omega box box-shadow">
<%= render partial: 'tabs' %>
<div class="grid_10 alpha">
Expand Down
2 changes: 1 addition & 1 deletion src/api/config/routes.rb
Expand Up @@ -44,7 +44,7 @@ def self.matches?(request)
controller 'webui/feeds' do
get 'main/news' => :news, as: :news_feed
get 'main/latest_updates' => :latest_updates, as: :latest_updates_feed
get 'project/latest_commits/:project' => :commits, defaults: { format: 'atom' }, constraints: cons
get 'project/latest_commits/:project' => :commits, defaults: { format: 'atom' }, constraints: cons, as: 'commits_feed'
end

controller 'webui/attribute' do
Expand Down

0 comments on commit f43be0e

Please sign in to comment.