module Strelka::App::FancyErrors
Fancy/useful error output for Strelka
appliation development. This plugin uses the Strelka
default :errors and :templating plugins.
Constants
- CONFIG_DEFAULTS
Configurability configuration defaults
- DEFAULT_DATADIR
The data directory in the project if that exists, otherwise the gem datadir
- REVISION
Version-control revision constant
- VERSION
Library version constant
Public Class Methods
configure( config=nil )
click to toggle source
Configurability API – Configure the plugin
# File lib/strelka/app/fancyerrors.rb, line 65 def self::configure( config=nil ) if config self.log.debug "Configuring fancy error templates: %p" % [ config ] self.templates_dir = Pathname( config[:templates_dir] ) if config[:templates_dir] end end
included( mod )
click to toggle source
Inclusion callback – add the plugin's templates directory right before activation so loading the config doesn't clobber it.
Calls superclass method
# File lib/strelka/app/fancyerrors.rb, line 75 def self::included( mod ) # Add the plugin's template directory to Inversion's template path Inversion::Template.template_paths.push( self.templates_dir ) super end
Public Instance Methods
fancy_error_template( key, response, status_info )
click to toggle source
Load the template that corresponds to key
and populate it with the given status_info
. If the application has a layout template, wrap it in that. Otherwise, use a simple default layout template.
# File lib/strelka/app/fancyerrors.rb, line 113 def fancy_error_template( key, response, status_info ) self.log.info "[:fancyerrors] Handling %d status response." % [ status_info[:status] ] content = self.template( key ) content.status_info = status_info self.log.debug " error content template loaded from %s" % [ content.source_file || 'memory' ] # If there's a layout template, just return the template as-is so # templating will wrap it correctly return content if self.layout self.log.debug " using the fancyerrors layout template." # Otherwise, wrap it in a simple layout of our own layout = self.template( :fancy_error_layout ) layout.body = content layout.status_info = status_info self.log.debug " error layout template loaded from %s" % [ layout.source_file || 'memory' ] # :templating method self.set_common_attributes( layout, response.request ) return layout end
templates_dir()
click to toggle source
The path to the error templates
# File lib/strelka/app/fancyerrors.rb, line 60 singleton_attr_accessor :templates_dir