Class: Intranet::AbstractResponder

Inherits:
Object
  • Object
show all
Defined in:
lib/intranet/abstract_responder.rb

Overview

The default implementation and interface of an Intranet module.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.module_homepage ⇒ String/Nil

The homepage of the module, if any.

Returns:

  • (String/Nil) —

    The homepage URL of the module, or nil if no homepage is available.



16
# File 'lib/intranet/abstract_responder.rb', line 16

def self.module_homepage; end

.module_name ⇒ String

Returns the name of the module.

Returns:

  • (String) —

    The name of the module



8
# File 'lib/intranet/abstract_responder.rb', line 8

def self.module_name; end

.module_version ⇒ String

The version of the module, according to semantic versionning.

Returns:

  • (String) —

    The version of the module



12
# File 'lib/intranet/abstract_responder.rb', line 12

def self.module_version; end

Instance Method Details

#css_dependencies ⇒ Array

Deprecated.

Use #generate_page partial content feature, setting :stylesheets attribute of the returned body.

Provides the list of Cascade Style Sheets (CSS) dependencies for this module, either using absolute or relative (from the module root) paths.

Returns:

  • (Array) —

    The list of CSS dependencies, as absolute path or relative to the module root URL.



66
67
68
# File 'lib/intranet/abstract_responder.rb', line 66

def css_dependencies
  []
end

#finalize ⇒ Object

Destroys the responder instance. This method gets called when server is shut down.



36
37
38
# File 'lib/intranet/abstract_responder.rb', line 36

def finalize
  # nothing to do
end

#generate_page(path, query) ⇒ Array<Integer, String, String> or Array<Integer, String, Hash>

Generates the HTML answer (HTTP return code, MIME type and body) associated to the given path and query.

The function may return a partial content, in which case the HTTP return code must be 206 and the answer body is expected to be a Hash with the following keys:

  • :title (mandatory): the page title
  • :content (mandatory): the partial content
  • :stylesheets (optional): an array of the required Cascade Style Sheets (CSS) files, either absolute or relative to the module root
  • :scripts (optional): an array of hashes, each representing a

    Specifies if the responder instance should be displayed in the main navigation menu or not.

    Returns:

    • (Boolean) —

      True if the responder instance should be added to the main navigation menu, False otherwise.

    
    
    21
    22
    23
    # File 'lib/intranet/abstract_responder.rb', line 21
    
    def in_menu?
      true
    end

#js_dependencies ⇒ Array

Deprecated.

Use #generate_page partial content feature, setting :scripts attribute of the returned body.

Provides the list of Javascript files (JS) dependencies for this module, either using absolute or relative (from the module root) paths.

Returns:

  • (Array) —

    The list of JS dependencies, as absolute path or relative to the module root URL.



76
77
78
# File 'lib/intranet/abstract_responder.rb', line 76

def js_dependencies
  []
end

#resources_dir ⇒ String

Specifies the absolute path to the resources directory for that module. This directory should contain three subdirectories: haml/, locales/ and www/. This method should be redefined to overwrite this default value with the actual resources directory path.

Returns:

  • (String) —

    The absolute path to the resources directory for the module.



30
31
32
# File 'lib/intranet/abstract_responder.rb', line 30

def resources_dir
  File.join(__dir__, 'resources')
end