Class: Intranet::AbstractResponder
- Inherits:
-
Object
- Object
- Intranet::AbstractResponder
- Defined in:
- lib/intranet/abstract_responder.rb
Overview
The default implementation and interface of an Intranet module.
Class Method Summary collapse
-
.module_homepage ⇒ String/Nil
The homepage of the module, if any.
-
.module_name ⇒ String
Returns the name of the module.
-
.module_version ⇒ String
The version of the module, according to semantic versionning.
Instance Method Summary collapse
-
#css_dependencies ⇒ Array
deprecated
Deprecated.
Use #generate_page partial content feature, setting
:stylesheets
attribute of the returned body. -
#finalize ⇒ Object
Destroys the responder instance.
-
#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
andquery
. -
#in_menu? ⇒ Boolean
Specifies if the responder instance should be displayed in the main navigation menu or not.
-
#js_dependencies ⇒ Array
deprecated
Deprecated.
Use #generate_page partial content feature, setting
:scripts
attribute of the returned body. -
#resources_dir ⇒ String
Specifies the absolute path to the resources directory for that module.
Class Method Details
.module_homepage ⇒ String/Nil
The homepage of the module, if any.
16 |
# File 'lib/intranet/abstract_responder.rb', line 16 def self.module_homepage; end |
.module_name ⇒ String
Returns 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.
12 |
# File 'lib/intranet/abstract_responder.rb', line 12 def self.module_version; end |
Instance Method Details
#css_dependencies ⇒ Array
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.
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 <script> element to be included in the generated page. Keys are the one accepted by the HTML <script> tag. The:src
key may be either absolute or relative to the module root
56 57 58 |
# File 'lib/intranet/abstract_responder.rb', line 56 def generate_page(path, query) [404, '', ''] end |
#in_menu? ⇒ Boolean
Specifies if the responder instance should be displayed in the main navigation menu or not.
21 22 23 |
# File 'lib/intranet/abstract_responder.rb', line 21 def true end |
#js_dependencies ⇒ Array
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.
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.
30 31 32 |
# File 'lib/intranet/abstract_responder.rb', line 30 def resources_dir File.join(__dir__, 'resources') end |