Sha256: 829f62c2e423fb84e23aed132308a24ce7652b7208efee4529b6c6090da06415
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
$: << File.expand_path(File.dirname(__FILE__))+'/lib' require 'fabulator' require 'fabulator/radiant' require_dependency "#{File.expand_path(File.dirname(__FILE__))}/app/models/fabulator_page" class FabulatorExtension < Radiant::Extension version "1.0" description "Applications as documents" url "http://github.com/jgsmith/radiant-fabulator" XML_PART_NAME = 'extended' extension_config do |config| config.gem 'fabulator' config.after_initialize do #run_something end end def activate FabulatorPage tab 'Fabulator' do end PagePart.class_eval do before_save :compile_xml def compile_xml if self.page.class_name == 'FabulatorPage' && self.name == FabulatorExtension::XML_PART_NAME old_compiled_xml = self.page.compiled_xml if self.content.nil? || self.content == '' self.page.compiled_xml = nil else # compile #isa = Fabulator::ActionLib.get_local_attr(doc.root, Fabulator::FAB_NS, 'is-a') isa = nil sm = nil if isa.nil? sm = Fabulator::Core::StateMachine.new.compile_xml(self.content) else supersm_page = self.page.find_by_url(isa) if supersm_page.nil? || supersm_page.is_a?(FileNotFoundPage) || !supersm_page.is_a?(FabulatorPage) || supersm_page.state_machine.nil? raise "File Not Found: unable to find #{isa}" end sm = supersm_page.state_machine.clone sm.compile_xml(self.content) end self.page.compiled_xml = YAML::dump(sm) end if old_compiled_xml != self.page.compiled_xml self.page.save end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
radiant-fabulator-extension-0.0.2 | fabulator_extension.rb |