Module: YARD::Server::Commands::StaticFileHelpers
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
|
|
Defined in: | lib/yard/server/commands/static_file_helpers.rb |
Overview
Include this module to get access to #static_template_file? and #favicon? helpers.
Constant Summary
::YARD::Server::HTTPUtils
- Included
DefaultMimeTypes, ESCAPED, NONASCII, UNESCAPED, UNESCAPED_FORM, UNESCAPED_PCHAR
Class Method Summary
- .find_file(adapter, url) mod_func
Instance Attribute Summary
-
#favicon? ⇒ Boolean
readonly
Serves an empty favicon.
-
#static_template_file? ⇒ void
readonly
Attempts to route a path to a static template file.
Instance Method Summary
::YARD::Server::HTTPUtils
- Included
#_escape, #_make_regex, #_make_regex!, #_unescape, | |
#dequote | Removes quotes and escapes from |
#escape | Escapes HTTP reserved and unwise characters in |
#escape8bit | Escapes 8 bit characters in |
#escape_form | Escapes form reserved characters in |
#escape_path | Escapes path |
#load_mime_types | Loads Apache-compatible mime.types in |
#mime_type | Returns the mime type of |
#normalize_path | Normalizes a request path. |
#parse_form_data | Parses form data in |
#parse_header | Parses an HTTP header |
#parse_query | Parses the query component of a URI in |
#parse_qvalues | Parses q values in |
#parse_range_header | Parses a Range header value |
#quote | Quotes and escapes quotes in |
#split_header_value | Splits a header value |
#unescape | Unescapes HTTP reserved and unwise characters in |
#unescape_form | Unescapes form reserved characters in |
Class Method Details
.find_file(adapter, url) (mod_func)
# File 'lib/yard/server/commands/static_file_helpers.rb', line 42
def find_file(adapter, url) # this const was defined in StaticFileCommand originally static_paths = StaticFileCommand::STATIC_PATHS file = nil ([adapter.document_root] + static_paths.reverse).compact.each do |path_prefix| file = File.join(path_prefix, url) break if File.exist?(file) file = nil end # Search in default/fulldoc/html template if nothing in static asset paths assets_template = Templates::Engine.template(:default, :fulldoc, :html) file || assets_template.find_file(url) end
Instance Attribute Details
#favicon? ⇒ Boolean
(readonly)
Serves an empty favicon.
# File 'lib/yard/server/commands/static_file_helpers.rb', line 14
def favicon? return unless request.path == '/favicon.ico' headers['Content-Type'] = 'image/png' self.status = 200 self.body = '' raise FinishRequest end
#static_template_file? ⇒ void
(readonly)
This method returns an undefined value.
Attempts to route a path to a static template file.
# File 'lib/yard/server/commands/static_file_helpers.rb', line 26
def static_template_file? # this const was defined in StaticFileCommand originally default_mime_types = StaticFileCommand::DefaultMimeTypes file = find_file(adapter, path) if file ext = "." + (path[/\.(\w+)$/, 1] || "html") headers['Content-Type'] = mime_type(ext, default_mime_types) self.body = File.read(file) raise FinishRequest end end