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_homepageString/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_nameString

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_versionString

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_dependenciesArray

Provides the list of Cascade Style Sheets (CSS) dependencies for this module, either using absolute or relative (from the module root) paths. If redefined, this method should probably append dependencies rather than overwriting them.

Returns:

  • (Array)

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



53
54
55
# File 'lib/intranet/abstract_responder.rb', line 53

def css_dependencies
  ['/design/style.css']
end

#finalizeObject

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

Generates the HTML content associated to the given path and query.

Parameters:

  • path (String)

    The requested URI, relative to that module root URI

  • query (Hash)

    The URI variable/value pairs, if any

Returns:

  • (Array)

    The HTTP return code, the MIME type and the answer body.



44
45
46
# File 'lib/intranet/abstract_responder.rb', line 44

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.

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_dependenciesArray

Provides the list of Javascript files (JS) dependencies for this module, either using absolute or relative (from the module root) paths. If redefined, this method should probably append dependencies rather than overwriting them.

Returns:

  • (Array)

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



62
63
64
# File 'lib/intranet/abstract_responder.rb', line 62

def js_dependencies
  ['/design/nav.js']
end

#resources_dirString

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