0
class SiteDrop < BaseDrop
0
+ liquid_attributes.push(*[:host, :subtitle, :title, :articles_per_page, :tag_path, :search_path])
0
def current_section() @current_section_liquid end
0
@@ -6,16 +7,14 @@ class SiteDrop < BaseDrop
0
@current_section = section
0
@current_section_liquid = section ? section.to_liquid : nil
0
- @site_liquid = [:id, :host, :subtitle, :title, :articles_per_page, :tag_path, :search_path].inject({}) { |h, k| h.merge k.to_s => @source.send(k) }
0
- @site_liquid['accept_comments'] = @source.accept_comments?
0
- def before_method(method)
0
- @site_liquid[method.to_s]
0
+ @liquid['accept_comments'] = @source.accept_comments?
0
- @sections ||= @source.sections.inject([]) { |all, s| all.send(s.home? ? :unshift : :<<, s.to_liquid(s == @current_section)) }
0
+ return @sections if @sections
0
+ @sections = @source.sections.inject([]) { |all, s| all.send(s.home? ? :unshift : :<<, s.to_liquid(s == @current_section)) }
0
+ @sections.each { |s| s.context = @context }
0
@@ -24,17 +23,13 @@ class SiteDrop < BaseDrop
0
def latest_articles(limit = nil)
0
return @articles if @articles && limit == @source.articles_per_page
0
- articles = returning @source.articles.find_by_date(:limit => (limit || @source.articles_per_page)) do |articles|
0
- articles.collect! &:to_liquid
0
+ articles = liquidize(*@source.articles.find_by_date(:limit => (limit || @source.articles_per_page)))
0
limit == @source.articles_per_page ? (@articles = articles) : articles
0
def latest_comments(limit = nil)
0
return @comments if @comments && limit == @source.articles_per_page
0
- comments = returning @source.comments.find(:all, :limit => (limit || @source.articles_per_page)) do |comments|
0
- comments.collect! &:to_liquid
0
+ comments = liquidize(*@source.comments.find(:all, :limit => (limit || @source.articles_per_page)))
0
limit == @source.articles_per_page ? (@comments = comments) : comments
0
@@ -43,21 +38,17 @@ class SiteDrop < BaseDrop
0
return @section_index[path] if @section_index[path]
0
@section_index[path] ||= @current_section_liquid if @current_section && @current_section.path == path
0
@section_index[path] ||= @sections.detect { |s| s['path'] == path } if @sections
0
- @section_index[path] ||=
@source.sections.find_by_path(path).to_liquid0
+ @section_index[path] ||=
liquidize(@source.sections.find_by_path(path)).first0
def find_child_sections(path)
0
path_search = path + (path == '' ? '%' : '/%')
0
- returning @source.sections.find(:all, :conditions => ['path != ? AND path LIKE ? AND path NOT LIKE ?', path, path_search, "#{path_search}/%"]) do |sections|
0
- sections.collect! &:to_liquid
0
+ liquidize(*@source.sections.find(:all, :conditions => ['path != ? AND path LIKE ? AND path NOT LIKE ?', path, path_search, "#{path_search}/%"]))
0
def find_descendant_sections(path)
0
path_search = path + (path == '' ? '%' : '/%')
0
- returning @source.sections.find(:all, :conditions => ['path != ? AND path LIKE ?', path, path_search]) do |sections|
0
- sections.collect! &:to_liquid
0
+ liquidize(*@source.sections.find(:all, :conditions => ['path != ? AND path LIKE ?', path, path_search]))
Comments
No one has commented yet.