Class: Intranet::Pictures::Responder
- Inherits:
-
AbstractResponder
- Object
- AbstractResponder
- Intranet::Pictures::Responder
- Includes:
- Core::HamlWrapper
- Defined in:
- lib/intranet/pictures/responder.rb
Overview
The responder for the Pictures monitor module of the Intranet.
Class Method Summary collapse
-
.module_homepage ⇒ String
Returns the homepage URL of the module.
-
.module_name ⇒ String
Returns the name of the module.
-
.module_version ⇒ String
Returns the version of the module, according to semantic versionning.
Instance Method Summary collapse
-
#generate_page(path, query) ⇒ Integer, String
Generates the HTML content associated to the given
pathandquery. -
#in_menu? ⇒ Boolean
Specifies if the responder instance should be displayed in the main navigation menu or not.
-
#initialize(provider, defaults, in_menu = true) ⇒ Responder
constructor
Initializes a new Pictures responder instance.
-
#resources_dir ⇒ String
Specifies the absolute path to the resources directory for that module.
-
#title ⇒ String
The title of the Pictures module, as displayed on the web page.
Constructor Details
#initialize(provider, defaults, in_menu = true) ⇒ Responder
Initializes a new Pictures responder instance.
43 44 45 46 47 |
# File 'lib/intranet/pictures/responder.rb', line 43 def initialize(provider, defaults, = true) @provider = provider @defaults = defaults @in_menu = end |
Class Method Details
.module_homepage ⇒ String
Returns the homepage URL of the module.
29 30 31 |
# File 'lib/intranet/pictures/responder.rb', line 29 def self.module_homepage HOMEPAGE_URL end |
.module_name ⇒ String
Returns the name of the module.
17 18 19 |
# File 'lib/intranet/pictures/responder.rb', line 17 def self.module_name NAME end |
.module_version ⇒ String
Returns the version of the module, according to semantic versionning.
23 24 25 |
# File 'lib/intranet/pictures/responder.rb', line 23 def self.module_version VERSION end |
Instance Method Details
#generate_page(path, query) ⇒ Integer, String
Generates the HTML content associated to the given path and query.
Relevant queries are as follows:
- If
pathis/browse.html, key/value pairs may be used to restrict the displayed images to those satisfying all the pairs. Moreover,sort_by(followed by a key),sort_order(followed by eitherascordesc) andgroup_bymay be used to alter the way images are displayed. - If
pathis/api/group_thumbnailor/api/group_brief, query must contain only a single key/value pair designating the pictures group. - If
pathis/api/pictures, key/value pairs may be used to restrict the displayed images to those satisfying all the pairs. Moreover,sort_by(followed by a key), andsort_order(followed by eitherascordesc) may be used to alter the order in which images are returned. - If
pathisapi/picture, key/value pairs must be used to select a single image from the gallery.
When path is /api/pictures, the selected pictures are returned in JSON format (REST API)
with the following structure:
[
{ "id": "...", "height": 480, "width": 640, "title": "...", "datetime": "...", ... },
{ ... }
]
88 89 90 91 92 93 94 95 |
# File 'lib/intranet/pictures/responder.rb', line 88 def generate_page(path, query) case path when %r{^/index\.html$} then serve_home(query) when %r{^/api/} then serve_api(path.gsub(%r{^/api}, ''), query) when %r{^/i18n\.js$} then serve_i18n_js else super end end |
#in_menu? ⇒ Boolean
Specifies if the responder instance should be displayed in the main navigation menu or not.
52 53 54 |
# File 'lib/intranet/pictures/responder.rb', line 52 def @in_menu end |
#resources_dir ⇒ String
Specifies the absolute path to the resources directory for that module.
58 59 60 |
# File 'lib/intranet/pictures/responder.rb', line 58 def resources_dir File.absolute_path(File.join('..', 'resources'), __dir__) end |
#title ⇒ String
The title of the Pictures module, as displayed on the web page.
99 100 101 |
# File 'lib/intranet/pictures/responder.rb', line 99 def title I18n.t('pictures.menu') end |