Module: BiovisionPostsHelper
- Defined in:
- app/helpers/biovision_posts_helper.rb
Overview
Helper methods for Posts component
Instance Method Summary collapse
- #admin_editorial_member_link(entity, text = entity.name) ⇒ Object
- #admin_post_category_link(entity, text = entity.name) ⇒ Object
- #admin_post_group_link(entity, text = entity.name, options = {}) ⇒ Object
- #admin_post_illustration_link(entity, text = entity.name, options = {}) ⇒ Object
- #admin_post_image_link(entity, text = entity.name) ⇒ Object
- #admin_post_link(entity, text = entity.title) ⇒ Object
- #admin_post_tag_link(entity, text = entity.name) ⇒ Object
- #admin_post_type_link(entity, text = entity.name) ⇒ Object
- #author_link(entity, text = entity&.profile_name, options = {}) ⇒ Object
- #my_post_link(entity, text = entity.title, options = {}) ⇒ Object
- #post_attachment_link(entity, text = entity.name!, options = {}) ⇒ Object
- #post_author_link(entity, options = {}) ⇒ Object
- #post_category_link(entity, text = nil, options = {}) ⇒ Object
- #post_group_link(entity, text = entity.nav_text, options = {}) ⇒ Object
-
#post_image_hd(entity, add_options = {}) ⇒ Object
Larger post image for displaying on post page.
-
#post_image_large(entity, add_options = {}) ⇒ Object
Large post image for displaying on post page.
-
#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_layouts_for_select ⇒ Object
- #post_link(entity, text = entity.title, options = {}) ⇒ Object
- #post_type_link(entity, text = entity.category_name!, options = {}) ⇒ Object
- #tagged_posts_link(tag_name, entity = nil) ⇒ Object
Instance Method Details
#admin_editorial_member_link(entity, text = entity.name) ⇒ Object
51 52 53 |
# File 'app/helpers/biovision_posts_helper.rb', line 51 def admin_editorial_member_link(entity, text = entity.name) link_to(text, admin_editorial_member_path(id: entity.id)) end |
#admin_post_category_link(entity, text = entity.name) ⇒ Object
13 14 15 |
# File 'app/helpers/biovision_posts_helper.rb', line 13 def admin_post_category_link(entity, text = entity.name) link_to(text, admin_post_category_path(id: entity.id)) end |
#admin_post_group_link(entity, text = entity.name, options = {}) ⇒ Object
32 33 34 |
# File 'app/helpers/biovision_posts_helper.rb', line 32 def admin_post_group_link(entity, text = entity.name, = {}) link_to(text, admin_post_group_path(id: entity.id), ) end |
#admin_post_illustration_link(entity, text = entity.name, options = {}) ⇒ Object
39 40 41 |
# File 'app/helpers/biovision_posts_helper.rb', line 39 def admin_post_illustration_link(entity, text = entity.name, = {}) link_to(text, admin_post_illustration_path(id: entity.id), ) end |
#admin_post_image_link(entity, text = entity.name) ⇒ Object
45 46 47 |
# File 'app/helpers/biovision_posts_helper.rb', line 45 def admin_post_image_link(entity, text = entity.name) link_to(text, admin_post_image_path(id: entity.id)) end |
#admin_post_link(entity, text = entity.title) ⇒ Object
19 20 21 |
# File 'app/helpers/biovision_posts_helper.rb', line 19 def admin_post_link(entity, text = entity.title) link_to(text, admin_post_path(id: entity.id)) end |
#admin_post_tag_link(entity, text = entity.name) ⇒ Object
25 26 27 |
# File 'app/helpers/biovision_posts_helper.rb', line 25 def admin_post_tag_link(entity, text = entity.name) link_to(text, admin_post_tag_path(id: entity.id)) end |
#admin_post_type_link(entity, text = entity.name) ⇒ Object
7 8 9 |
# File 'app/helpers/biovision_posts_helper.rb', line 7 def admin_post_type_link(entity, text = entity.name) link_to(text, admin_post_type_path(id: entity.id)) end |
#author_link(entity, text = entity&.profile_name, options = {}) ⇒ Object
65 66 67 68 69 70 71 |
# File 'app/helpers/biovision_posts_helper.rb', line 65 def (entity, text = entity&.profile_name, = {}) if EditorialMember.user?(entity) link_to(text, (slug: entity.slug), ) elsif entity.is_a?(User) user_link(entity) end end |
#my_post_link(entity, text = entity.title, options = {}) ⇒ Object
58 59 60 |
# File 'app/helpers/biovision_posts_helper.rb', line 58 def my_post_link(entity, text = entity.title, = {}) link_to(text, my_post_path(id: entity.id), ) end |
#post_attachment_link(entity, text = entity.name!, options = {}) ⇒ Object
133 134 135 136 137 138 139 140 141 |
# File 'app/helpers/biovision_posts_helper.rb', line 133 def (entity, text = entity.name!, = {}) return '' if entity.file.blank? = { target: '_blank' } link_to(text, entity.file.url, .merge()) end |
#post_author_link(entity, options = {}) ⇒ Object
109 110 111 112 113 114 115 116 117 118 |
# File 'app/helpers/biovision_posts_helper.rb', line 109 def (entity, = {}) if entity..blank? raw("<span>#{entity.}</span>") else = { rel: 'external nofollow noopener noreferrer' } link_to(entity., entity., .merge()) end end |
#post_category_link(entity, text = nil, options = {}) ⇒ Object
88 89 90 91 |
# File 'app/helpers/biovision_posts_helper.rb', line 88 def post_category_link(entity, text = nil, = {}) text ||= entity.respond_to?(:name) ? entity.name : entity.title link_to(text, entity.url, ) end |
#post_group_link(entity, text = entity.nav_text, options = {}) ⇒ Object
103 104 105 |
# File 'app/helpers/biovision_posts_helper.rb', line 103 def post_group_link(entity, text = entity.nav_text, = {}) link_to(text, post_group_path(id: entity.slug), ) end |
#post_image_hd(entity, add_options = {}) ⇒ Object
Larger post image for displaying on post page
197 198 199 200 201 202 203 |
# File 'app/helpers/biovision_posts_helper.rb', line 197 def post_image_hd(entity, = {}) return '' if entity.image.blank? alt_text = entity.image_alt_text.to_s = { alt: alt_text }.merge() image_tag(entity.image.hd.url, ) end |
#post_image_large(entity, add_options = {}) ⇒ Object
Large post image for displaying on post page
184 185 186 187 188 189 190 191 |
# File 'app/helpers/biovision_posts_helper.rb', line 184 def post_image_large(entity, = {}) return '' if entity.image.blank? alt_text = entity.image_alt_text.to_s versions = "#{entity.image.hd.url} 2x" = { alt: alt_text, srcset: versions }.merge() image_tag(entity.image.big.url, ) end |
#post_image_medium(entity, add_options = {}) ⇒ Object
Medium post image for displaying on post page
171 172 173 174 175 176 177 178 |
# File 'app/helpers/biovision_posts_helper.rb', line 171 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
146 147 148 149 150 151 152 |
# File 'app/helpers/biovision_posts_helper.rb', line 146 def post_image_preview(entity) return '' if entity.image.blank? alt_text = entity.image_alt_text versions = "#{entity.image.preview_2x.url} 2x" image_tag(entity.image.preview.url, alt: alt_text, srcset: versions) end |
#post_image_small(entity, add_options = {}) ⇒ Object
Small post image for displaying in lists of posts and feeds
158 159 160 161 162 163 164 165 |
# File 'app/helpers/biovision_posts_helper.rb', line 158 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_layouts_for_select ⇒ Object
73 74 75 76 |
# File 'app/helpers/biovision_posts_helper.rb', line 73 def post_layouts_for_select = PostLayout.ordered_by_name.map { |i| [i.name, i.id] } + [[t(:not_set), '']] end |
#post_link(entity, text = entity.title, options = {}) ⇒ Object
81 82 83 |
# File 'app/helpers/biovision_posts_helper.rb', line 81 def post_link(entity, text = entity.title, = {}) link_to(text, entity.url, ) end |
#post_type_link(entity, text = entity.category_name!, options = {}) ⇒ Object
96 97 98 |
# File 'app/helpers/biovision_posts_helper.rb', line 96 def post_type_link(entity, text = entity.category_name!, = {}) link_to(text, entity.url, ) end |
#tagged_posts_link(tag_name, entity = nil) ⇒ Object
122 123 124 125 126 127 128 |
# File 'app/helpers/biovision_posts_helper.rb', line 122 def tagged_posts_link(tag_name, entity = nil) if entity.nil? link_to(tag_name, tagged_posts_path(tag_name: tag_name), rel: 'tag') else link_to(tag_name, entity.tagged_path(tag_name), rel: 'tag') end end |