From Evgeny.Myasishchev at gmail.com Tue Sep 2 13:05:34 2008 From: Evgeny.Myasishchev at gmail.com (Evgeny Myasishchev) Date: Tue, 2 Sep 2008 20:05:34 +0300 Subject: [Apotomo-talk] Single controller to handle all events In-Reply-To: References: <2a7ca00d0808271124q4349d0e0if92435da99a98d81@mail.gmail.com> Message-ID: <2a7ca00d0809021005w4495a600o264486ff338b5577@mail.gmail.com> Hey Nick, See code below... I had to override *address_to_event* like this: module Apotomo module ViewHelper alias_method :origin_address_to_event, :address_to_event def address_to_event(way={}, action='event') way[:controller] = "public/widgets" way[:action] = "event" origin_address_to_event(way, action) end end end I think it would be good to make controller/action assignment configurable but don't have enough time for that. So it's hardcoded for now. Controller "public/widgets": class Public::WidgetsController < ApplicationController include Apotomo::ControllerHelper def event act_as_widget(params[:source]) end end And finally *render_widget *method* *(I have placed it to the application_helper for now) def render_widget widget_id controller.render_widget_from_tree(widget_id, ::ApplicationWidgetTree) end Sorry don't have enough time to create standalone sample, so just inline code... hope it's clear Have a nice vocation! I hope I will be able to to have some rest in three weeks (after release). Sincerely, Evgeny Myasishchev E-Mail: Evgeny.Myasishchev at gmail.com Cell: +380677132298, +380634482151 ICQ: 280954119 On Tue, Sep 2, 2008 at 7:38 PM, Nick Sutterer wrote: > hey evgeni! > thanks, that sounds good. can you send me the code? i will have a look > at it at the weekend, when i?m back from vacation. > > cheers, > nick > > > On Wed, Aug 27, 2008 at 8:24 PM, Evgeny Myasishchev > wrote: > > Hello everybody, > > > > First of all let me say thanks to the guys who has contributed to the > widget > > framework. I found it very useful and it almost ideally satisfies my new > > project requirements. > > > > The only thing that was missing for me is the ability to render several > > widgets in single controller action (as cells does). So I have added a > > helper method render_widget to do that and also a single controller that > is > > used to handle all events from all my widgets. If you think this is > useful > > feature I can share the code. > > > > Sincerely, > > > > Evgeny Myasishchev > > E-Mail: Evgeny.Myasishchev at gmail.com > > Cell: +380677132298, +380634482151 > > ICQ: 280954119 > > > > > > _______________________________________________ > > Apotomo-talk mailing list > > Apotomo-talk at rubyforge.org > > http://rubyforge.org/mailman/listinfo/apotomo-talk > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From apotonick at gmail.com Sun Sep 28 16:16:28 2008 From: apotonick at gmail.com (Nick Sutterer) Date: Sun, 28 Sep 2008 22:16:28 +0200 Subject: [Apotomo-talk] Single controller to handle all events In-Reply-To: References: <2a7ca00d0808271124q4349d0e0if92435da99a98d81@mail.gmail.com> <2a7ca00d0809021005w4495a600o264486ff338b5577@mail.gmail.com> Message-ID: hey evgeny, thanks for heading me. another Apotomo user also asked for this "feature", so finally i commited it to github in the dynamic branch, look here: http://github.com/apotonick/apotomo/tree/dynamic i also added a sample app to the github account which demonstrates how to use #render_widget and friends: http://github.com/apotonick/apotomo_sample_app/tree/master the sample app contains installations instructions in the README, it also advices you how to switch to the newer dynamic branch in Apotomo. please give it a try and let me hear what you think! cheers, nick On Tue, Sep 2, 2008 at 7:05 PM, Evgeny Myasishchev wrote: > Hey Nick, > > See code below... > > I had to override address_to_event like this: > module Apotomo > module ViewHelper > alias_method :origin_address_to_event, :address_to_event > > def address_to_event(way={}, action='event') > way[:controller] = "public/widgets" > way[:action] = "event" > origin_address_to_event(way, action) > end > end > end > I think it would be good to make controller/action assignment configurable > but don't have enough time for that. So it's hardcoded for now. > > Controller "public/widgets": > class Public::WidgetsController < ApplicationController > include Apotomo::ControllerHelper > > def event > act_as_widget(params[:source]) > end > end > > And finally render_widget method (I have placed it to the application_helper > for now) > def render_widget widget_id > controller.render_widget_from_tree(widget_id, ::ApplicationWidgetTree) > end > > Sorry don't have enough time to create standalone sample, so just inline > code... hope it's clear > > Have a nice vocation! I hope I will be able to to have some rest in three > weeks (after release). > > Sincerely, > > Evgeny Myasishchev > E-Mail: Evgeny.Myasishchev at gmail.com > Cell: +380677132298, +380634482151 > ICQ: 280954119 > > > > On Tue, Sep 2, 2008 at 7:38 PM, Nick Sutterer wrote: >> >> hey evgeni! >> thanks, that sounds good. can you send me the code? i will have a look >> at it at the weekend, when i?m back from vacation. >> >> cheers, >> nick >> >> >> On Wed, Aug 27, 2008 at 8:24 PM, Evgeny Myasishchev >> wrote: >> > Hello everybody, >> > >> > First of all let me say thanks to the guys who has contributed to the >> > widget >> > framework. I found it very useful and it almost ideally satisfies my new >> > project requirements. >> > >> > The only thing that was missing for me is the ability to render several >> > widgets in single controller action (as cells does). So I have added a >> > helper method render_widget to do that and also a single controller that >> > is >> > used to handle all events from all my widgets. If you think this is >> > useful >> > feature I can share the code. >> > >> > Sincerely, >> > >> > Evgeny Myasishchev >> > E-Mail: Evgeny.Myasishchev at gmail.com >> > Cell: +380677132298, +380634482151 >> > ICQ: 280954119 >> > >> > >> > _______________________________________________ >> > Apotomo-talk mailing list >> > Apotomo-talk at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/apotomo-talk >> > >> > > > From apotonick at gmail.com Mon Sep 29 06:50:35 2008 From: apotonick at gmail.com (Nick Sutterer) Date: Mon, 29 Sep 2008 12:50:35 +0200 Subject: [Apotomo-talk] Fwd: Single controller to handle all events In-Reply-To: References: <2a7ca00d0808271124q4349d0e0if92435da99a98d81@mail.gmail.com> <2a7ca00d0809021005w4495a600o264486ff338b5577@mail.gmail.com> Message-ID: hey evgeny, thanks for heading me. another Apotomo user also asked for this "feature", so finally i commited it to github in the dynamic branch, look here: http://github.com/apotonick/apotomo/tree/dynamic i also added a sample app to the github account which demonstrates how to use #render_widget and friends: http://github.com/apotonick/apotomo_sample_app/tree/master the sample app contains installations instructions in the README, it also advices you how to switch to the newer dynamic branch in Apotomo. please give it a try and let me hear what you think! cheers, nick On Tue, Sep 2, 2008 at 7:05 PM, Evgeny Myasishchev wrote: > Hey Nick, > > See code below... > > I had to override address_to_event like this: > module Apotomo > module ViewHelper > alias_method :origin_address_to_event, :address_to_event > > def address_to_event(way={}, action='event') > way[:controller] = "public/widgets" > way[:action] = "event" > origin_address_to_event(way, action) > end > end > end > I think it would be good to make controller/action assignment configurable > but don't have enough time for that. So it's hardcoded for now. > > Controller "public/widgets": > class Public::WidgetsController < ApplicationController > include Apotomo::ControllerHelper > > def event > act_as_widget(params[:source]) > end > end > > And finally render_widget method (I have placed it to the application_helper > for now) > def render_widget widget_id > controller.render_widget_from_tree(widget_id, ::ApplicationWidgetTree) > end > > Sorry don't have enough time to create standalone sample, so just inline > code... hope it's clear > > Have a nice vocation! I hope I will be able to to have some rest in three > weeks (after release). > > Sincerely, > > Evgeny Myasishchev > E-Mail: Evgeny.Myasishchev at gmail.com > Cell: +380677132298, +380634482151 > ICQ: 280954119 > > > > On Tue, Sep 2, 2008 at 7:38 PM, Nick Sutterer wrote: >> >> hey evgeni! >> thanks, that sounds good. can you send me the code? i will have a look >> at it at the weekend, when i?m back from vacation. >> >> cheers, >> nick >> >> >> On Wed, Aug 27, 2008 at 8:24 PM, Evgeny Myasishchev >> wrote: >> > Hello everybody, >> > >> > First of all let me say thanks to the guys who has contributed to the >> > widget >> > framework. I found it very useful and it almost ideally satisfies my new >> > project requirements. >> > >> > The only thing that was missing for me is the ability to render several >> > widgets in single controller action (as cells does). So I have added a >> > helper method render_widget to do that and also a single controller that >> > is >> > used to handle all events from all my widgets. If you think this is >> > useful >> > feature I can share the code. >> > >> > Sincerely, >> > >> > Evgeny Myasishchev >> > E-Mail: Evgeny.Myasishchev at gmail.com >> > Cell: +380677132298, +380634482151 >> > ICQ: 280954119 >> > >> > >> > _______________________________________________ >> > Apotomo-talk mailing list >> > Apotomo-talk at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/apotomo-talk >> > >> > > >