Class: Strelka::CMS::PageFilter
- Inherits:
-
Object
- Object
- Strelka::CMS::PageFilter
- Extended by:
- Loggability, Pluggability
- Defined in:
- lib/strelka/cms/pagefilter.rb
Overview
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 Method Summary collapse
-
.load_all ⇒ Object
Search for plugins in the $LOAD_PATH and load each of them that’s found.
Instance Method Summary collapse
-
#export_resources(output_dir) ⇒ Object
Export any static resources required by this filter to the given
output_dir
. -
#name ⇒ Object
I N S T A N C E M E T H O D S.
-
#process(source, page, index) ⇒ Object
Process the
page
‘s source with the filter and return the altered content.
Class Method Details
.load_all ⇒ Object
Search for plugins in the $LOAD_PATH and load each of them that’s found.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/strelka/cms/pagefilter.rb', line 29 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__). == plugin. 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. ] err.backtrace.each do |frame| self.log.debug " #{frame}" end end end end return loaded end |
Instance Method Details
#export_resources(output_dir) ⇒ Object
Export any static resources required by this filter to the given output_dir
.
67 68 69 |
# File 'lib/strelka/cms/pagefilter.rb', line 67 def export_resources( output_dir ) # No-op by default end |
#name ⇒ Object
I N S T A N C E M E T H O D S
60 61 62 63 |
# File 'lib/strelka/cms/pagefilter.rb', line 60 def name self.log.warn "#name called from: \n%s" % [ caller(1).join("\n") ] "pagefilter" end |
#process(source, page, index) ⇒ Object
Process the page
‘s source with the filter and return the altered content.
73 74 75 76 |
# File 'lib/strelka/cms/pagefilter.rb', line 73 def process( source, page, index ) raise NotImplementedError, "%s does not implement the #process method" % [ self.class.name ] end |