[typo] Category Feeds: Is this in Typo?

Justus Pendleton justus at ryoohki.net
Thu Aug 18 02:01:12 EDT 2005


Dev Purkayastha wrote:
> Is there a built-in feature to Typo allowing for by-category feeds?
 > Is someone thinking of trying out such a patch?

I've attached a patch for what I use.  URLs are in the form of
/xml/categoryrss/CATEGORYNAME/feed.xml

You'll probably want to edit your theme to add a link to that in somewhere.
-------------- next part --------------
Index: app/controllers/xml_controller.rb
===================================================================
--- app/controllers/xml_controller.rb	(revision 530)
+++ app/controllers/xml_controller.rb	(working copy)
@@ -1,10 +1,20 @@
 class XmlController < ApplicationController  
-  caches_page :rss, :atom, :articlerss, :commentrss, :rsd, :trackbackrss
+  caches_page :rss, :atom, :articlerss, :commentrss, :rsd, :trackbackrss, :categoryrss
 
   def articlerss
     @article = Article.find(params[:id])
     @comments = @article.comments.find(:all, :order => 'created_at DESC', :limit => 25)     
   end
+
+  def categoryrss
+    category = Category.find_by_name(params[:id])
+    @articles = Article.find(:all, :conditions => [%{ published != 0
+          AND articles.id = articles_categories.article_id
+          AND articles_categories.category_id = ? }, category.id],
+        :joins => ', articles_categories',
+        :order => "created_at DESC",
+	:limit => config[:limit_rss_display])
+  end
   
   def commentrss
     @comments = Comment.find(:all, :order => 'created_at DESC', :limit => config[:limit_rss_display])
Index: config/routes.rb
===================================================================
--- config/routes.rb	(revision 530)
+++ config/routes.rb	(working copy)
@@ -16,6 +16,7 @@
   # cached feeds with the correct xml mime type. 
   map.xml 'xml/:action/feed.xml', :controller => 'xml'
   map.xml 'xml/articlerss/:id/feed.xml', :controller => 'xml', :action => 'articlerss'
+  map.xml 'xml/categoryrss/:id/feed.xml', :controller => 'xml', :action => 'categoryrss'
 
   # allow neat perma urls
   map.connect 'articles',


More information about the Typo-list mailing list