require 'pp'
class PostSetPresenter < Presenter
attr_accessor :post_set
def initialize(post_set)
@post_set = post_set
end
def posts
post_set.posts
end
def tag_list_html
""
end
def wiki_html(template)
if post_set.is_single_tag?
wiki_page = WikiPage.find_by_title(post_set.tags)
html = ''
if wiki_page.nil?
html << ''
html << 'There is no wiki for this tag.'
html << ' '
html << template.link_to("Create a new page", template.new_wiki_page_path(:title => post_set.tags))
html << '.'
html << '
'
else
html << ''
html << template.h(wiki_page.title)
html << '
'
html << template.format_text(wiki_page.body)
end
html << ''
html.html_safe
end
end
def pagination_html(template)
if post_set.use_sequential_paginator?
sequential_pagination_html(template)
else
numbered_pagination_html(template)
end
end
def sequential_pagination_html(template)
html = "
"
html.html_safe
end
def numbered_pagination_html(template)
total_pages = (post_set.count.to_f / post_set.limit.to_f).ceil
current_page = [1, post_set.page].max
html = ""
html.html_safe
end
def numbered_pagination_item(template, page, current_page)
html = ""
if page == "..."
html << "..."
elsif page == current_page
html << page.to_s
else
html << template.link_to(page, template.__send__(:posts_path, :tags => template.params[:tags], :page => page))
end
html << ""
html.html_safe
end
def post_previews_html
html = ""
posts.each do |post|
flags = []
flags << "pending" if post.is_pending?
flags << "flagged" if post.is_flagged?
flags << "removed" if post.is_removed?
html << %{}
html << %{}
html << %{
}
html << %{}
html << %{}
end
html.html_safe
end
end