aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUģis Ozols <ugis@ugisozols.com>2013-06-17 01:37:26 -0700
committerUģis Ozols <ugis@ugisozols.com>2013-06-17 01:37:26 -0700
commit49813243e0d1aff18548ffc014e751a937e0f974 (patch)
treea06adbc3455fd6b5a10692431fb7a5ec1733d126
parentccff7c06b5b1aa863c7021c3e253ccc866b37b1d (diff)
parent8f6c29e18aec5ea5f9df96d62ed0778a2b470c3e (diff)
downloadrefinerycms-blog-49813243e0d1aff18548ffc014e751a937e0f974.tar.gz
refinerycms-blog-49813243e0d1aff18548ffc014e751a937e0f974.tar.bz2
refinerycms-blog-49813243e0d1aff18548ffc014e751a937e0f974.zip
Merge pull request #333 from dougbradbury/master
Limit rss feed length with query param
-rw-r--r--app/controllers/refinery/blog/posts_controller.rb6
-rw-r--r--readme.md7
-rw-r--r--spec/controllers/refinery/blog/posts_controller_spec.rb24
3 files changed, 35 insertions, 2 deletions
diff --git a/app/controllers/refinery/blog/posts_controller.rb b/app/controllers/refinery/blog/posts_controller.rb
index 999b49a..dbb2af8 100644
--- a/app/controllers/refinery/blog/posts_controller.rb
+++ b/app/controllers/refinery/blog/posts_controller.rb
@@ -10,7 +10,11 @@ module Refinery
def index
# Rss feeders are greedy. Let's give them every blog post instead of paginating.
- (@posts = Post.live.includes(:comments, :categories)) if request.format.rss?
+ if request.format.rss?
+ @posts = Post.live.includes(:comments, :categories)
+ #limit rss feed for services (like feedburner) who have max size
+ @posts = Post.recent(params["max_results"]) if params["max_results"].present?
+ end
respond_with (@posts) do |format|
format.html
format.rss { render :layout => false }
diff --git a/readme.md b/readme.md
index dfb2b64..2fda6df 100644
--- a/readme.md
+++ b/readme.md
@@ -9,6 +9,11 @@ Options:
* Comment moderation
* [ShareThis.com](http://sharethis.com) support on posts. To enable, set your key in Refinery's settings area.
+## Additional Features
+* to limit rss feed length, use the 'max_results' parameter
+
+ http://test.host/blog/feed/rss?max_results=10
+
## Requirements
Refinery CMS version 2.0.1 or above.
@@ -57,4 +62,4 @@ Or just with rake spec
* Check out our [Website](http://refinerycms.com/)
* Documentation is available in the [guides](http://refinerycms.com/guides)
* Questions can be asked on our [Google Group](http://group.refinerycms.org)
-* Questions can also be asked in our IRC room, [#refinerycms on freenode](irc://irc.freenode.net/refinerycms) \ No newline at end of file
+* Questions can also be asked in our IRC room, [#refinerycms on freenode](irc://irc.freenode.net/refinerycms)
diff --git a/spec/controllers/refinery/blog/posts_controller_spec.rb b/spec/controllers/refinery/blog/posts_controller_spec.rb
new file mode 100644
index 0000000..ee948a5
--- /dev/null
+++ b/spec/controllers/refinery/blog/posts_controller_spec.rb
@@ -0,0 +1,24 @@
+require "spec_helper"
+
+module Refinery
+ module Blog
+ describe PostsController do
+ before do
+ FactoryGirl.create(:blog_post, :title => "blogpost_one")
+ FactoryGirl.create(:blog_post, :title => "blogpost_two")
+ FactoryGirl.create(:blog_post, :title => "blogpost_three")
+ end
+
+ it "should not limit rss feed" do
+ get :index, :format => :rss
+ assigns[:posts].size.should == 3
+ end
+
+ it "should limit rss feed" do
+ get :index, :format => :rss, :max_results => 2
+ assigns[:posts].count.should == 2
+ end
+ end
+ end
+end
+