Sha256: d795d13a0aadc3942360cafdb88c3323186541f87d6c122fb1c8b0e50c9c085b
Contents?: true
Size: 1.98 KB
Versions: 4
Compression:
Stored size: 1.98 KB
Contents
#!/usr/bin/env ruby require 'pluginfactory' require 'strelka/mixins' require 'strelka/cms' unless defined?( Strelka::CMS ) require 'strelka/cms/page' unless defined?( Strelka::CMS::Page ) # An abstract base class for page filters in the Strelka CMS. # # A page filter replaces one or more placeholders with generated or altered # content. # class Strelka::CMS::PageFilter extend Loggability, PluginFactory # Loggability API -- log to the deveiate logger log_to :strelka_cms ### PluginFactory API -- list the directories to search for derivatives. def self::derivative_dirs [ 'strelka/cms/pagefilter' ] end ### Search for plugins in the $LOAD_PATH and load each of them that's found. def self::load_all loaded = [] glob_pat = '{' + self.derivative_dirs.join(',') + '}/*.rb' $LOAD_PATH.uniq.collect {|path| path.untaint; Pathname(path) }.each do |base| self.log.debug " searching for %s" % [ base + glob_pat ] Pathname.glob( base + glob_pat ).each do |plugin| # Don't load this file twice next if Pathname(__FILE__).expand_path == plugin.expand_path begin path = plugin.to_s.untaint require( path ) loaded << plugin rescue LoadError, SecurityError => err self.log.error " %s while loading %s: %s" % [ err.class.name, plugin.to_s, err.message ] err.backtrace.each do |frame| self.log.debug " #{frame}" end end end end return loaded end ################################################################# ### I N S T A N C E M E T H O D S ################################################################# ### Export any static resources required by this filter to the given +output_dir+. def export_resources( output_dir ) # No-op by default end ### Process the +page+'s source with the filter and return the altered content. def process( source, page, index ) raise NotImplementedError, "%s does not implement the #process method" % [ self.class.name ] end end # class Strelka::CMS::PageFilter
Version data entries
4 entries across 4 versions & 1 rubygems