lib/polygon/helpers.rb in polygon-0.0.3 vs lib/polygon/helpers.rb in polygon-0.9.1
- old
+ new
@@ -1,20 +1,53 @@
module Polygon
module Helpers
- def static; settings.static; end
- def dynamic; settings.dynamic; end
- def templates; settings.templates; end
+ def static
+ settings.static
+ end
- def default_wlang_context
- { "environment" => settings.environment }
+ def dynamic
+ settings.dynamic
end
- def wlang(tpl, ctx = {})
- tpl = templates/"#{tpl}.whtml" if tpl.is_a?(Symbol)
- ctx = (ctx && ctx.to_hash) || {}
- ctx = default_wlang_context.to_hash.merge(ctx)
- WLang::file_instantiate tpl, ctx
+ def templates
+ settings.templates
end
+
+ def database
+ settings.database
+ end
+
+ def lispy(&bl)
+ @lispy ||= Alf.lispy(database)
+ bl ? @lispy.evaluate(&bl) : @lispy
+ end
+
+ def in_production
+ settings.environment == :production
+ end
+
+ def in_test
+ settings.environment == :test
+ end
+
+ def in_development
+ settings.environment == :development
+ end
+
+ def sitemap_locals
+ { :urls => database.sitemap }
+ end
+
+ def page_locals(path = "")
+ rel = lispy do
+ (unwrap \
+ (extend (restrict :sitemap, :path => path),
+ :data => lambda{ entry.to_hash }),
+ :data)
+ end
+ rel && rel.to_a.first
+ end
+ alias :index_locals :page_locals
end # module Helpers
end # module Polygon