Permalink
Browse files

using engine

  • Loading branch information...
1 parent 95dc381 commit 706a35392b6b08026cf7be343b04233bf000ebf9 @kristianmandrup committed Sep 7, 2012
View
@@ -21,7 +21,7 @@ def setup
end
require 'apotomo/widget'
-require 'apotomo/railtie'
+require 'apotomo/engine'
require 'apotomo/cell/rendering'
require 'apotomo/widget_shortcuts'
require 'apotomo/rails/controller_methods'
@@ -1,12 +1,22 @@
module Cell
module Rendering
def render(*args)
- if args.first.kind_of?(Hash) && args.first[:view]
- hash = args.first
- hash[:view] = File.join('views', hash[:view].to_s)
- args = [hash, args[1..-1]]
+ puts "render: #{args}"
+
+ if args.first.kind_of?(Hash)
+ if args.first[:view]
+ hash = args.first
+ hash[:view] = File.join('views', hash[:view].to_s)
+ args = [hash, args[1..-1]]
+ end
+ if args.first[:partial]
+ view_name = self.action_name || ''
+ end
end
- view_name = File.join('views', self.action_name || '')
+
+ view_name ||= File.join('views', self.action_name || '')
+
+ puts "view_name: #{view_name}, #{args}"
render_view_for(view_name, *args)
end
end
View
@@ -0,0 +1,26 @@
+require "rails/engine"
+
+module Apotomo
+ module Rails
+ class Engine < ::Rails::Engine
+ rake_tasks do
+ load "apotomo/apotomo.rake"
+ end
+
+ # As we are a Railtie only, the routes won't be loaded automatically. Beside that, we want our
+ # route to be the very first (otherwise #resources might supersede it).
+ initializer 'apotomo.prepend_routes', :after => :add_routing_paths do |app|
+ app.routes_reloader.paths.unshift(File.dirname(__FILE__) + "/../../config/routes.rb")
+ end
+
+ # Include a lazy loader via has_widgets.
+ initializer 'apotomo.add_has_widgets' do |app|
+ ActionController::Base.extend Apotomo::Rails::ControllerMethodsLoader
+ end
+
+ initializer 'apotomo.setup_view_paths', :after => 'cells.setup_view_paths' do |app|
+ Apotomo::Widget.setup_view_paths!
+ end
+ end
+ end
+end
@@ -1,24 +0,0 @@
-require "rails/railtie"
-
-module Apotomo
- class Railtie < ::Rails::Railtie
- rake_tasks do
- load "apotomo/apotomo.rake"
- end
-
- # As we are a Railtie only, the routes won't be loaded automatically. Beside that, we want our
- # route to be the very first (otherwise #resources might supersede it).
- initializer 'apotomo.prepend_routes', :after => :add_routing_paths do |app|
- app.routes_reloader.paths.unshift(File.dirname(__FILE__) + "/../../config/routes.rb")
- end
-
- # Include a lazy loader via has_widgets.
- initializer 'apotomo.add_has_widgets' do |app|
- ActionController::Base.extend Apotomo::Rails::ControllerMethodsLoader
- end
-
- initializer 'apotomo.setup_view_paths', :after => 'cells.setup_view_paths' do |app|
- Apotomo::Widget.setup_view_paths!
- end
- end
-end
@@ -35,7 +35,7 @@ module Apotomo
#
# def update(evt)
# @cheese = Cheese.find evt[:cheese_id]
- class Widget < Cell::Rails
+ class Widget < Cell::Rails
DEFAULT_VIEW_PATHS = [File.join('app', 'widgets')]
include Hooks
@@ -82,8 +82,8 @@ def initialize(parent, id, options={})
@name = id
@visible = true
- setup_tree_node(parent)
-
+ setup_tree_node(parent)
+
run_hook :after_initialize, self
end
@@ -122,6 +122,7 @@ def invoke(state, *args)
#
# issues a squeaking alert dialog on the page.
def render(*args, &block)
+ puts "apotomo render: #{args}"
super
end
@@ -30,5 +30,5 @@
}).call(this);
-namespace "Widget";
-namespace "Widgets";
+namespace("Widget");
+namespace("Widgets");
@@ -4,4 +4,4 @@
* Open source under the MIT License.
*/
(function(){var a;a=function(a,g){var e,c,b,d,h,f;b="undefined"!==typeof exports&&null!==exports?exports:window;if(0<a.length){f=a.split(".");d=0;for(h=f.length;d<h;d++)c=f[d],b=b[c]||(b[c]={})}for(e in g)c=g[e],b[e]=c;return b};a("",{namespace:a})}).call(this);
-namespace "Widget"; namespace "Widgets";
+namespace("Widget"); namespace("Widgets");

0 comments on commit 706a353

Please sign in to comment.