Sha256: a0f962aa987ee7a2918f6db0b50b36c25d5ac03cb32281b64a78226b149d9585
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
require 'noodall/articles/archive' require 'noodall/articles/categories' class ArticleList < Noodall::Node include Noodall::Articles::Archive include Noodall::Articles::Categories sub_templates Article def articles children.published end def recent_articles(options = {}) options = remove_invalid_filters(options) options[:order] = ['published_at DESC','created_at DESC'] children.published.limit(3).all(options) end def list self end def all_categories super(children.published.criteria.to_hash) end def archive(options = {}) options = remove_invalid_filters(options) criteria = Plucky::CriteriaHash.new( :path => self._id, :_type => 'Article', :published_at => { :$lte => Time.zone.now }, :published_to => { :$gte => Time.zone.now } ).to_hash.merge(options) result = self.collection.map_reduce(archive_map('published_at'), archive_reduce, {:query => criteria, :finalize => archive_finalize, :out => "tmp_articles"}) years = result.find.to_a.map{ |hash| Year.new(hash['_id'],hash['value']) }.sort{ |a,b| b.year <=> a.year } years end private def remove_invalid_filters(query) query.reject {|key, value| value == "All" || value.blank? } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
noodall-articles-1.0.0 | app/models/article_list.rb |