Module: ApplicationHelper

Overview

:nodoc:

Constant Summary

Constants included from ApplicationHTMLFormattersHelper

ApplicationHTMLFormattersHelper::DefaultCodePipelineOptions, ApplicationHTMLFormattersHelper::DefaultHTMLPipeline, ApplicationHTMLFormattersHelper::DefaultHTMLPipelineOptions, ApplicationHTMLFormattersHelper::DefaultPipeline, ApplicationHTMLFormattersHelper::DefaultPipelineOptions, ApplicationHTMLFormattersHelper::HTMLSanitizerOptions, ApplicationHTMLFormattersHelper::HTMLSanitizerPipeline, ApplicationHTMLFormattersHelper::MAX_CODE_LINES, ApplicationHTMLFormattersHelper::MAX_CODE_SIZE, ApplicationHTMLFormattersHelper::SANITIZATION_FILTER_WHITELIST, ApplicationHTMLFormattersHelper::VIDEO_URL_WHITELIST, ApplicationHTMLFormattersHelper::VIDEO_WHITELIST_TRANSFORMER

Instance Method Summary collapse

Methods included from RenderWithinLayoutHelper

#render

Methods included from FormForWithResourceHelper

#form_for, form_for_with_resource_option

Methods included from ApplicationSidebarHelper

#link_to_sidebar_item, #sidebar, #sidebar!, #sidebar?, #sidebar_items

Methods included from ApplicationFormattersHelper

#display_topic, #display_user, #display_user_image, #draft_class, #draft_message, #format_block_text, #format_boolean, #format_datetime, #format_duration, #format_inline_text, #link_to_user, #time_period_class, #time_period_message, #unread_class

Methods included from ApplicationHTMLFormattersHelper

#default_code_pipeline, #format_code_block, #format_html, #highlight_code_block, #sanitize

Methods included from ApplicationNotificationsHelper

#notification_directory_path, #notification_view_path

Methods included from ApplicationCocoonHelper

#link_to_add_association

Methods included from ApplicationWidgetsHelper

#delete_button, #display_progress_bar, #edit_button, #new_button

Methods included from ApplicationAnnouncementsHelper

#global_announcements

Methods included from ApplicationThemingHelper

#application_resources, #page_class

Instance Method Details

#header_tags(*args, &proc) ⇒ Object Also known as: within_head_tag

Accesses the header tags specified for the current page


19
20
21
# File 'app/helpers/application_helper.rb', line 19

def header_tags(*args, &proc)
  content_for(:header_tags, *args, &proc)
end

#page_header(header = nil) { ... } ⇒ String

Generates a page header. The title shown will be the +.header+ key in the page that calls this helper.

Yields:

  • A block in which other helper methods may be called, to place child elements on the far right of the header.


34
35
36
37
38
39
40
41
42
43
# File 'app/helpers/application_helper.rb', line 34

def page_header(header = nil)
  (:div, class: 'page-header') do
    (:h1) do
      (:span, header || t('.header')) +
        (:div, class: 'pull-right') do
          yield if block_given?
        end
    end
  end
end

#page_titleString

Generates all page titles, from the reverse breadcrumb if it's available, otherwise checks the +content_for?+ Rails helper. Appends the default title to everything.


49
50
51
52
53
54
55
56
57
58
# File 'app/helpers/application_helper.rb', line 49

def page_title
  if content_for?(:page_title)
    "#{content_for(:page_title)} - "
  elsif !breadcrumb_names.empty?
    "#{breadcrumb_names.reverse.join(' - ')} - "
  else
    ''
  end +
    t('layout.coursemology')
end

#server_context_meta_tagString

Returns a meta tag that has the server side context. Now the context contains following info: :controller-name The name of the current controller. e.g. 'Course::LessonPlanController' will return 'course/lesson_plan' :i18n-locale The locale on the server side.


66
67
68
69
70
71
72
73
74
75
# File 'app/helpers/application_helper.rb', line 66

def server_context_meta_tag
  data = {
    name: 'server-context',
    'data-controller-name': controller.class.name.sub(/Controller$/, '').underscore,
    'data-i18n-locale': I18n.locale,
    'data-time-zone': ActiveSupport::TimeZone::MAPPING[user_time_zone]
  }

  tag(:meta, data)
end

#user_time_zoneObject


77
78
79
# File 'app/helpers/application_helper.rb', line 77

def user_time_zone
  user_signed_in? ? current_user.time_zone : nil
end

#webpack_assets_tagObject

This helper will includes all webpack assets


82
83
84
85
86
87
88
89
# File 'app/helpers/application_helper.rb', line 82

def webpack_assets_tag
  capture do
    concat javascript_pack_tag('manifest')
    concat javascript_pack_tag('lib')
    concat javascript_pack_tag('vendor')
    concat javascript_pack_tag('coursemology')
  end
end