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, recents = [], home_groups = [], 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
Returns the title of the Pictures module, as displayed on the web page.
Constructor Details
#initialize(provider, recents = [], home_groups = [], in_menu = true) ⇒ Responder
Initializes a new Pictures responder instance.
54 55 56 57 58 59 |
# File 'lib/intranet/pictures/responder.rb', line 54 def initialize(provider, recents = [], home_groups = [], = true) @provider = provider @recents = recents @in_menu = @home_groups = home_groups 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": "...", ... },
{ ... }
]
100 101 102 103 104 105 106 107 108 |
# File 'lib/intranet/pictures/responder.rb', line 100 def generate_page(path, query) case path when %r{^/index\.html$} then serve_home when %r{^/browse\.html$} then serve_browse(query) when %r{^/api/} then serve_api(path.gsub(%r{^/api}, ''), query) when %r{^/i18n\.js$} then serve_i18n_js else super(path, query) end end |
#in_menu? ⇒ Boolean
Specifies if the responder instance should be displayed in the main navigation menu or not.
64 65 66 |
# File 'lib/intranet/pictures/responder.rb', line 64 def @in_menu end |
#resources_dir ⇒ String
Specifies the absolute path to the resources directory for that module.
70 71 72 |
# File 'lib/intranet/pictures/responder.rb', line 70 def resources_dir File.absolute_path(File.join('..', 'resources'), __dir__) end |
#title ⇒ String
Returns the title of the Pictures module, as displayed on the web page.
112 113 114 |
# File 'lib/intranet/pictures/responder.rb', line 112 def title @provider.title end |