public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
add monthly_articles filter

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2316 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Tue Oct 03 22:33:27 -0700 2006
commit  c74d46232e3cede6a31bf68734fc4c686b68eddc
tree    d8cd46f2962018911a08f9ca4bd5f3196e060b46
parent  f87c6db3b15b0bd622f6ecb62bcdf26de26e5078
...
24
25
26
 
 
 
 
 
 
 
27
28
...
24
25
26
27
28
29
30
31
32
33
34
35
0
@@ -24,4 +24,11 @@ module DropFilters
0
   def latest_comments(site, limit = nil)
0
     site.latest_comments(limit || site['articles_per_page'])
0
   end
0
+
0
+ def monthly_articles(section, date = nil)
0
+ date = parse_date(date)
0
+ returning section.source.articles.find_all_in_month(date.year, date.month) do |articles|
0
+ articles.collect! { |a| a.to_liquid :site => @context['site'].source, :mode => :single }
0
+ end
0
+ end
0
 end
0
\ No newline at end of file
...
1
2
3
4
 
5
6
7
...
51
52
53
 
 
 
 
54
...
1
2
3
 
4
5
6
7
...
51
52
53
54
55
56
57
58
0
@@ -1,7 +1,7 @@
0
 require File.dirname(__FILE__) + '/../test_helper'
0
 context "Drop Filters" do
0
   fixtures :sites, :sections, :contents, :assigned_sections
0
- include DropFilters
0
+ include DropFilters, CoreFilters
0
 
0
   def setup
0
     @site = sites(:first).to_liquid
0
@@ -51,4 +51,8 @@ context "Drop Filters" do
0
     assert_models_equal [sections(:europe), sections(:africa), sections(:bucharest)], descendant_sections('earth').collect(&:source)
0
   end
0
 
0
+ specify "should find articles by month" do
0
+ assert_models_equal sections(:home).articles.find_all_in_month(Time.now.year, Time.now.month), monthly_articles(sections(:home).to_liquid).collect(&:source)
0
+ end
0
+
0
 end

Comments

    No one has commented yet.