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
Tatuya Kamada
gitlab-ce
Commits
d31d711a
Commit
d31d711a
authored
Dec 04, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DRY and refactor atom code
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
a46fe875
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
56 additions
and
102 deletions
+56
-102
app/helpers/events_helper.rb
app/helpers/events_helper.rb
+22
-0
app/helpers/issues_helper.rb
app/helpers/issues_helper.rb
+15
-0
app/views/dashboard/issues.atom.builder
app/views/dashboard/issues.atom.builder
+5
-16
app/views/dashboard/show.atom.builder
app/views/dashboard/show.atom.builder
+4
-21
app/views/groups/issues.atom.builder
app/views/groups/issues.atom.builder
+1
-12
app/views/groups/show.atom.builder
app/views/groups/show.atom.builder
+4
-20
app/views/projects/issues/index.atom.builder
app/views/projects/issues/index.atom.builder
+1
-12
app/views/users/show.atom.builder
app/views/users/show.atom.builder
+4
-21
No files found.
app/helpers/events_helper.rb
View file @
d31d711a
...
...
@@ -145,4 +145,26 @@ module EventsHelper
rescue
"--broken encoding"
end
def
event_to_atom
(
xml
,
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/helpers/issues_helper.rb
View file @
d31d711a
...
...
@@ -113,4 +113,19 @@ module IssuesHelper
'issue-box-open'
end
end
def
issue_to_atom
(
xml
,
issue
)
xml
.
entry
do
xml
.
id
project_issue_url
(
issue
.
project
,
issue
)
xml
.
link
href:
project_issue_url
(
issue
.
project
,
issue
)
xml
.
title
truncate
(
issue
.
title
,
length:
80
)
xml
.
updated
issue
.
created_at
.
strftime
(
"%Y-%m-%dT%H:%M:%SZ"
)
xml
.
media
:thumbnail
,
width:
"40"
,
height:
"40"
,
url:
avatar_icon
(
issue
.
author_email
)
xml
.
author
do
|
author
|
xml
.
name
issue
.
author_name
xml
.
email
issue
.
author_email
end
xml
.
summary
issue
.
title
end
end
end
app/views/dashboard/issues.atom.builder
View file @
d31d711a
xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns
:
media" => "http://search.yahoo.com/mrss/" do
xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlnsmedia" => "http://search.yahoo.com/mrss/" do
xml.title "#{current_user.name} issues"
xml.link
:href => issues_dashboard_url(:atom, :private_token => current_user.private_token), :rel => "self", :type =>
"application/atom+xml"
xml.link
:href => issues_dashboard_url(:private_token => current_user.private_token), :rel => "alternate", :type =>
"text/html"
xml.id issues_dashboard_url(
:private_token =>
current_user.private_token)
xml.link
href: issues_dashboard_url(:atom, private_token: current_user.private_token), rel: "self", type:
"application/atom+xml"
xml.link
href: issues_dashboard_url(private_token: current_user.private_token), rel: "alternate", type:
"text/html"
xml.id issues_dashboard_url(
private_token:
current_user.private_token)
xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any?
@issues.each do |issue|
xml.entry do
xml.id project_issue_url(issue.project, issue)
xml.link :href => project_issue_url(issue.project, issue)
xml.title truncate(issue.title, :length => 80)
xml.updated issue.created_at.strftime("%Y-%m-%dT%H:%M:%SZ")
xml.media :thumbnail, :width => "40", :height => "40", :url => avatar_icon(issue.author_email)
xml.author do |author|
xml.name issue.author_name
xml.email issue.author_email
end
xml.summary issue.title
end
issue_to_atom(xml, issue)
end
end
app/views/dashboard/show.atom.builder
View file @
d31d711a
xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns
:
media" => "http://search.yahoo.com/mrss/" do
xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlnsmedia" => "http://search.yahoo.com/mrss/" do
xml.title "Dashboard feed#{" - #{current_user.name}" if current_user.name.present?}"
xml.link
:href => dashboard_url(:atom), :rel => "self", :type =>
"application/atom+xml"
xml.link
:href => dashboard_url, :rel => "alternate", :type =>
"text/html"
xml.link
href: dashboard_url(:atom), rel: "self", type:
"application/atom+xml"
xml.link
href: dashboard_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.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
event_to_atom(xml, event)
end
end
app/views/groups/issues.atom.builder
View file @
d31d711a
...
...
@@ -7,18 +7,7 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://sear
xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any?
@issues.each do |issue|
xml.entry do
xml.id project_issue_url(issue.project, issue)
xml.link :href => project_issue_url(issue.project, issue)
xml.title truncate(issue.title, :length => 80)
xml.updated issue.created_at.strftime("%Y-%m-%dT%H:%M:%SZ")
xml.media :thumbnail, :width => "40", :height => "40", :url => avatar_icon(issue.author_email)
xml.author do |author|
xml.name issue.author_name
xml.email issue.author_email
end
xml.summary issue.title
end
issue_to_atom(xml, issue)
end
end
app/views/groups/show.atom.builder
View file @
d31d711a
xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns
:
media" => "http://search.yahoo.com/mrss/" do
xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlnsmedia" => "http://search.yahoo.com/mrss/" do
xml.title "Group feed - #{@group.name}"
xml.link
:href => group_path(@group, :atom), :rel => "self", :type =>
"application/atom+xml"
xml.link
:href => group_path(@group), :rel => "alternate", :type =>
"text/html"
xml.link
href: group_path(@group, :atom), rel: "self", type:
"application/atom+xml"
xml.link
href: group_path(@group), 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)
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 event_title
end
end
event_to_atom(xml, event)
end
end
app/views/projects/issues/index.atom.builder
View file @
d31d711a
...
...
@@ -7,17 +7,6 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://sear
xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any?
@issues.each do |issue|
xml.entry do
xml.id project_issue_url(@project, issue)
xml.link :href => project_issue_url(@project, issue)
xml.title truncate(issue.title, :length => 80)
xml.updated issue.created_at.strftime("%Y-%m-%dT%H:%M:%SZ")
xml.media :thumbnail, :width => "40", :height => "40", :url => avatar_icon(issue.author_email)
xml.author do |author|
xml.name issue.author_name
xml.email issue.author_email
end
xml.summary issue.title
end
issue_to_atom(xml, issue)
end
end
app/views/users/show.atom.builder
View file @
d31d711a
xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns
:
media" => "http://search.yahoo.com/mrss/" do
xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlnsmedia" => "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.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
event_to_atom(xml, event)
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