lib/fabulator/radiant/actions.rb in radiant-fabulator-extension-0.0.2 vs lib/fabulator/radiant/actions.rb in radiant-fabulator-extension-0.0.3
- old
+ new
@@ -19,11 +19,11 @@
#register_type 'user', {
#}
register_type 'page', {
:ops => {
- :children => Proc.new { |p| p.value.children.collect { |c| Lib.page_to_node(c, p) } },
+ :children => Proc.new { |p| Page.find(p.value.to_i).children.collect { |c| Lib.page_to_node(c, p) } },
},
}
# page parts are attributes of a page
# as are @name, @breadcrumb, @description, @keywords
@@ -55,25 +55,25 @@
function 'current-user' do |ctx, args|
u = UserActionObserver.current_user
if !u.nil?
n = ctx.root.anon_node(u.id) #, [ RADIANT_NS, 'user' ])
n.set_attribute('admin', u.admin?)
-Rails.logger.info("Returning: #{YAML::dump(n)}")
return [ n ]
else
return [ ]
end
end
def self.page_to_node(p, ctx)
return nil if p.nil?
- p_node = ctx.root.anon_node(p, [ RADIANT_NS, 'page' ])
+ p_node = ctx.root.anon_node(p.id, [ RADIANT_NS, 'page' ])
p_node.name = p.slug
p.parts.each do |pp|
- pp_node = ctx.root.anon_node(pp.content, [ RADIANT_NS, 'page-part' ])
- pp_node.name = pp.name
+ #pp_node = ctx.root.anon_node(pp.content, [ RADIANT_NS, 'page-part' ])
+ #pp_node.name = pp.name
#pp_node.set_attribute('filter', pp.filter)
- p_node.set_attribute(pp.name, pp_node)
+ #p_node.set_attribute(pp.name, pp_node)
+ p_node.set_attribute(pp.name, pp.content)
end
p_node.set_attribute('title', p.title)
p_node.set_attribute('breadcrumb', p.breadcrumb)
p_node.set_attribute('description', p.description)
p_node.set_attribute('keywords', p.keywords)