Module: Blogit::PostsHelper
- Defined in:
- app/helpers/blogit/posts_helper.rb
Instance Method Summary (collapse)
-
- (Object) blog_post_tag(name, content_or_options = {}, options = {}, &block)
Creates a div tag with class 'blog_post_' + name Eg:.
-
- (Object) blog_posts_archive_tag(year_css, month_css, post_css, archive_posts = Post.all)
Creates a ul tag tree with posts by year and monthes.
-
- (Object) comments_for(post)
A comments tag corresponding to the comments configuration.
-
- (Object) share_bar_for(post)
A share bar as configured.
Instance Method Details
- (Object) blog_post_tag(name, content_or_options = {}, options = {}, &block)
Creates a div tag with class 'blog_post_' + name Eg:
blog_post_tag(:title, "") # => <div class="blog_post_title"></div>
7 8 9 10 11 12 13 14 15 16 |
# File 'app/helpers/blogit/posts_helper.rb', line 7 def blog_post_tag(name, = {}, ={}, &block) if block_given? content = capture(&block) = else content = end [:class] = "#{[:class]} blog_post_#{name}".strip content_tag(name, content, ) end |
- (Object) blog_posts_archive_tag(year_css, month_css, post_css, archive_posts = Post.all)
Creates a ul tag tree with posts by year and monthes. Include blogit/archive.js to enabled expand collapse.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/helpers/blogit/posts_helper.rb', line 38 def blog_posts_archive_tag(year_css, month_css, post_css, archive_posts = Post.all) posts_tree = archive_posts.chunk {|post| post.created_at.year}.map do |year, posts_of_year| [year, posts_of_year.chunk {|post| l(post.created_at, format: :plain_month_only) }] end result = [] result << "<ul class=\"#{year_css}\">" posts_tree.each do |year, posts_by_month| result << "<li><a data-blogit-click-to-toggle-children>#{year}</a><ul class=\"#{month_css}\">" posts_by_month.each do |month, posts| result << "<li><a data-blogit-click-to-toggle-children>#{CGI.escape_html(month)}</a><ul class=\"#{post_css}\">" posts.each do |post| result << "<li><a href=\"#{blogit.post_path(post)}\">#{CGI.escape_html(post.title)}</a></li>" end result << "</ul></li>" end result << "</ul></li>" end result << "</ul>" result.join.html_safe end |
- (Object) comments_for(post)
A comments tag corresponding to the comments configuration
19 20 21 |
# File 'app/helpers/blogit/posts_helper.rb', line 19 def comments_for(post) render(partial: "blogit/posts/#{Blogit.configuration.include_comments}_comments", locals: { post: post, comment: Blogit::Comment.new }) end |
- (Object) share_bar_for(post)
A share bar as configured
24 25 26 27 28 29 30 |
# File 'app/helpers/blogit/posts_helper.rb', line 24 def (post) if !Blogit.configuration. "" else render(partial: "blogit/posts/share_bar", locals: { post: post}) end end |