Module: PiccoBlog::PostsHelper
- Includes:
- ActsAsTaggableOn::TagsHelper
- Defined in:
- app/helpers/picco_blog/posts_helper.rb
Instance Method Summary collapse
- #created_date_display(post, format = "") ⇒ Object
- #linked_tag_list(tag_list) ⇒ Object
- #markdown(text) ⇒ Object
- #members_only_check(user) ⇒ Object
- #nil_or_empty(str) ⇒ Object
- #post_preview(post, continue_link = true, length = 250) ⇒ Object
- #post_title_encode(post) ⇒ Object
- #post_url_encode(post) ⇒ Object
Instance Method Details
#created_date_display(post, format = "") ⇒ Object
8 9 10 11 |
# File 'app/helpers/picco_blog/posts_helper.rb', line 8 def created_date_display(post, format="") format = "%m/%d/%Y" if format.blank? post.created_at.strftime(format) end |
#linked_tag_list(tag_list) ⇒ Object
58 59 60 61 62 |
# File 'app/helpers/picco_blog/posts_helper.rb', line 58 def linked_tag_list(tag_list) "" unless tag_list tag_list.map{|tag| link_to tag, tagged_url(:tag => tag) }.join(", ").html_safe end |
#markdown(text) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/helpers/picco_blog/posts_helper.rb', line 29 def markdown(text) renderer = Redcarpet::Render::HTML.new(hard_wrap: true, filter_html: false) = { autolink: true, no_intra_emphasis: true, disable_indented_code_blocks: true, fenced_code_blocks: true, lax_html_blocks: true, strikethrough: true, superscript: true, tables: true } Redcarpet::Markdown.new(renderer, ).render(text).html_safe end |
#members_only_check(user) ⇒ Object
54 55 56 |
# File 'app/helpers/picco_blog/posts_helper.rb', line 54 def members_only_check(user) user.send(PiccoBlog.members_only_method) end |
#nil_or_empty(str) ⇒ Object
25 26 27 |
# File 'app/helpers/picco_blog/posts_helper.rb', line 25 def nil_or_empty(str) str.to_s.nil? || str.to_s.empty? end |
#post_preview(post, continue_link = true, length = 250) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/helpers/picco_blog/posts_helper.rb', line 13 def post_preview(post, continue_link=true, length=250) preview = "" unless nil_or_empty(post.excerpt) preview = (markdown(post.excerpt)) else preview = truncate((markdown(post.text)), length: length) end preview += " " + link_to("Continue Reading", picco_blog.post_path(post)) if continue_link preview.html_safe end |
#post_title_encode(post) ⇒ Object
46 47 48 |
# File 'app/helpers/picco_blog/posts_helper.rb', line 46 def post_title_encode(post) URI.encode(post.title) if post end |
#post_url_encode(post) ⇒ Object
50 51 52 |
# File 'app/helpers/picco_blog/posts_helper.rb', line 50 def post_url_encode(post) URI.encode(post_url(post)) if post end |