github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

apotonick / apotomo

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 70
    • 9
  • Source
  • Commits
  • Network (9)
  • Issues (0)
  • Downloads (0)
  • Wiki (5)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (4)
    • andy/master
    • dynamic
    • master ✓
    • xmas-cleanup
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Apotomo is a stateful widget component framework for Rails. — Read more

  cancel

http://apotomo.de

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

refactored url change methods. to make your widget a url listener you have 
to overwrite #responds_to_url_fragment_for? and #local_fragment. you also 
have to add an :urlChange event listener via 
apotonick (author)
Sun Jan 24 11:41:18 -0800 2010
commit  ebfe8805a7e3281e798f94aa939f33d490a8c515
tree    38da4162183ea7f068dd4a82a693e087551714a5
parent  517454511ee076be0b29574d9a2ffc1e39e5bf4b
apotomo /
name age
history
message
file README Thu Aug 07 05:30:32 -0700 2008 symlinks again [apotonick]
file README.rdoc Sun Jan 24 11:41:18 -0800 2010 refactored url change methods. to make your wid... [apotonick]
file Rakefile Thu Oct 09 01:28:47 -0700 2008 cleaned up StatefulWidget (lot of superseded me... [apotonick]
file TODO Thu Oct 09 01:28:47 -0700 2008 cleaned up StatefulWidget (lot of superseded me... [apotonick]
directory app/ Sun Jan 24 11:41:18 -0800 2010 refactored url change methods. to make your wid... [apotonick]
directory generators/ Sun Jan 24 11:41:18 -0800 2010 refactored url change methods. to make your wid... [apotonick]
file init.rb Sat Jan 02 04:14:59 -0800 2010 introduced #render_widget in views by adding a ... [apotonick]
directory lib/ Sun Jan 24 11:41:18 -0800 2010 refactored url change methods. to make your wid... [apotonick]
directory public/ Sat Sep 13 04:16:42 -0700 2008 simplified the TabPanel thanks to berry's desig... [apotonick]
directory test/ Sun Jan 24 11:41:18 -0800 2010 refactored url change methods. to make your wid... [apotonick]
README.rdoc

Apotomo

Apotomo is a stateful widget component framework for Rails.

A stateful WHAT?

Well, you know that. In Rails, people tend to have fat controllers. One controller action renders the complete page. While many programmers try to separate their code into helpers, controller actions, RJS logic and partials, it is still the controller that has to care about when to update what, and how!

In Apotomo, it is the opposite. Widgets are small, autonomous components that look and feel like controllers. These tiny monsters listen to events and thus keep updating themselves on the page via AJAX. However, there’s no JavaScript for you - they’re pure Ruby.

Man, gimme code!

Let’s use the famous and tiresome counter example.

 class CounterCell < Apotomo::StatefulWidget
   transition :from => :display, :to => :increment

   def display
     respond_to_event :counterClick, :with => :increment

     @count = 0
     render             # renders display.html.erb
   end

   def increment
     @count += 1        # @count is simply there - that's stateful.
     render :view => :display
   end
 end

Since this widget calls render it surely needs a view.

 <!-- I'm display.html.erb -->

 <h1><%= @count %></h1>

 <%= link_to_event "Increment me!", :type => :counterClick %>

We now plug the widget in a page.

 class ExistingController < ApplicationController
   include Apotomo::ControllerHelper

   def some_action
     # do what you want...

     use_widgets do |root|
       root << cell(:counter, :display, 'my_first_counter')
     end
   end
 end

As soon as the widget is rendered it will jump to its :display state which initializes the counter and renders itself.

Speaking of rendering: how do we place the widget in our controller?

  <!-- I'm some_action.html.erb -->
  <p>
        <%= render_widget 'my_first_counter' %>

Ok, so this renders the widget in our controller page.

When clicking the link it updates automatically on the screen showing the incremented value. Wow.

That’s cool!

Yes, it is.

Is there more?

Apotomo got a load of features.

Composability
Widgets can range from small standalone components to nested widget trees like dashboards or forms. Remember that each widget can have any number of children.
Bubbling events
Widgets can trigger events and watch out for them. While events bubble up from their triggering source to root they can be observed, providing a way to implement loosely coupled, distributable components.
Deep Linking
Apotomo deals with deep links (or url fragments) out-of-the-box while using SWFAddress. Components that register for deep linking will update as soon as the deep link changes. That makes your application back-button-safe!
Testing
Needless to say that it is simply easier to test small components instead of fat do-it-all controllers.

Give it a try- you will love the power and simplicity of real stateful components!

Bugs, Community

Please visit apotomo.de, the official project page with lots of examples. Join the mailing list and visit us in the IRC channel. More information is here.

License

Copyright © 2007-2010 Nick Sutterer <apotonick@gmail.com>

The MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server