Module: BiovisionPostsHelper
- Defined in:
- app/helpers/biovision_posts_helper.rb
Instance Method Summary collapse
- #admin_post_category_link(entity, text = entity.name) ⇒ Object
- #admin_post_link(entity, text = entity.title) ⇒ Object
- #admin_post_type_link(entity, text = entity.name) ⇒ Object
- #post_author_link(entity, options = {}) ⇒ Object
- #post_categories_for_select(post_type_id) ⇒ Object
-
#post_image_medium(entity, add_options = {}) ⇒ Object
Medium post image for displaying on post page.
-
#post_image_preview(entity) ⇒ Object
Post image preview for displaying in “administrative” lists.
-
#post_image_small(entity, add_options = {}) ⇒ Object
Small post image for displaying in lists of posts and feeds.
- #post_link(entity, text = entity.title, options = {}) ⇒ Object
Instance Method Details
#admin_post_category_link(entity, text = entity.name) ⇒ Object
10 11 12 |
# File 'app/helpers/biovision_posts_helper.rb', line 10 def admin_post_category_link(entity, text = entity.name) link_to(text, admin_post_category_path(id: entity.id)) end |
#admin_post_link(entity, text = entity.title) ⇒ Object
16 17 18 |
# File 'app/helpers/biovision_posts_helper.rb', line 16 def admin_post_link(entity, text = entity.title) link_to(text, admin_post_path(id: entity.id)) end |
#admin_post_type_link(entity, text = entity.name) ⇒ Object
4 5 6 |
# File 'app/helpers/biovision_posts_helper.rb', line 4 def admin_post_type_link(entity, text = entity.name) link_to(text, admin_post_type_path(id: entity.id)) end |
#post_author_link(entity, options = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'app/helpers/biovision_posts_helper.rb', line 48 def (entity, = {}) if entity..blank? entity. else = { rel: 'external nofollow noopener noreferrer' } link_to(entity., entity., .merge()) end end |
#post_categories_for_select(post_type_id) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/biovision_posts_helper.rb', line 21 def post_categories_for_select(post_type_id) = [[t(:not_set), '']] PostCategory.for_tree(post_type_id).each do |category| << [category.name, category.id] if category.child_categories.any? PostCategory.for_tree(post_type_id, category.id).each do |subcategory| << ["-#{subcategory.name}", subcategory.id] if subcategory.child_categories.any? PostCategory.for_tree(post_type_id, subcategory.id).each do |deep_category| << ["--#{deep_category.name}", deep_category.id] end end end end end end |
#post_image_medium(entity, add_options = {}) ⇒ Object
Medium post image for displaying on post page
86 87 88 89 90 91 92 93 |
# File 'app/helpers/biovision_posts_helper.rb', line 86 def post_image_medium(entity, = {}) return '' if entity.image.blank? alt_text = entity.image_alt_text.to_s versions = "#{entity.image.big.url} 2x" = { alt: alt_text, srcset: versions }.merge() image_tag(entity.image.medium.url, ) end |
#post_image_preview(entity) ⇒ Object
Post image preview for displaying in “administrative” lists
62 63 64 65 66 67 |
# File 'app/helpers/biovision_posts_helper.rb', line 62 def post_image_preview(entity) return '' if entity.image.blank? versions = "#{entity.image.preview_2x.url} 2x" image_tag(entity.image.preview.url, alt: entity.title, srcset: versions) end |
#post_image_small(entity, add_options = {}) ⇒ Object
Small post image for displaying in lists of posts and feeds
73 74 75 76 77 78 79 80 |
# File 'app/helpers/biovision_posts_helper.rb', line 73 def post_image_small(entity, = {}) return '' if entity.image.blank? alt_text = entity.image_alt_text.to_s versions = "#{entity.image.medium.url} 2x" = { alt: alt_text, srcset: versions }.merge() image_tag(entity.image.small.url, ) end |
#post_link(entity, text = entity.title, options = {}) ⇒ Object
42 43 44 |
# File 'app/helpers/biovision_posts_helper.rb', line 42 def post_link(entity, text = entity.title, = {}) link_to(text, PostManager.handler(entity, locale).post_path, ) end |