Skip to content

Commit

Permalink
Extract partials for atom entries
Browse files Browse the repository at this point in the history
  • Loading branch information
nono committed Dec 14, 2013
1 parent c8ddb09 commit 6681171
Show file tree
Hide file tree
Showing 16 changed files with 110 additions and 154 deletions.
16 changes: 16 additions & 0 deletions app/views/diaries/_diary.atom.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
url = polymorphic_url([diary.owner, diary])
feed.entry(diary, :url => url) do |entry|
entry.title(diary.title)
if diary.node.cc_licensed
entry.rights("Licence CC by-sa http://creativecommons.org/licenses/by-sa/3.0/deed.fr")
end
epub = content_tag(:div, link_to("Télécharger ce contenu au format Epub", "#{url}.epub"))
entry.content(diary.body + epub + atom_comments_link(url), :type => 'html')
entry.author do |author|
author.name(diary.owner.name)
end
diary.node.popular_tags.each do |tag|
entry.category(:term => tag.name)
end
entry.wfw :commentRss, "http://#{MY_DOMAIN}/nodes/#{diary.node.id}/comments.atom"
end
19 changes: 1 addition & 18 deletions app/views/diaries/index.atom.builder
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,5 @@ atom_feed(:root_url => diaries_url, "xmlns:wfw" => "http://wellformedweb.org/Com
feed.updated(@nodes.first.try :created_at)
feed.icon("/favicon.png")

@nodes.map(&:content).each do |diary|
url = polymorphic_url([diary.owner, diary])
feed.entry(diary, :url => url) do |entry|
entry.title(diary.title)
if diary.node.cc_licensed
entry.rights("Licence CC by-sa http://creativecommons.org/licenses/by-sa/3.0/deed.fr")
end
epub = content_tag(:div, link_to("Télécharger ce contenu au format Epub", "#{url}.epub"))
entry.content(diary.body + epub + atom_comments_link(url), :type => 'html')
entry.author do |author|
author.name(diary.owner.name)
end
diary.node.popular_tags.each do |tag|
entry.category(:term => tag.name)
end
entry.wfw :commentRss, "http://#{MY_DOMAIN}/nodes/#{diary.node.id}/comments.atom"
end
end
render :partial => @nodes.map(&:content), :locals => { :feed => feed }
end
18 changes: 1 addition & 17 deletions app/views/forums/index.atom.builder
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,5 @@ atom_feed(:root_url => forums_url, "xmlns:wfw" => "http://wellformedweb.org/Comm
feed.updated(@nodes.first.try :created_at)
feed.icon("/favicon.png")

@nodes.each do |node|
post = node.content
url = forum_post_url(:forum_id => post.forum, :id => post)
feed.entry(post, :url => url) do |entry|
entry.title(post.title)
epub = content_tag(:div, link_to("Télécharger ce contenu au format Epub", "#{url}.epub"))
entry.content(post.body + epub + atom_comments_link(url), :type => 'html')
entry.author do |author|
author.name(post.user.name)
end
entry.category(:term => post.forum.title)
node.popular_tags.each do |tag|
entry.category(:term => tag.name)
end
entry.wfw :commentRss, "http://#{MY_DOMAIN}/nodes/#{node.id}/comments.atom"
end
end
render :partial => @nodes.map(&:content), :locals => { :feed => feed }
end
13 changes: 1 addition & 12 deletions app/views/forums/show.atom.builder
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,5 @@ atom_feed(:root_url => forum_url(@forum), "xmlns:wfw" => "http://wellformedweb.o
feed.updated(@posts.first.try :created_at)
feed.icon("/favicon.png")

@posts.each do |post|
url = url_for([@forum, post])
feed.entry([@forum, post], :id => "tag:linuxfr.org,2005:ForumPost/#{post.id}") do |entry|
epub = content_tag(:div, link_to("Télécharger ce contenu au format Epub", "#{url}.epub"))
entry.title(post.title)
entry.content(post.body + epub + atom_comments_link(url), :type => 'html')
entry.author do |author|
author.name(post.user.name)
end
entry.wfw :commentRss, "http://#{MY_DOMAIN}/nodes/#{post.node.id}/comments.atom"
end
end
render :partial => @posts, :locals => { :feed => feed }
end
32 changes: 32 additions & 0 deletions app/views/news/_news.atom.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
feed.entry(news, :published => news.node.created_at) do |entry|
url = news_url news
entry.title(news.title)
if news.node.cc_licensed
entry.rights("Licence CC by-sa http://creativecommons.org/licenses/by-sa/3.0/deed.fr")
end
first = content_tag(:div, news.body)
links = content_tag(:ul, news.links.map.with_index do |l,i|
content_tag(:li, "lien n°#{i+1} : ".html_safe +
link_to(l.title, "http://#{MY_DOMAIN}/redirect/#{l.id}", :title => l.url, :hreflang => l.lang))
end.join.html_safe)
second = content_tag(:div, news.second_part)
if news.published?
epub = content_tag(:div, link_to("Télécharger ce contenu au format Epub", "#{url}.epub"))
else
epub = ""
end
comments = atom_comments_link(url)
entry.content(first + links + second + epub + comments, :type => 'html')
news.attendees.each do |attendee|
entry.author do |author|
author.name(attendee.name)
end
end
entry.category(:term => news.section.title)
news.node.popular_tags.each do |tag|
entry.category(:term => tag.name)
end
if news.published?
entry.wfw :commentRss, "http://#{MY_DOMAIN}/nodes/#{news.node.id}/comments.atom"
end
end
29 changes: 1 addition & 28 deletions app/views/news/index.atom.builder
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,5 @@ atom_feed(:root_url => news_index_url, "xmlns:wfw" => "http://wellformedweb.org/
feed.updated(@nodes.first.try :updated_at)
feed.icon("/favicon.png")

@nodes.map(&:content).each do |news|
feed.entry(news, :published => news.node.created_at) do |entry|
url = news_url news
entry.title(news.title)
if news.node.cc_licensed
entry.rights("Licence CC by-sa http://creativecommons.org/licenses/by-sa/3.0/deed.fr")
end
first = content_tag(:div, news.body)
links = content_tag(:ul, news.links.map.with_index do |l,i|
content_tag(:li, "lien n°#{i+1} : ".html_safe +
link_to(l.title, "http://#{MY_DOMAIN}/redirect/#{l.id}", :title => l.url, :hreflang => l.lang))
end.join.html_safe)
second = content_tag(:div, news.second_part)
epub = content_tag(:div, link_to("Télécharger ce contenu au format Epub", "#{url}.epub"))
comments = atom_comments_link(url)
entry.content(first + links + second + epub + comments, :type => 'html')
news.attendees.each do |attendee|
entry.author do |author|
author.name(attendee.name)
end
end
entry.category(:term => news.section.title)
news.node.popular_tags.each do |tag|
entry.category(:term => tag.name)
end
entry.wfw :commentRss, "http://#{MY_DOMAIN}/nodes/#{news.node.id}/comments.atom"
end
end
render :partial => @nodes.map(&:content), :locals => { :feed => feed }
end
13 changes: 13 additions & 0 deletions app/views/polls/_poll.atom.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
feed.entry(poll, :published => poll.node.created_at) do |entry|
url = poll_url(poll)
entry.title(poll.title)
epub = content_tag(:div, link_to("Télécharger ce contenu au format Epub", "#{url}.epub"))
entry.content(poll_body(poll) + epub + atom_comments_link(url), :type => 'html')
entry.author do |author|
author.name(poll.node.user.name)
end
poll.node.popular_tags.each do |tag|
entry.category(:term => tag.name)
end
entry.wfw :commentRss, "http://#{MY_DOMAIN}/nodes/#{poll.node.id}/comments.atom"
end
16 changes: 1 addition & 15 deletions app/views/polls/index.atom.builder
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,5 @@ atom_feed(:root_url => polls_url, "xmlns:wfw" => "http://wellformedweb.org/Comme
feed.updated(@polls.first.try :created_at)
feed.icon("/favicon.png")

@polls.each do |poll|
feed.entry(poll, :published => poll.node.created_at) do |entry|
url = poll_url(poll)
entry.title(poll.title)
epub = content_tag(:div, link_to("Télécharger ce contenu au format Epub", "#{url}.epub"))
entry.content(poll_body(poll) + epub + atom_comments_link(url), :type => 'html')
entry.author do |author|
author.name(poll.node.user.name)
end
poll.node.popular_tags.each do |tag|
entry.category(:term => tag.name)
end
entry.wfw :commentRss, "http://#{MY_DOMAIN}/nodes/#{poll.node.id}/comments.atom"
end
end
render :partial => @polls, :locals => { :feed => feed }
end
14 changes: 14 additions & 0 deletions app/views/posts/_post.atom.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
url = forum_post_url(:forum_id => post.forum, :id => post)
feed.entry(post, :url => url) do |entry|
entry.title(post.title)
epub = content_tag(:div, link_to("Télécharger ce contenu au format Epub", "#{url}.epub"))
entry.content(post.body + epub + atom_comments_link(url), :type => 'html')
entry.author do |author|
author.name(post.user.name)
end
entry.category(:term => post.forum.title)
post.node.popular_tags.each do |tag|
entry.category(:term => tag.name)
end
entry.wfw :commentRss, "http://#{MY_DOMAIN}/nodes/#{post.node.id}/comments.atom"
end
24 changes: 1 addition & 23 deletions app/views/redaction/news/index.atom.builder
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,5 @@ atom_feed(:root_url => redaction_news_index_url) do |feed|
feed.updated(@news.first.try :updated_at)
feed.icon("/favicon.png")

@news.each do |news|
feed.entry(news, :published => news.node.created_at) do |entry|
entry.title(news.title)
if news.node.cc_licensed
entry.rights("Licence CC by-sa http://creativecommons.org/licenses/by-sa/3.0/deed.fr")
end
first = content_tag(:div, news.body)
links = content_tag(:ul, news.links.map.with_index do |l,i|
content_tag(:li, "lien n°#{i+1} : ".html_safe +
link_to(l.title, "http://#{MY_DOMAIN}/redirect/#{l.id}", :title => l.url, :hreflang => l.lang))
end.join.html_safe)
second = content_tag(:div, news.second_part)
comments = atom_comments_link(redaction_news_url news)
entry.content(first + links + second + comments, :type => 'html')
entry.author do |author|
author.name(news.author_name)
end
entry.category(:term => news.section.title)
news.node.popular_tags.each do |tag|
entry.category(:term => tag.name)
end
end
end
render :partial => @news, :locals => { :feed => feed }
end
13 changes: 1 addition & 12 deletions app/views/sections/show.atom.builder
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,5 @@ atom_feed(:root_url => section_url(@section), "xmlns:wfw" => "http://wellformedw
feed.updated(@news.first.try :updated_at)
feed.icon("/favicon.png")

@news.each do |news|
feed.entry(news) do |entry|
entry.title(news.title)
url = news_url news
epub = content_tag(:div, link_to("Télécharger ce contenu au format Epub", "#{url}.epub"))
entry.content(news.body + epub + atom_comments_link(url), :type => 'html')
entry.author do |author|
author.name(news.author_name)
end
entry.wfw :commentRss, "http://#{MY_DOMAIN}/nodes/#{news.node.id}/comments.atom"
end
end
render :partial => @news, :locals => { :feed => feed }
end
1 change: 1 addition & 0 deletions app/views/tags/public.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
= render "hide"

=h1 "Tous les contenus taggés avec #{@tag.name}"
- feed "Flux Atom du tag #{@tag.name}"
- link = link_to("Afficher uniquement les contenus que j'ai taggés avec #{@tag.name}", tag_path(@tag.name)) if current_account
= paginated_section @nodes, link do
%main#contents(role="main")
Expand Down
12 changes: 12 additions & 0 deletions app/views/trackers/_tracker.atom.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
feed.entry(tracker) do |entry|
entry.title("#{tracker.category.title} : #{tracker.title}")
entry.content(tracker.body + atom_comments_link(tracker_url tracker), :type => 'html')
entry.author do |author|
author.name(tracker.user.try(:name) || 'Anonyme')
end
entry.category(:term => tracker.category.title)
tracker.node.popular_tags.each do |tag|
entry.category(:term => tag.name)
end
entry.wfw :commentRss, "http://#{MY_DOMAIN}/nodes/#{tracker.node.id}/comments.atom"
end
15 changes: 1 addition & 14 deletions app/views/trackers/index.atom.builder
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,5 @@ atom_feed(:root_url => trackers_url, "xmlns:wfw" => "http://wellformedweb.org/Co
feed.updated(@trackers.first.try :created_at)
feed.icon("/favicon.png")

@trackers.each do |tracker|
feed.entry(tracker) do |entry|
entry.title("#{tracker.category.title} : #{tracker.title}")
entry.content(tracker.body + atom_comments_link(tracker_url tracker), :type => 'html')
entry.author do |author|
author.name(tracker.user.try(:name) || 'Anonyme')
end
entry.category(:term => tracker.category.title)
tracker.node.popular_tags.each do |tag|
entry.category(:term => tag.name)
end
entry.wfw :commentRss, "http://#{MY_DOMAIN}/nodes/#{tracker.node.id}/comments.atom"
end
end
render :partial => @trackers, :locals => { :feed => feed }
end
13 changes: 13 additions & 0 deletions app/views/wiki_pages/_wiki_page.atom.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
feed.entry(wiki_page) do |entry|
entry.title(wiki_page.title)
url = wiki_page_url wiki_page
epub = content_tag(:div, link_to("Télécharger ce contenu au format Epub", "#{url}.epub"))
entry.content(wiki_page.body + epub + atom_comments_link(url), :type => 'html')
entry.author do |author|
author.name(wiki_page.node.user.try :name)
end
wiki_page.node.popular_tags.each do |tag|
entry.category(:term => tag.name)
end
entry.wfw :commentRss, "http://#{MY_DOMAIN}/nodes/#{wiki_page.node.id}/comments.atom"
end
16 changes: 1 addition & 15 deletions app/views/wiki_pages/index.atom.builder
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,5 @@ atom_feed(:root_url => wiki_pages_url, "xmlns:wfw" => "http://wellformedweb.org/
feed.icon("/favicon.png")
feed.rights("Licence CC by-sa http://creativecommons.org/licenses/by-sa/3.0/deed.fr")

@wiki_pages.each do |page|
feed.entry(page) do |entry|
entry.title(page.title)
url = wiki_page_url page
epub = content_tag(:div, link_to("Télécharger ce contenu au format Epub", "#{url}.epub"))
entry.content(page.body + epub + atom_comments_link(url), :type => 'html')
entry.author do |author|
author.name(page.node.user.try :name)
end
page.node.popular_tags.each do |tag|
entry.category(:term => tag.name)
end
entry.wfw :commentRss, "http://#{MY_DOMAIN}/nodes/#{page.node.id}/comments.atom"
end
end
render :partial => @wiki_pages, :locals => { :feed => feed }
end

0 comments on commit 6681171

Please sign in to comment.