Class: Redmine::Hook::ViewListener

Inherits:
Listener
  • Object
show all
Includes:
ActionView::Helpers::AssetTagHelper, ActionView::Helpers::FormHelper, ActionView::Helpers::FormOptionsHelper, ActionView::Helpers::FormTagHelper, ActionView::Helpers::JavaScriptHelper, ActionView::Helpers::NumberHelper, ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper, ActionView::Helpers::UrlHelper, ApplicationHelper, ERB::Util
Defined in:
lib/redmine/hook/view_listener.rb

Overview

Listener class used for views hooks. Listeners that inherit this class will include various helpers by default.

Since:

  • 0.8.0

Constant Summary

Constants included from ApplicationHelper

ApplicationHelper::HEADING_RE, ApplicationHelper::LINKS_RE, ApplicationHelper::MACROS_RE, ApplicationHelper::MACRO_SUB_RE, ApplicationHelper::TOC_RE

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ApplicationHelper

#accesskey, #anchor, #api_meta, #authoring, #authorize_for, #avatar, #avatar_edit_link, #back_url, #back_url_hidden_field_tag, #body_css_classes, #breadcrumb, #calendar_for, #catch_macros, #check_all_links, #checked_image, #context_menu, #default_search_project_scope, #delete_link, #due_date_distance_in_words, #email_delivery_enabled?, #error_messages_for, #favicon, #favicon_path, #favicon_url, #format_activity_day, #format_activity_description, #format_activity_title, #format_changeset_comments, #format_object, #format_version_name, #generate_csv, #html_hours, #html_title, #image_tag, #include_calendar_headers_tags, #include_in_api_response?, #inject_macros, #javascript_heads, #javascript_include_tag, #labelled_fields_for, #labelled_form_for, #lang_options_for_select, #link_to_attachment, #link_to_function, #link_to_if_authorized, #link_to_issue, #link_to_message, #link_to_project, #link_to_project_settings, #link_to_revision, #link_to_user, #link_to_version, #option_tag, #other_formats_links, #page_header_title, #parse_headings, #parse_hires_images, #parse_inline_attachments, #parse_non_pre_blocks, #parse_redmine_links, #parse_sections, #parse_wiki_links, #preview_link, #principals_check_box_tags, #principals_options_for_select, #progress_bar, #project_tree, #project_tree_options_for_select, #projects_for_jump_box, #raw_json, #render_error_messages, #render_flash_messages, #render_page_hierarchy, #render_project_jump_box, #render_project_nested_lists, #render_projects_for_jump_box, #render_tabs, #reorder_handle, #reorder_links, #replace_toc, #robot_exclusion_tag, #sanitize_anchor_name, #sidebar_content?, #simple_format_without_paragraph, #stylesheet_link_tag, #syntax_highlight, #syntax_highlight_lines, #textilizable, #thumbnail_tag, #time_tag, #title, #to_path_param, #toggle_checkboxes_link, #toggle_link, #truncate_lines, #truncate_single_line_raw, #view_layouts_base_sidebar_hook_response, #wiki_page_path

Methods included from Redmine::Helpers::URL

#uri_with_safe_scheme?

Methods included from Helper

#call_hook

Methods included from Themes::Helper

#current_theme, #heads_for_theme

Methods included from SudoMode::Helper

#hash_to_hidden_fields

Methods included from Pagination::Helper

#pagination_links_each, #pagination_links_full, #per_page_links, #per_page_options

Methods included from I18n

#current_language, #day_letter, #day_name, #find_language, #format_date, #format_hours, #format_time, #l, #l_hours, #l_hours_short, #l_or_humanize, #languages_options, #ll, #lu, #month_name, #set_language_if_valid, #valid_languages

Methods included from GravatarHelper::PublicMethods

#gravatar, #gravatar_api_url, #gravatar_for, #gravatar_url

Methods included from WikiFormatting::Macros::Definitions

#exec_macro, #extract_macro_options, #macro_exists?

Methods inherited from Listener

inherited

Class Method Details

.default_url_optionsObject

Default to creating links using only the path. Subclasses can change this default as needed

Since:

  • 0.8.2



38
39
40
# File 'lib/redmine/hook/view_listener.rb', line 38

def self.default_url_options
  {:only_path => true, :script_name => Redmine::Utils.relative_url_root}
end

.render_on(hook, *render_options) ⇒ Object

Helper method to directly render using the context, render_options must be valid #render options.

class MyHook < Redmine::Hook::ViewListener
  render_on :view_issues_show_details_bottom, :partial => "show_more_data"
end

class MultipleHook < Redmine::Hook::ViewListener
  render_on :view_issues_show_details_bottom,
    {:partial => "show_more_data"},
    {:partial => "show_even_more_data"}
end

Since:

  • 0.8.2



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/redmine/hook/view_listener.rb', line 55

def self.render_on(hook, *render_options)
  define_method hook do |context|
    render_options.map do |options|
      if context[:hook_caller].respond_to?(:render)
        context[:hook_caller].send(:render, {:locals => context}.merge(options))
      elsif context[:controller].is_a?(ActionController::Base)
        context[:controller].send(:render_to_string, {:locals => context}.merge(options))
      else
        raise "Cannot render #{self.name} hook from #{context[:hook_caller].class.name}"
      end
    end
  end
end

Instance Method Details

#configObject

Since:

  • 2.0.0



73
74
75
# File 'lib/redmine/hook/view_listener.rb', line 73

def config
  ActionController::Base.config
end

#controllerObject

Since:

  • 2.0.0



69
70
71
# File 'lib/redmine/hook/view_listener.rb', line 69

def controller
  nil
end