Module: BiovisionCoursesHelper
- Defined in:
- app/helpers/biovision_courses_helper.rb
Instance Method Summary collapse
- #admin_course_category_link(entity, text = entity.name) ⇒ Object
- #admin_course_link(entity, text = entity.title) ⇒ Object
- #admin_course_tag_link(entity, text = entity.name) ⇒ Object
- #course_categories_for_select ⇒ Object
- #course_category_link(entity, text = entity.name, options = {}) ⇒ Object
-
#course_image_medium(entity, add_options = {}) ⇒ Object
Medium course image for displaying on course page.
-
#course_image_preview(entity) ⇒ Object
Course image preview for displaying in “administrative” lists.
-
#course_image_small(entity, add_options = {}) ⇒ Object
Small course image for displaying in lists of courses and feeds.
- #course_link(entity, text = entity.title, options = {}) ⇒ Object
- #course_tag_link(entity, text = entity.name, options = {}) ⇒ Object
Instance Method Details
#admin_course_category_link(entity, text = entity.name) ⇒ Object
10 11 12 |
# File 'app/helpers/biovision_courses_helper.rb', line 10 def admin_course_category_link(entity, text = entity.name) link_to(text, admin_course_category_path(entity.id)) end |
#admin_course_link(entity, text = entity.title) ⇒ Object
16 17 18 |
# File 'app/helpers/biovision_courses_helper.rb', line 16 def admin_course_link(entity, text = entity.title) link_to(text, admin_course_path(entity.id)) end |
#admin_course_tag_link(entity, text = entity.name) ⇒ Object
4 5 6 |
# File 'app/helpers/biovision_courses_helper.rb', line 4 def admin_course_tag_link(entity, text = entity.name) link_to(text, admin_course_tag_path(entity.id)) end |
#course_categories_for_select ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/helpers/biovision_courses_helper.rb', line 20 def course_categories_for_select = [] CourseCategory.for_tree.each do |category| << [category.name, category.id] if category.child_categories.any? CourseCategory.for_tree(category.id).each do |subcategory| << ["-#{subcategory.name}", subcategory.id] if subcategory.child_categories.any? CourseCategory.for_tree(subcategory.id).each do |deep_category| << ["--#{deep_category.name}", deep_category.id] end end end end end end |
#course_category_link(entity, text = entity.name, options = {}) ⇒ Object
48 49 50 |
# File 'app/helpers/biovision_courses_helper.rb', line 48 def course_category_link(entity, text = entity.name, = {}) link_to(text, course_category_path(entity.id), ) end |
#course_image_medium(entity, add_options = {}) ⇒ Object
Medium course image for displaying on course page
86 87 88 89 90 91 92 93 |
# File 'app/helpers/biovision_courses_helper.rb', line 86 def course_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 |
#course_image_preview(entity) ⇒ Object
Course image preview for displaying in “administrative” lists
62 63 64 65 66 67 |
# File 'app/helpers/biovision_courses_helper.rb', line 62 def course_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 |
#course_image_small(entity, add_options = {}) ⇒ Object
Small course image for displaying in lists of courses and feeds
73 74 75 76 77 78 79 80 |
# File 'app/helpers/biovision_courses_helper.rb', line 73 def course_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 |
#course_link(entity, text = entity.title, options = {}) ⇒ Object
41 42 43 |
# File 'app/helpers/biovision_courses_helper.rb', line 41 def course_link(entity, text = entity.title, = {}) link_to(text, course_path(entity.id), ) end |
#course_tag_link(entity, text = entity.name, options = {}) ⇒ Object
55 56 57 |
# File 'app/helpers/biovision_courses_helper.rb', line 55 def course_tag_link(entity, text = entity.name, = {}) link_to(text, course_tag_path(entity.id), ) end |