Module: EffectivePostsHelper

Defined in:
app/helpers/effective_posts_helper.rb

Instance Method Summary collapse

Instance Method Details

#effective_post_path(post) ⇒ Object



37
38
39
40
# File 'app/helpers/effective_posts_helper.rb', line 37

def effective_post_path(post)
  category = post.category.to_s.downcase
  EffectivePosts.use_category_routes ? "/#{category}/#{post.to_param}" : effective_posts.post_path(post, :category => category.to_s)
end

#link_to_post_category(category, options = {}) ⇒ Object



30
31
32
33
34
35
# File 'app/helpers/effective_posts_helper.rb', line 30

def (category, options = {})
  category = category.to_s.downcase

  href = EffectivePosts.use_category_routes ? "/#{category}" : effective_posts.posts_path(:category => category.to_s)
  link_to(category.to_s.titleize, href, options)
end

#post_excerpt(post, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/effective_posts_helper.rb', line 15

def post_excerpt(post, options = {})
  content = effective_region(post, :content) { "<p>Default content</p>".html_safe }

  index = content.index(Effective::Snippets::ReadMoreDivider::TOKEN)

  if index.present? # We have to return the excerpt and add a Read more... link
    content[0...index].html_safe +
    (:p, :class => 'post-read-more') do
      link_to((options.delete(:label) || 'Read more...'), effective_post_path(post), options)
    end
  else
    content
  end
end

#post_meta(post) ⇒ Object



6
7
8
9
10
11
12
13
# File 'app/helpers/effective_posts_helper.rb', line 6

def (post)
  [
    "Published",
    "on #{post.published_at.strftime("%d-%b-%Y %l:%M %p")}",
    ("to #{(post.category)}" if Array(EffectivePosts.categories).length > 0),
    ("by #{post.user.to_s.presence || 'Unknown'}" if EffectivePosts.)
  ].compact.join(' ').html_safe
end

#render_post(post) ⇒ Object



2
3
4
# File 'app/helpers/effective_posts_helper.rb', line 2

def render_post(post)
  render(:partial => 'effective/posts/post', :locals => {:post => post})
end