Module: BiovisionCoursesHelper

Defined in:
app/helpers/biovision_courses_helper.rb

Instance Method Summary collapse

Instance Method Details

Parameters:



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

Parameters:

  • entity (Course)
  • text (String) (defaults to: entity.title)


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

Parameters:

  • entity (CourseTag)
  • text (String) (defaults to: entity.name)


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_selectObject



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
  options = []
  CourseCategory.for_tree.each do |category|
    options << [category.name, category.id]
    if category.child_categories.any?
      CourseCategory.for_tree(category.id).each do |subcategory|
        options << ["-#{subcategory.name}", subcategory.id]
        if subcategory.child_categories.any?
          CourseCategory.for_tree(subcategory.id).each do |deep_category|
            options << ["--#{deep_category.name}", deep_category.id]
          end
        end
      end
    end
  end
  options
end

Parameters:

  • entity (CourseCategory)
  • text (String) (defaults to: entity.name)
  • options (Hash) (defaults to: {})


48
49
50
# File 'app/helpers/biovision_courses_helper.rb', line 48

def course_category_link(entity, text = entity.name, options = {})
  link_to(text, course_category_path(entity.id), options)
end

#course_image_medium(entity, add_options = {}) ⇒ Object

Medium course image for displaying on course page

Parameters:

  • entity (Course)
  • add_options (Hash) (defaults to: {})


86
87
88
89
90
91
92
93
# File 'app/helpers/biovision_courses_helper.rb', line 86

def course_image_medium(entity, add_options = {})
  return '' if entity.image.blank?

  alt_text = entity.image_alt_text.to_s
  versions = "#{entity.image.big.url} 2x"
  options  = { alt: alt_text, srcset: versions }.merge(add_options)
  image_tag(entity.image.medium.url, options)
end

#course_image_preview(entity) ⇒ Object

Course image preview for displaying in “administrative” lists

Parameters:



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

Parameters:

  • entity (Course)
  • add_options (Hash) (defaults to: {})


73
74
75
76
77
78
79
80
# File 'app/helpers/biovision_courses_helper.rb', line 73

def course_image_small(entity, add_options = {})
  return '' if entity.image.blank?

  alt_text = entity.image_alt_text.to_s
  versions = "#{entity.image.medium.url} 2x"
  options  = { alt: alt_text, srcset: versions }.merge(add_options)
  image_tag(entity.image.small.url, options)
end

Parameters:

  • entity (Course)
  • text (String) (defaults to: entity.title)
  • options (Hash) (defaults to: {})


41
42
43
# File 'app/helpers/biovision_courses_helper.rb', line 41

def course_link(entity, text = entity.title, options = {})
  link_to(text, course_path(entity.id), options)
end

Parameters:

  • entity (CourseTag)
  • text (String) (defaults to: entity.name)
  • options (Hash) (defaults to: {})


55
56
57
# File 'app/helpers/biovision_courses_helper.rb', line 55

def course_tag_link(entity, text = entity.name, options = {})
  link_to(text, course_tag_path(entity.id), options)
end