From 52c36c38919753d26ec2d2d2ca5b00122425b570 Mon Sep 17 00:00:00 2001 From: andrew Date: Sun, 3 Feb 2008 09:27:09 +0000 Subject: [PATCH] adding feeds to major categories git-svn-id: http://svn.barleysodas.com/barleysodas/trunk@125 0f7b21a7-9e3a-4941-bbeb-ce5c7c368fa7 --- app/controllers/beers_controller.rb | 23 ++++++++++------- app/controllers/breweries_controller.rb | 25 ++++++++++-------- app/controllers/discussions_controller.rb | 6 ++--- app/controllers/experiences_controller.rb | 2 +- app/controllers/pages_controller.rb | 31 +++++++++++++---------- app/controllers/peoples_controller.rb | 19 +++++++++----- app/views/beers/_beers.rxml | 20 +++++++++++++++ app/views/beers/index.rhtml | 4 +++ app/views/breweries/_breweries.rxml | 20 +++++++++++++++ app/views/breweries/index.rhtml | 4 +++ app/views/discussions/_discussions.rxml | 20 +++++++++++++++ app/views/discussions/show.rhtml | 4 +++ app/views/experiences/_experiences.rhtml | 17 ------------- app/views/experiences/_experiences.rxml | 20 +++++++++++++++ app/views/layouts/application.rhtml | 1 + app/views/pages/_pages.rxml | 20 +++++++++++++++ app/views/pages/index.rhtml | 4 +++ app/views/peoples/_peoples.rxml | 19 ++++++++++++++ app/views/peoples/index.rhtml | 4 +++ db/migrate/004_create_breweries.rb | 1 + 20 files changed, 202 insertions(+), 62 deletions(-) create mode 100644 app/views/beers/_beers.rxml create mode 100644 app/views/breweries/_breweries.rxml create mode 100644 app/views/discussions/_discussions.rxml delete mode 100644 app/views/experiences/_experiences.rhtml create mode 100644 app/views/experiences/_experiences.rxml create mode 100644 app/views/pages/_pages.rxml create mode 100644 app/views/peoples/_peoples.rxml diff --git a/app/controllers/beers_controller.rb b/app/controllers/beers_controller.rb index 62823bb..44279a9 100644 --- a/app/controllers/beers_controller.rb +++ b/app/controllers/beers_controller.rb @@ -5,16 +5,21 @@ class BeersController < ApplicationController # GET /beers # GET /beers.xml def index - @content_title = 'The Beers' - @secondary_title = 'Browsing all beers' - @pages, @beers = paginate :beers, :include => 'page', :per_page => per_page, - :order => 'beers.title ASC' - flash.now[:notice] = 'There are no beers yet.' if @beers.empty? - @tags = Page.tags(:limit => 25, :order => "name DESC", - :owner_type => 'Beer') respond_to do |format| - format.html # index.rhtml - format.xml { render :xml => @beers.to_xml } + format.html do + @content_title = 'The Beers' + @secondary_title = 'Browsing all beers' + @pages, @beers = paginate :beers, :include => 'page', :per_page => per_page, + :order => 'beers.title ASC' + flash.now[:notice] = 'There are no beers yet.' if @beers.empty? + @tags = Page.tags(:limit => 25, :order => "name DESC", + :owner_type => 'Beer') + end + format.rss do + @beers = Beer.find :all, :order => 'beers.created_at DESC', + :limit => per_page + render :partial => 'beers' + end end end diff --git a/app/controllers/breweries_controller.rb b/app/controllers/breweries_controller.rb index 3c24d90..b7fcb8d 100644 --- a/app/controllers/breweries_controller.rb +++ b/app/controllers/breweries_controller.rb @@ -5,18 +5,21 @@ class BreweriesController < ApplicationController # GET /breweries # GET /breweries.xml def index - @content_title = 'The Breweries' - @secondary_title = 'Browsing all breweries' - @pages, @breweries = paginate :breweries, :include => 'page', - :order => 'breweries.title ASC', :per_page => per_page - if @breweries.empty? - flash.now[:notice] = 'There are no breweries yet.' - end - @tags = Page.tags(:limit => 25, :order => "name DESC", - :owner_type => 'Beer') respond_to do |format| - format.html # index.rhtml - format.xml { render :xml => @breweries.to_xml } + format.html do + @content_title = 'The Breweries' + @secondary_title = 'Browsing all breweries' + @pages, @breweries = paginate :breweries, :include => 'page', + :order => 'breweries.title ASC', :per_page => per_page + flash.now[:notice] = 'There are no breweries yet.' if @breweries.empty? + @tags = Page.tags(:limit => 25, :order => "name DESC", + :owner_type => 'Beer') + end + format.rss do + @breweries = Brewery.find :all, :order => 'breweries.created_at DESC', + :limit => per_page + render :partial => 'breweries' + end end end diff --git a/app/controllers/discussions_controller.rb b/app/controllers/discussions_controller.rb index 8252501..4a7d123 100644 --- a/app/controllers/discussions_controller.rb +++ b/app/controllers/discussions_controller.rb @@ -11,7 +11,7 @@ class DiscussionsController < ApplicationController :conditions => [ 'allow_discussions = ?', true ], :per_page => per_page, :include => [ 'discussions' ] respond_to do |format| - format.html # index.rhtml + format.html end end @@ -23,8 +23,8 @@ class DiscussionsController < ApplicationController @pages, @discussions = paginate :discussion, :order => 'created_at ASC', :conditions => [ 'page_id = ?', @page.id ], :per_page => per_page respond_to do |format| - format.html # show.rhtml - format.xml { render :xml => @discussions.to_xml } + format.html + format.rss { render :partial => 'discussions' } end end diff --git a/app/controllers/experiences_controller.rb b/app/controllers/experiences_controller.rb index 7e926dd..c5eab6d 100644 --- a/app/controllers/experiences_controller.rb +++ b/app/controllers/experiences_controller.rb @@ -26,7 +26,7 @@ class ExperiencesController < ApplicationController end format.rss do @experiences = @people.experiences.find :all, :limit => per_page, - :order => 'created_at DESC' + :order => 'experiences.created_at DESC' render :partial => 'experiences' end end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index b8165c8..24e2e4d 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -5,21 +5,24 @@ class PagesController < ApplicationController # GET /pages # GET /pages.xml def index - @page = Page.find_by_title_and_owner_type 'HomePage', nil - @page ||= Page.create :title => 'HomePage', - :redcloth => 'Welcome to BarleySodas!' - @content_title = 'The Beer Wiki' - @secondary_title = 'Browsing all pages' - - cond_ary = [ 'owner_id IS NULL' ] - cond_ary << "title <> 'HomePage'" - @pages, @wiki_pages = paginate :page, :per_page => per_page, - :order => 'title ASC', :conditions => [ cond_ary.join(' AND ') ] - - @tags = Page.tags(:limit => 25, :order => "name ASC") - respond_to do |format| - format.html # index.rhtml + format.html do + @page = Page.find_by_title_and_owner_type 'HomePage', nil + @page ||= Page.create :title => 'HomePage', + :redcloth => 'Welcome to BarleySodas!' + @content_title = 'The Beer Wiki' + @secondary_title = 'Browsing all pages' + cond_ary = [ 'owner_id IS NULL' ] + cond_ary << "title <> 'HomePage'" + @pages, @wiki_pages = paginate :page, :per_page => per_page, + :order => 'title ASC', :conditions => [ cond_ary.join(' AND ') ] + @tags = Page.tags(:limit => 25, :order => "name ASC") + end + format.rss do + @pages = Page.find :all, :order => 'updated_at DESC', + :limit => per_page, :conditions => [ 'owner_type IS NULL' ] + render :partial => 'pages' + end end end diff --git a/app/controllers/peoples_controller.rb b/app/controllers/peoples_controller.rb index f502410..c955f1c 100644 --- a/app/controllers/peoples_controller.rb +++ b/app/controllers/peoples_controller.rb @@ -5,14 +5,19 @@ class PeoplesController < ApplicationController # GET /peoples # GET /peoples.xml def index - @secondary_title = 'Browsing all Peoples' - @pages, @peoples = paginate :people, :per_page => per_page, - :order => 'title ASC', :singular_name => 'people' - @tags = Page.tags(:limit => 25, :order => "name DESC", - :owner_type => 'People') respond_to do |format| - format.html # index.rhtml - format.xml { render :xml => @people.to_xml } + format.html do + @secondary_title = 'Browsing all Peoples' + @pages, @peoples = paginate :people, :per_page => per_page, + :order => 'title ASC', :singular_name => 'people' + @tags = Page.tags(:limit => 25, :order => "name DESC", + :owner_type => 'People') + end + format.rss do + @peoples = People.find :all, :order => 'peoples.created_at DESC', + :limit => per_page + render :partial => 'peoples' + end end end diff --git a/app/views/beers/_beers.rxml b/app/views/beers/_beers.rxml new file mode 100644 index 0000000..b1b0c9c --- /dev/null +++ b/app/views/beers/_beers.rxml @@ -0,0 +1,20 @@ +xml.instruct! :xml, :version=>"1.0" +xml.rss(:version=>"2.0"){ + xml.channel{ + xml.title("BarleySodas Newest Beers") + xml.link(beers_url) + xml.description("The newest experience points added into BarleySodas.") + xml.lastBuildDate((@beers.first.created_at.strftime("%a, %d %b %Y %H:%M:%S %z") rescue nil)) + xml.language('en-us') + for beer in @beers + xml.item do + xml.title(beer.title) + xml.description(beer.brewery.title) + xml.author(beer.page.created_by.title) + xml.pubDate(beer.created_at.strftime("%a, %d %b %Y %H:%M:%S %z")) + xml.link(beer_url(beer.page.title_for_url)) + xml.guid(beer_url(beer.page.title_for_url)) + end + end + } +} \ No newline at end of file diff --git a/app/views/beers/index.rhtml b/app/views/beers/index.rhtml index bc94949..fb61ea3 100644 --- a/app/views/beers/index.rhtml +++ b/app/views/beers/index.rhtml @@ -8,3 +8,7 @@ <%= link_to "New Beer", new_beer_path, { :title => 'Create a new beer' } -%>
<%= render :partial => 'shared/tag_cloud' %> <% end -%> + +<% content_for :auto_discoveries do -%> + <%= auto_discovery_link_tag :rss, { :format => :rss } %> +<% end -%> \ No newline at end of file diff --git a/app/views/breweries/_breweries.rxml b/app/views/breweries/_breweries.rxml new file mode 100644 index 0000000..e2e52a3 --- /dev/null +++ b/app/views/breweries/_breweries.rxml @@ -0,0 +1,20 @@ +xml.instruct! :xml, :version=>"1.0" +xml.rss(:version=>"2.0"){ + xml.channel{ + xml.title("BarleySodas Newest Breweries") + xml.link(breweries_url) + xml.description("The newest breweries added into BarleySodas.") + xml.lastBuildDate((@breweries.first.created_at.strftime("%a, %d %b %Y %H:%M:%S %z") rescue nil)) + xml.language('en-us') + for brewery in @breweries + xml.item do + xml.title(brewery.title) + xml.description(brewery.homepage) + xml.author(brewery.page.created_by.title) + xml.pubDate(brewery.created_at.strftime("%a, %d %b %Y %H:%M:%S %z")) + xml.link(brewery_url(brewery.page.title_for_url)) + xml.guid(brewery_url(brewery.page.title_for_url)) + end + end + } +} \ No newline at end of file diff --git a/app/views/breweries/index.rhtml b/app/views/breweries/index.rhtml index b52df6d..fad4bb8 100644 --- a/app/views/breweries/index.rhtml +++ b/app/views/breweries/index.rhtml @@ -8,3 +8,7 @@ <%= link_to 'New brewery', new_brewery_path -%>
<%= render :partial => 'shared/tag_cloud' %> <% end -%> + +<% content_for :auto_discoveries do -%> + <%= auto_discovery_link_tag :rss, { :format => :rss } %> +<% end -%> \ No newline at end of file diff --git a/app/views/discussions/_discussions.rxml b/app/views/discussions/_discussions.rxml new file mode 100644 index 0000000..10afafb --- /dev/null +++ b/app/views/discussions/_discussions.rxml @@ -0,0 +1,20 @@ +xml.instruct! :xml, :version=>"1.0" +xml.rss(:version=>"2.0"){ + xml.channel{ + xml.title("Discussion Thread for #{@page.title}") + xml.link(discussion_url(@page)) + xml.description("All posts in the thread.") + xml.language('en-us') + xml.lastBuildDate((@discussions.last.created_at.strftime("%a, %d %b %Y %H:%M:%S %z") rescue nil)) + for discussion in @discussions + xml.item do + xml.title("Item posted at #{discussion.created_at}") + xml.description(discussion.text) + xml.author("Unknown, right now.") + xml.pubDate(discussion.created_at.strftime("%a, %d %b %Y %H:%M:%S %z")) + xml.link(discussion_url(@page)) + xml.guid(discussion_url(@page)) + end + end + } +} \ No newline at end of file diff --git a/app/views/discussions/show.rhtml b/app/views/discussions/show.rhtml index 3bdf125..11d7261 100644 --- a/app/views/discussions/show.rhtml +++ b/app/views/discussions/show.rhtml @@ -12,4 +12,8 @@ <% content_for 'sidebar' do -%> <%= page_or_parent_link(@page) -%>
+<% end -%> + +<% content_for :auto_discoveries do -%> + <%= auto_discovery_link_tag :rss, { :format => :rss } %> <% end -%> \ No newline at end of file diff --git a/app/views/experiences/_experiences.rhtml b/app/views/experiences/_experiences.rhtml deleted file mode 100644 index 6a28e53..0000000 --- a/app/views/experiences/_experiences.rhtml +++ /dev/null @@ -1,17 +0,0 @@ - - - - <%= @people.title -%>'s Beers - <%= experience_path(@people.page.title_for_url) -%> - Most recently added beers - <%= @experiences.first.created_at rescue '' -%> -<% for experience in @experiences -%> - - <%= experience.beer.title -%> - <%= show_beer_link(experience.beer) -%> - <%= experience.beer.brewery.title -%> - <%= experience.created_at -%> - -<% end -%> - - \ No newline at end of file diff --git a/app/views/experiences/_experiences.rxml b/app/views/experiences/_experiences.rxml new file mode 100644 index 0000000..af78ca6 --- /dev/null +++ b/app/views/experiences/_experiences.rxml @@ -0,0 +1,20 @@ +xml.instruct! :xml, :version=>"1.0" +xml.rss(:version=>"2.0"){ + xml.channel{ + xml.title("#{@people.title}'s Newest Beers") + xml.link(experience_url(@people.page.title_for_url)) + xml.description("Most recently added beers.") + xml.language('en-us') + xml.lastBuildDate((@experiences.first.created_at.strftime("%a, %d %b %Y %H:%M:%S %z") rescue nil)) + for experience in @experiences + xml.item do + xml.title(experience.beer.title) + xml.description(experience.beer.brewery.title) + xml.author(experience.beer.page.created_by.title) + xml.pubDate(experience.created_at.strftime("%a, %d %b %Y %H:%M:%S %z")) + xml.link(beer_url(experience.beer.page.title_for_url)) + xml.guid(beer_url(experience.beer.page.title_for_url)) + end + end + } +} \ No newline at end of file diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml index f809ad5..02d9eb4 100644 --- a/app/views/layouts/application.rhtml +++ b/app/views/layouts/application.rhtml @@ -11,6 +11,7 @@ + <%= yield :auto_discoveries %> diff --git a/app/views/pages/_pages.rxml b/app/views/pages/_pages.rxml new file mode 100644 index 0000000..3b5e0f4 --- /dev/null +++ b/app/views/pages/_pages.rxml @@ -0,0 +1,20 @@ +xml.instruct! :xml, :version=>"1.0" +xml.rss(:version=>"2.0"){ + xml.channel{ + xml.title("BarleySodas Recently Updated Pages") + xml.link(pages_url) + xml.description("The most recently updated pages in BarleySodas.") + xml.lastBuildDate((@pages.first.created_at.strftime("%a, %d %b %Y %H:%M:%S %z") rescue nil)) + xml.language('en-us') + for page in @pages + xml.item do + xml.title(page.title) + xml.description(page.title) + xml.author(page.created_by.title) + xml.pubDate(page.created_at.strftime("%a, %d %b %Y %H:%M:%S %z")) + xml.link(page_url(page.title_for_url)) + xml.guid(page_url(page.title_for_url)) + end + end + } +} \ No newline at end of file diff --git a/app/views/pages/index.rhtml b/app/views/pages/index.rhtml index be6505f..dd7796e 100644 --- a/app/views/pages/index.rhtml +++ b/app/views/pages/index.rhtml @@ -14,3 +14,7 @@ <%= new_page_link -%>
<%= render :partial => 'shared/tag_cloud' %> <% end -%> + +<% content_for :auto_discoveries do -%> + <%= auto_discovery_link_tag :rss, { :format => :rss } %> +<% end -%> diff --git a/app/views/peoples/_peoples.rxml b/app/views/peoples/_peoples.rxml new file mode 100644 index 0000000..7222453 --- /dev/null +++ b/app/views/peoples/_peoples.rxml @@ -0,0 +1,19 @@ +xml.instruct! :xml, :version=>"1.0" +xml.rss(:version=>"2.0"){ + xml.channel{ + xml.title("BarleySodas Newest People") + xml.link(peoples_url) + xml.description("The newest people added into BarleySodas.") + xml.lastBuildDate((@peoples.first.created_at.strftime("%a, %d %b %Y %H:%M:%S %z") rescue nil)) + xml.language('en-us') + for people in @peoples + xml.item do + xml.title(people.title) + xml.description(people.title) + xml.pubDate(people.created_at.strftime("%a, %d %b %Y %H:%M:%S %z")) + xml.link(people_url(people.page.title_for_url)) + xml.guid(people_url(people.page.title_for_url)) + end + end + } +} \ No newline at end of file diff --git a/app/views/peoples/index.rhtml b/app/views/peoples/index.rhtml index f702097..93d8442 100644 --- a/app/views/peoples/index.rhtml +++ b/app/views/peoples/index.rhtml @@ -7,4 +7,8 @@ <% content_for :sidebar do -%> <%= new_people_link %>
<%= render :partial => 'shared/tag_cloud' %> +<% end -%> + +<% content_for :auto_discoveries do -%> + <%= auto_discovery_link_tag :rss, { :format => :rss } %> <% end -%> \ No newline at end of file diff --git a/db/migrate/004_create_breweries.rb b/db/migrate/004_create_breweries.rb index 585628f..1ebbfbc 100644 --- a/db/migrate/004_create_breweries.rb +++ b/db/migrate/004_create_breweries.rb @@ -8,6 +8,7 @@ class CreateBreweries < ActiveRecord::Migration t.column :state, :string t.column :postal_code, :string t.column :country, :string + t.column :homepage, :string t.column :created_at, :timestamp end add_column :beers, :brewery_id, :integer