fixed post listing

This commit is contained in:
albert
2011-06-21 13:10:01 -04:00
parent 07f8dba7f2
commit fab37bc0d3
8 changed files with 80 additions and 56 deletions

View File

@@ -0,0 +1,43 @@
module PostSets
class Post
attr_reader :tags, :page, :posts
def initialize(params)
@tags = Tag.scan_query(params[:tags])
@page = [params[:page].to_i, 1].max
@posts = ::Post.tag_match(tag_string).paginate(page)
end
def tag_string
@tag_string ||= tags.join(" ")
end
def has_wiki?
if tags.any?
::WikiPage.titled(tag_string).exists?
else
false
end
end
def wiki_page
if tags.any?
::WikiPage.titled(tag_string).first
else
nil
end
end
def is_single_tag?
tags.size == 1
end
def tag
tag_string
end
def presenter
@presenter ||= PostSetPresenter.new(self)
end
end
end