hobo_files/plugin/lib/hobo/controller.rb in hobo-0.5.3 vs hobo_files/plugin/lib/hobo/controller.rb in hobo-0.6
- old
+ new
@@ -1,23 +1,39 @@
module Hobo
module Controller
- include ControllerHelpers
-
include AuthenticationSupport
-
+
def self.included(base)
if base.is_a?(Class)
- Hobo::ControllerHelpers.public_instance_methods.each {|m| base.hide_action(m)}
- base.class_eval do
- alias_method_chain :redirect_to, :object_url
- end
+ included_in_class(base)
end
end
+
+ def self.included_in_class(klass)
+ klass.extend(ClassMethods)
+ klass.class_eval do
+ alias_method_chain :redirect_to, :object_url
+ @included_taglibs = []
+ end
+ Hobo::HoboHelper.add_to_controller(klass)
+ end
+ module ClassMethods
+ attr_reader :included_taglibs
+
+ def include_taglib(src, options={})
+ @included_taglibs << if options[:from_plugin]
+ 'plugins/' + options[:from_plugin] + '/taglibs/' + src
+ else
+ src
+ end
+ end
+ end
+
protected
def redirect_to_with_object_url(destination, view=nil)
if destination.is_a?(String, Hash, Symbol)
redirect_to_without_object_url(destination)
@@ -89,29 +105,36 @@
end
end
end
- def render_tag(tag, options={})
+ def render_tag(tag, options={}, render_options={})
add_variables_to_assigns
- render :text => Hobo::Dryml.render_tag(@template, tag, options), :layout => false
+ render({:text => Hobo::Dryml.render_tag(@template, tag, options),
+ :layout => false }.merge(render_options))
end
def render_tags(objects, tag, options={})
+ for_type = options.delete(:for_type)
add_variables_to_assigns
dryml_renderer = Hobo::Dryml.empty_page_renderer(@template)
- render :text => objects.map {|o| dryml_renderer.send(tag, options.merge(:obj => o))}.join +
- dryml_renderer.part_contexts_js
+
+ results = objects.map do |o|
+ tag = dryml_renderer.find_polymorphic_tag(tag, o.class) if for_type
+ dryml_renderer.send(tag, options.merge(:with => o))
+ end.join
+
+ render :text => results + dryml_renderer.part_contexts_js
end
def site_search(query)
results = Hobo.find_by_search(query).select {|r| Hobo.can_view?(current_user, r, nil)}
if results.empty?
render :text => "<p>Your search returned no matches.</p>"
else
- render_tags(results, "tag_for_object", :name => "search_result")
+ render_tags(results, :card, :for_type => true)
end
end
# Store the given user in the session.