module BlogHelper
include ArticleHelper
def custom_options_for_article(article,tokenized_children)
@article = article
hidden_field_tag('article[published]', 1) +
hidden_field_tag('article[accept_comments]', 0) +
visibility_options(article,tokenized_children)
end
def cms_label_for_new_children
_('New post')
end
def cms_label_for_edit
_('Configure blog')
end
def list_posts(articles, conf = { format: 'full', paginate: true })
pagination = will_paginate(articles, {
:param_name => 'npage',
:previous_label => _('« Newer posts'),
:next_label => _('Older posts »'),
:params => {:action=>"view_page", :page=>articles.first.parent.path.split('/'), :controller=>"content_viewer"}
}) if articles.present? && conf[:paginate]
content = []
artic_len = articles.length
articles.each_with_index{ |art,i|
css_add = [ 'blog-post', 'position-'+(i+1).to_s() ]
position = (i%2 == 0) ? 'odd-post' : 'even-post'
css_add << 'first' if i == 0
css_add << 'last' if i == (artic_len-1)
css_add << 'not-published' if !art.published?
css_add << position
content << (content_tag 'div', id: "post-#{art.id}", class: css_add do
content_tag 'div', class: position + '-inner blog-post-inner' do
display_post(art, conf[:format]).html_safe +
'
'.html_safe
end
end)
}
content.join("\n