lib/masterview/initializer.rb in masterview-0.3.1 vs lib/masterview/initializer.rb in masterview-0.3.2

- old
+ new

@@ -20,22 +20,22 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ # # == MasterView Configuration and Initialization -# +# # The MasterView template engine supports a number of configuration settings # which allow a client to easily customize its operation. # -# A MasterView::Configuration specification is used to allow the application to +# A MasterView::Configuration specification is used to allow the application to # specify custom configuration options during application startup. The configuration options # are installed in MasterView when its Initializer is run, which handles # loading and configuring MasterView for operation. -# +# #-- -# This style of configuration specification + initializer follows the technique -# used by Rails itself. A configuration specification can be customized by the +# This style of configuration specification + initializer follows the technique +# used by Rails itself. A configuration specification can be customized by the # application in its startup and is used by the Initialzer to configure # the MasterView template engine implementation at load time. # [D. Lewis 31-May-2006] #++ # @@ -54,27 +54,27 @@ DEBUG_DIRECTIVE_PATH = false #:nodoc: # temp debug module MasterView - # A Configuration holds all the configuration settings used the + # A Configuration holds all the configuration settings used the # MasterView::Initializer to configure the template engine. - # - # Configuration provides defaults that suit most Rails applications. - # You can change the default settings in the configuration to customize + # + # Configuration provides defaults that suit most Rails applications. + # You can change the default settings in the configuration to customize # MasterView with options suitable for your application. - # - # In the most common usage pattern, a Configuration instance initialized - # with the standard default settings is created implicitly when the + # + # In the most common usage pattern, a Configuration instance initialized + # with the standard default settings is created implicitly when the # Initializer is run, which happens automatically # when Masterview is installed as a plugin in a Rails application. # Application-specific settings are then loaded from the application's # +config+ directory and used by the Initializer to configure # the MasterView template engine for operation. - # + # # When using MasterView in a standalone application (i.e., not within rails), - # it is also possible to create the Configuration instance in advance and + # it is also possible to create the Configuration instance in advance and # pass it in explicitly to the Initializer. This technique can be useful # when it is necessary to establish the application root directory location # that MasterView uses during its operation or to specify to location of the # application's configuration files. # @@ -120,55 +120,55 @@ # === General Options # Path to the root location for the application. # Used for resolving relative references. - # + # # For a rails application, this is +RAILS_ROOT+. - # + # attr_accessor :root_path - # Path to the directory containing the application's MasterView + # Path to the directory containing the application's MasterView # configuration settings files (if any). If no configuration # directory or settings files are defined, MasterView runs # with the standard default configuration options. - # + # # Specified as a relative path from the application's +root_path+. - # + # # Default: for a Rails application, this is <tt>RAILS_ROOT/config/masterview</tt>. - # + # attr_accessor :config_dir_path - # Specify the directory where masterview templates are located + # Specify the directory where masterview templates are located # as a relative path from the application's +root_path+. def config_dir_path= rel_path #:nodoc: # bolts down abs path, thanks to our firm roots @config_dir_path = rel_path.nil? ? nil : ( rel_path.empty? ? root_path : File.join( root_path, rel_path )) end - # The current execution environment, if applicable + # The current execution environment, if applicable # (e.g., 'development', 'test', 'production'). - # + # # Used for loading application settings from config directory, if available. - # + # # For a Rails application, this is +RAILS_ENV+. - # + # attr_accessor :environment # Paths of directories to load directives from. - # - # The directory containing the built-in MasterView directives + # + # The directory containing the built-in MasterView directives # is installed by default. If the application provides # a <tt>masterview/directives</tt> directory in its +root_path+, # that directory is also automatically added to the directives # load path. - # + # # A directive load path entry specifiess a directory path # from which masterview directives are loaded. # Configuration options can optionally be specified to override # or extend any .metadata specifications in the directory. # - # Use add_directive_path to append additional directory path(s) + # Use add_directive_path to append additional directory path(s) # from which to load custom directives. # attr_accessor :directive_load_path # Deprecated - use directive_load_path @@ -185,76 +185,76 @@ # containing directive implementation classes to be loaded # into the MasterView processing configuration. # # Optionally specify options for the directives loaded # from this directory: - # + # # :default - metadata defaults - # + # # Metadata defaults extend or override any defaults specified # in the dir_path/.metadata file, if defined, allowing application # customization of the default defaults. # def add_directive_path(dir_path, options=nil) directive_load_path << DirectiveLoadPath::PathEntry.new( dir_path, options ) end - - # Relative path from +root_path+ of the temp directory used for creating + + # Relative path from +root_path+ of the temp directory used for creating # backup files before rebuilding/updating a template file. - # + # # Set to nil to suppress backups. - # + # # Default: <tt>RAILS_ROOT/tmp/masterview/rebuild/backups</tt> #-- # ISSUE: change this to use IOMgr mapping, how best to do this config?? # Leave existing mechanism here, but drop out of documentation and examples # until resolved #++ - attr_accessor :rebuild_backups_tmp_dir_path #:nodoc: + attr_accessor :rebuild_backups_tmp_dir_path #:nodoc: # Logger which will be used to record debug, warning, and error messages. - # + # # Supported loggers: # 'log4r' - the Log4r logging library # 'logger' - Logger in the ruby standard class library - # + # # Default: uses <code>Log4r</code> if available, otherwise a standard ruby +Logger+. attr_accessor :logger # Logging severity threshold for the logger. - # + # # Specify the name of the logging level to use with the configured logger. # Standard logging levels in both Log4r and ruby Logger are # +DEBUG+, +INFO+, +WARN+, +ERROR+, +FATAL+. # Other level names depend on the configured logger. - # + # # Default: +INFO+ for development, +WARN+ otherwise attr_accessor :log_level # Sets a block which will be executed after MasterView has been fully initialized. - # Useful for per-environment configuration which depends on the plugin being + # Useful for per-environment configuration which depends on the plugin being # fully initialized. def after_initialize(&after_initialize_block) @after_initialize_block = after_initialize_block end - + # Returns the block set in Configuration#after_initialize def after_initialize_block @after_initialize_block end # === Template Source Options # Path to the directory where masterview templates are located. - # + # # Assign the value as a relative path from the application's +root_path+ # or use the +template_src_dir_abs_path+ method to specify an absolute path. - # + # # Default: <tt>RAILS_ROOT/app/views</tt> for a rails application # or <tt>{root_path}/masterview/templates</tt> for a non-rails application. attr_accessor :template_src_dir_path - # Specify the directory where masterview templates are located + # Specify the directory where masterview templates are located # as a relative path from the application's +root_path+. def template_src_dir_path= rel_path #:nodoc: # bolts down abs path, thanks to our firm roots @template_src_dir_path = rel_path.nil? ? nil : ( rel_path.empty? ? root_path : File.join( root_path, rel_path )) end @@ -263,105 +263,105 @@ @template_src_dir_path = abs_path end # Filename pattern for masterview template files # within the template source directory. - # + # # Default: <tt>'*.html'</tt> attr_accessor :template_filename_pattern # Regex pattern specifications for identifying the base directory # on asset references in a template document to convert # design-time assert references for images, stylesheets, # and javascript files into relative references for use # with the standard Rails asset helper functions. - # + # # The patterns are a hash indexed by asset type. # Asset types are :images, :stylesheets, :javascripts - # - # The standard patterns match path prefixes up through + # + # The standard patterns match path prefixes up through # <code>public/<i>asset-type</i></code>. For example, # an <code>mv:stylesheet_link</code> directive of the form: - # + # # <link rel="stylesheet" type="text/css" href="../../../public/stylesheets/mystyles.css" mv:stylesheet_link="" /> - # + # # would match the standard base-dir prefix and result in: - # + # # <%= stylesheet_link_tag "mystyles" %> - # + # attr_accessor :template_asset_base_ref_pattern # === Template Generation Options # Path to the directory where Masterview template output (rhtml) # will be generated. - # + # # Assign the value as a relative path from the application's +root_path+ # or use the +template_dst_dir_abs_path+ method to specify an absolute path. - # + # # Default: <tt>RAILS_ROOT/app/views</tt> attr_accessor :template_dst_dir_path - # Specify the directory where masterview template output is generated + # Specify the directory where masterview template output is generated # as a relative path from the application's +root_path+. def template_dst_dir_path= rel_path #:nodoc: # bolts down abs path, thanks to our firm roots @template_dst_dir_path = rel_path.nil? ? nil : ( rel_path.empty? ? root_path : File.join( root_path, rel_path )) end # Specify the absolute path to the directory where masterview template output is generated. def template_dst_dir_abs_path(abs_path) @template_dst_dir_path = abs_path end - # Filename extension to use for generated output files if not + # Filename extension to use for generated output files if not # explicitly specified in the +mv:generate+ attribute value. - # + # # Default: <tt>'.rhtml'</tt> attr_accessor :output_filename_extension # Filename extension to use for generated files if not explicitly specified. - # + # # Default: <tt>'.rhtml'</tt> attr_accessor :generated_file_default_extension #FIXME # Boolean which controls whether to include a comment in template # output files indicating that the file was generated by MasterView. - # + # # By default, a warning comment is generated in template output files # indicating that the file was generated by MasterView from a template # and should not be directly edited, as any changes would be lost when the # output file is regenerated. - # + # # Default: +true+ attr_accessor :include_generated_file_comment - # Text for generated-file comment inserted in rhtml template output files + # Text for generated-file comment inserted in rhtml template output files # generated by MasterView. - # + # # Standard comment includes the name of the master template file which contains # the source to edit. - # + # # Variable substitution on the comment text will replace a reference # to <tt>{template_path}</tt> with the pathname of the source template file. - # + # attr_accessor :generated_file_comment # === Template Parsing Options - # Specify whether MasterView should handle exceptions when + # Specify whether MasterView should handle exceptions when # parsing template files. - # - # Exceptions that occur during template parsing are always + # + # Exceptions that occur during template parsing are always # recorded in the debug log. These are generally problems # caused by invalid (x)html in the template. - # + # # Set to +true+ to have the template parser catch exceptions and # continue processing after logging a problem report. - # + # # Set to +false+ to have exceptions raised to the application. - # + # # Default: +true+ - # + # attr_accessor :handle_parse_exceptions # Default option settings for template parsing (a hash) # :tidy => false - run tidy before parsing (tidy_path must be set if enabled) # :escape_erb => true - escapes <% %> before parsing @@ -373,123 +373,155 @@ # Allows invalid xhmtl to be corrected before masterview template parsing is performed. attr_accessor :tidy_path # XML name space prefix for builtin MasterView directive attributes in template html. # e.g. mv:generate="target.rhtml". - # + # # Default: <tt>'mv:'</tt> attr_accessor :namespace_prefix # XML name space prefix for MasterView extension directive attributes in template html. # e.g. mvx:custom_directive="foo". - # + # # Default: <tt>'mvx:'</tt> attr_accessor :namespace_prefix_extensions # Xhtml-safe substitution for '<%' in a masterview template # NOTE: you must also update inline_erb_substitution_regex if this is changed. - # + # # Default: <tt>'{{{'</tt> attr_accessor :inline_erb_start # Xhtml safe substitution for '%>'in a masterview template # NOTE: you must also update inline_erb_substitution_regex if this is changed. - # + # # Default: <tt>'}}}'</tt> attr_accessor :inline_erb_end # regex used to find escaped inline_erb markup. # Needs to match +inline_erb_start+ and +inline_erb_end+. attr_accessor :inline_erb_substitution_regex # === Rails Application Options - # Boolean which specifies whether masterview templates are parsed + # Boolean which specifies whether masterview templates are parsed # during initial application startup loading. - # + # # Set to +false+ to disable all load-time parsing. # Template parsing must be manually triggered when the auto-parse option is disabled. - # + # # Default: +true+ attr_accessor :parse_masterview_templates_at_startup # Boolean which determines whether masterview templates are automatically # reparsed if the template changes after initial application loading. - # + # # Set to +true+ to monitor masterview templates for file system changes # during Rails request dispatching. - # + # # Set to +false+ to disable changed-template monitoring. # Template parsing must be manually triggered when the auto-parse option is disabled. - # + # # This option is only supported when running as part of a Rails application. # It is enabled by default in the standard Rails development configuration # (+parse_masterview_templates_at_startup+ is enabled and - # ActionController::Base.perform_caching is false so that changed classes + # ActionController::Base.perform_caching is false so that changed classes # are dynamically reloaded during request dispatching). - # + # # Automatic change-detection and reparsing of masterview templates is disabled # by default in the usual Rails configuration for production mode # (ActionController::Base.perform_caching is on to enable loaded class caching). - # - # Default: +true+ if parse_masterview_templates_at_startup is enabled + # + # Default: +true+ if parse_masterview_templates_at_startup is enabled # and ActionController is reloading changed classes (no caching) attr_accessor :reparse_changed_masterview_templates + # Authorization module which will be mixed into MasterView Admin controller + # to determine whether access should be granted to a user. + # + # The module must implement the method allow_access? which returns a boolean + # indicating whether access is allowed to the MasterView administration pages. + # By default, the module name for a custom mixin is MasterViewAdminAuthMixin. + # + # The admin_auth_check mixin is included in an ApplicationController subclass + # and thus may use any services available to controllers in your application. + # + # Defaults to local machine access only using local_request? check. + # Automatically installs custom mixin from app/masterview/admin_auth_mixin.rb + # if available. + # + # To load a different file from app/masterview or use a different module name: + # + # config.admin_auth_mixin = { + # :file => 'alt_admin_auth_mixin', # module file in #{RAILS_ROOT}/app/masterview dir + # :module => :AltMasterViewAdminAuthMixin, # default is :MasterViewAdminAuthMixin + # } + # + # To load a mixin from the rails app's lib directory: + # + # config.admin_auth_mixin = { + # :file => 'lib/custom/mv_admin_auth_mixin', # module file in rails lib dir + # :file_loc => :RAILS_ROOT, # default location for rel refs is #{RAILS_ROOT}/app/masterview + # :module => :CustomMasterViewAdminAuthMixin, # default is :MasterViewAdminAuthMixin + # } + # + # see examples/rails_app_admin_auth/admin_auth_mixin.rb for more details + attr_accessor :admin_auth_mixin + # Enable MasterView admin pages in the rails application. - # + # # Enables the masterview admin controller at <tt>http://yourappdomain/masterview</tt>. - # + # # Default: +false+ attr_accessor :enable_admin_pages # Enable MasterView admin view rhtml feature - # - # If MasterView admin pages are enabled, then you may set this feature to true and it + # + # If MasterView admin pages are enabled, then you may set this feature to true and it # will allow you to get to the generated rhtml from the MasterView admin page which is # especially useful for debugging or understanding how MasterView is interpretting the - # your templates. When enabled you may click on any of the generated rhtml parts from + # your templates. When enabled you may click on any of the generated rhtml parts from # the list view and it will show you the rhtml that is generated. For security purposes - # you will probably want this to disable this feature in production (or even better + # you will probably want this to disable this feature in production (or even better # disable admin pages itself). Alternatively there is a rake task called mv:view_rhtml # which allows you to see the rhtml from the command line (regardless of this setting). # # Default +false+ attr_accessor :enable_view_rhtml - # Generate rhtml files if true, rails will load them from there. Otherwise when this - # setting is false, enable rails app to read rhtml(erb) directly from MasterView cache + # Generate rhtml files if true, rails will load them from there. Otherwise when this + # setting is false, enable rails app to read rhtml(erb) directly from MasterView cache # bypassing the serialization to the file system. # Default: +false+ attr_accessor :generate_rhtml_files # These are the original default parser options, whatever is set in the config - # will be merged with these to arrive at the result. This allows us to easily + # will be merged with these to arrive at the result. This allows us to easily # add new defaults in and even if users empty this hash, the defaults will get added # to disable they specifically set something to false or nil OriginalDefaultParserOptions = { :tidy => false, :escape_erb => true, :default_generate => true } # :nodoc: save the originals # list of [ :log_level, msg ] pairs for config initialization/validation messages # used by the initializer to validate load path and report any problems attr_accessor :initialization_messages #:nodoc: # Create a new Configuration instance, initialized with the default # values. - # + # # Optional arguments to the constructor allow for initializing defaults # for a rails app when not actually running rails or for initializing # defaults for a standalone app with context anchored at some well-defined # point in space (other than where we're actually running). - # + # # :app_root_path => path to the root directory of the application # :rails_app_root_path => path to the root directory of a Rails app # :environment => current environment for loading settings - # + # # The +app_root_path+ and +rails_app_root_path+ arguments are mutually exclusive. # Use +rails_app_root_path+ when operating on a Rails application which # isn't actually running; use +app_root_path+ for a non-rails application. - # + # def initialize( params={} ) #:nodoc: rails_env = (defined?(RAILS_ENV)) ? RAILS_ENV : nil # unpack the supported keyword args app_root_path = params[:app_root_path] @@ -563,19 +595,19 @@ else #ISSUE: add hook here to check for MASTERVIEW_ROOT_PATH or ENV[xxx]??? self.root_path = program_root_path end # For a rails app, we have a point of view on where to find config files. - # A standalone client needs to proactively tell us where to find their settings. + # A standalone client needs to proactively tell us where to find their settings. self.config_dir_path = rails_app? ? "config/masterview" : nil self.environment = on_rails? ? ::RAILS_ENV : env self.directive_load_path = DirectiveLoadPath::Path.new add_directive_path builtin_directives_path, { :use_masterview_namespace => true, } discover_standard_directive_path_additions() #TODO: if rails_app? && File.exist?( "#{rails_root_path}/app/masterview/directives" ) THEN append it as well - self.rebuild_backups_tmp_dir_path = rails_app? ? File.join( rails_root_path, 'tmp/masterview/rebuild/backups') : nil + self.rebuild_backups_tmp_dir_path = rails_app? ? File.join( rails_root_path, 'tmp/masterview/rebuild/backups') : nil # use Log4r by default if available, otherwise Logger from standard ruby library # find out if Kernel#require will succeed if we try to load Log4R log4r_dir = $:.detect { |dir| File.exists?("#{dir}/log4r.rb") } #? path_contains? predicate somewhere?? self.logger = log4r_dir ? 'log4r' : 'logger' #self.log_level = nil # use the default level of the logger @@ -603,14 +635,14 @@ self.template_dst_dir_path = rails_app? ? 'app/views' : 'masterview/output' # bolts down abs ref self.output_filename_extension = '.rhtml' self.generated_file_default_extension = '.rhtml' self.include_generated_file_comment = true self.generated_file_comment = <<-END -# WARNING - This is a generated file created by MasterView. +# WARNING - This is a generated file created by MasterView. # Do not edit - changes will be lost when this file is re-generated. -# -# To make changes, edit the MasterView source file located at: +# +# To make changes, edit the MasterView source file located at: END self.generated_file_comment << '# #{template_path}' # carefully avoid premature subst eval STDOUT.puts "...template_dst_dir_path=#{template_dst_dir_path || 'nil'}" if debug_TRACE_HACK @@ -626,14 +658,15 @@ self.inline_erb_substitution_regex = /\{\{\{(([^}]|\}[^}]|\}\}[^}])*)\}\}\}/ # Rails application options self.parse_masterview_templates_at_startup = true self.reparse_changed_masterview_templates = on_rails? ? (not ActionController::Base.perform_caching) : false + self.admin_auth_mixin = nil # if defined then this module will be included in MasterView controller self.enable_admin_pages = is_development self.enable_view_rhtml = is_development self.generate_rhtml_files = false - + STDOUT.puts "...mv config initialized with default settings\n" if debug_TRACE_HACK self.initialization_messages = [] # for installer validation checking and problem reporting end @@ -646,11 +679,11 @@ # @running_rails = has_rails_context && (defined?(::Dispatcher.dispatch)) != nil end # see if this app has the std file structure that indicates a rails application def looks_like_rails_app? #:nodoc: - std_rails_directories = [ 'app', 'config', 'public' ] + std_rails_directories = [ 'app', 'config', 'public' ] std_rails_directories.each { | dir_path | return if ! File.directory?(dir_path) } true end @@ -670,20 +703,83 @@ # By default the file is at <tt>config/masterview/settings.rb</tt>. def app_settings_path config_dir_path ? "#{config_dir_path}/settings.rb" : nil end - # The path to the current environment's settings file (development.rb, etc.). + # The path to the current environment's settings file (development.rb, etc.). # By default the file is at <tt>config/masterview/environments/{environment}.rb</tt>. def environment_settings_path (config_dir_path && environment) ? "#{config_dir_path}/environments/#{environment}.rb" : nil end + # Add masterview directive implementations from plugins + # to the masterview directive load path + # + # EXPERIMENTAL PROTOTYPE - NOT YET PUBLICIZED [DJL 13-Feb-2007] + def add_plugin_directives(*base_paths) #:nodo: + # append plugin directives in alphabetical order, per Rails plugin loading + plugin_directives = find_plugin_directives(base_paths) + plugin_directives.each { | plugin_dir_path | + add_directive_path plugin_dir_path + } + plugin_directives + end + + protected + # Return list of directives paths from plugins + def find_plugin_directives(*base_paths) + directive_paths = [] + find_plugins(base_paths).each do | plugin_dir_path | + next if File.basename(plugin_dir_path) == 'masterview' #skip masterview's own built-in directives + directive_dir_path = File.join(plugin_dir_path, 'directives') + if File.directory?(directive_dir_path) + directive_paths << directive_dir_path + else + directive_dir_path = File.join(plugin_dir_path, 'lib', 'directives') + if File.directory?(directive_dir_path) + directive_paths << directive_dir_path + end + end + end + directive_paths + end + + # cloned from Rails::Initializer {1.1.2); updated for Rails 1.2.2 + # Return a list of plugin paths within base_path. A plugin path is + # a directory that contains either a lib directory or an init.rb file. + # This recurses into directories which are not plugin paths, so you + # may organize your plugins within the plugin path. + def find_plugins(*base_paths) #:nodoc: + base_paths.flatten.inject([]) do |plugins, base_path| + Dir.glob(File.join(base_path, '*')).each do |path| + if plugin_path?(path) + plugins << path if plugin_enabled?(path) #enabled check per Rails 1.2 + elsif File.directory?(path) + plugins += find_plugins(path) + end + end + plugins + end + end + + # cloned from Rails::Initializer {1.1.2) + def plugin_path?(path) #:nodoc: + File.directory?(path) and (File.directory?(File.join(path, 'lib')) or File.file?(File.join(path, 'init.rb'))) + end + + # cloned from Rails::Initializer {1.2.2) + def plugin_enabled?(path) #:nodoc: + #ISSUE: how can our plugin init get at the rails config which is loading it? + #... don't want to duplicate notion of enabled plugins + ###TODO: (rails) configuration.plugins.nil? || configuration.plugins.include?(File.basename(path)) + true + end + end # The Initializer is responsible for processing the MasterView configuration. - # + # # In a Rails application using the MasterView facilities, # the Initializer is run automatically during rails startup # when the plugin is loaded. No special action is required # by the application. # @@ -691,24 +787,24 @@ # in your application's config directory, setting standard settings # in <tt>config/masterview/settings.rb</tt> and optionally setting # environment-specific values in <tt>config/masterview/environments/{environment}.rb</tt>. # The settings files are executed with the +config+ variable initialized to # the current configuration. This is the standard technique for a Rails application. - # - # An application using the MasterView facilities outside the Rails context + # + # An application using the MasterView facilities outside the Rails context # must run the MasterView::Initializer during its application startup. - # + # # It can be run as a simple command that uses the default configuration: # # require 'masterview/initializer' # MasterView::Initializer.run # # or more simply just load MasterView: - # + # # require 'masterview' # - # In order to customize the MasterView configuration outside the Rails context, + # In order to customize the MasterView configuration outside the Rails context, # you must explicitly provide a basic Configuration to the Initializer # which specifies the root location of the application and the paths # to the template directories if the default locations are not appropriate. # Configuration settings can be set directly or provided through config # settings file by specifying the +config_dir_path+ to the application's @@ -731,21 +827,21 @@ # you can specify explicitly which initialization routine you want: # # MasterView::Initializer.run(:initialize_configuration) # # This is useful if you only want the config settings initialized, without - # incurring the overhead of completely loading the entire component. + # incurring the overhead of completely loading the entire component. # def self.run(command = :process, configuration = Configuration.new) if block_given? yield configuration end initializer = new(configuration) initializer.send(command) initializer end - + # Create a new Initializer instance that references the given Configuration # instance. def initialize(config) #:nodoc: @configuration = config end @@ -758,18 +854,18 @@ complete_plugin_installation end # Load the Masterview configuration settings. # Does *not* load and configure the template engine. - # + # # Intended for use in testing. def initialize_configuration #?? return if MasterView.const_defined?(:ConfigSettings) ?? #ISSUE: support format_datetime option on the logger settings?? [DJL 30-Jul-2006] - configuration.initialization_messages << [ :info, + configuration.initialization_messages << [ :info, "Initializing MasterView configuration (#{DateTime.now.strftime('%Y-%m-%d %H:%M')})" ] - configuration.initialization_messages << [ :info, + configuration.initialization_messages << [ :info, "Program name = #{$PROGRAM_NAME}" ] # log the program that is starting the session load_config_settings ensure_valid_settings install_config_settings # make a final check for running_rails? (in case config settings changed scripts spec) @@ -777,11 +873,11 @@ # keep a permananent record of how we got started configuration.freeze MasterView.const_set('ConfigSettings', configuration) end - # Load configuration settings from <tt>{config.config_dir_path}/settings.rb</tt> + # Load configuration settings from <tt>{config.config_dir_path}/settings.rb</tt> # and <tt>{config.config_dir_path}/environments/{config.environment}.rb</tt>. def load_config_settings #:nodoc: load_app_settings load_environment_settings end @@ -789,11 +885,11 @@ # Loads application config settings. def load_app_settings #:nodoc: load_settings_file(configuration.app_settings_path) end - # Loads config settings for the environment specified by + # Loads config settings for the environment specified by # Configuration#environment_path, which # is typically one of development, testing, or production. def load_environment_settings #:nodoc: load_settings_file(configuration.environment_settings_path) end @@ -833,11 +929,11 @@ # Otherwise all the fine rails view template stuff doesn't work end # Rails application options if config.on_rails? - # ensure we don't activate runtime reparsing if we didn't autoparse at startup + # ensure we don't activate runtime reparsing if we didn't autoparse at startup # (?overzealous? But this what we're currently asserting as the intended behavior in the docs) if not config.parse_masterview_templates_at_startup config.reparse_changed_masterview_templates = false end #else @@ -893,12 +989,12 @@ end # Complete installation of masterview after its own code has been loaded def complete_plugin_installation #:nodoc: #?? return if MasterView.const_defined?(:Initialized) ?? - MasterView::DirectiveRegistry.register_default_namespaces( - configuration.namespace_prefix, + MasterView::DirectiveRegistry.register_default_namespaces( + configuration.namespace_prefix, configuration.namespace_prefix_extensions ) initialize_logger initialize_mio #Back out experiment: causes load order problems ##load_directives # held off on this until logger is installed @@ -923,18 +1019,18 @@ config = configuration MasterView.const_set('DefaultSerializer', TemplateProcessing::MIOSerializer) # all root_path directory anchor points for I/O are expanded absolute paths io_mgr = MIO::MIOTrees.new template_extension = File.extname( config.template_filename_pattern ) - io_mgr.template = MIO::FileMIOTree.new( config.template_src_dir_path, template_extension, + io_mgr.template = MIO::FileMIOTree.new( config.template_src_dir_path, template_extension, :escape_erb => DefaultParserOptions[:escape_erb], # use DefaultParserOptions since already has config merged - :tidy => DefaultParserOptions[:tidy], + :tidy => DefaultParserOptions[:tidy], :default_generate => DefaultParserOptions[:default_generate], #TODO: expose the following in Configuration.default_parser_options and document - :caching => false, + :caching => false, :logging => true ) - + if config.generate_rhtml_files io_mgr.erb = MIO::FileMIOTree.new( config.template_dst_dir_path, config.generated_file_default_extension, :logging => true) else io_mgr.erb = MIO::RailsErbCacheMIOTree.new( config.generated_file_default_extension, :logging => true) end @@ -1005,10 +1101,10 @@ require 'masterview/rails_ext/action_controller_erb_direct' #:nodoc: MasterView::LoadedFeatures[:rails_erb_mv_direct] = true end end - # Fires the user-supplied after_initialize block (Configuration#after_initialize) + # Fires the user-supplied after_initialize block (Configuration#after_initialize) def after_initialize #:nodoc: configuration.after_initialize_block.call if configuration.after_initialize_block end end