Forum: Ruby [ANN] Wee 2.0.0 released (Rack, Continuations, Refactoring)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Baf83fa62a7481a08c40353795e11f44?d=identicon&s=25 Michael Neumann (mneumann)
on 2009-04-07 12:14
Hi all,

Around 4 years have passed since the last release of Wee.

What is Wee?
============

Wee is a Seaside-inspired [1] web-framework for building highly-dynamic
component-based web-applications.

What's new?
===========

* 100% Rack based
* Support for continuations
* JQuery AJAX support
* Ruby 1.9 ready

Distinctive Features
====================

Wee is not just another web framework. It is completely different.

Continuations
-------------

You can use continuations to model the page flow of the your
application, in the same way as you'd call a method in a GUI
application. Continuations are optional; nothing in Wee depends on them.
Example:

   # you can write code like this:

   if callcc YesNoMessageBox.new('Really?')
     # do something
   else
     # something else
   end

Without continuations one has to use (ugly) Continuation Passing Style
(CPS):

   call YesNoMessageBox.new('Really?') do |res|
     if res
       # do something
     else
       # something else
     end
   end

Backtracking
------------

Backtracking means that the user can naturally use the browsers back
button despite Wee's statefulness. This is not taken for granted for
stateful web frameworks. Behind the scenes, Wee keeps multiple states
of the application around with only little help by the programmer.

Components
----------

Contrary to the widely used model/view/controller (MVC) paradigm, Wee
tighly couples the controller and the view within a *component*.
Components itself are highly decoupled from the rest of the application
and can be reused to construct more complex applications. The powerful
programmatic HTML rendering approach further reduces wasting the
programmers mind by avoiding switching files (controller/view) or
languages (Ruby/HTML). Therefore in Wee everything is written in Ruby.
The programmatic HTML renderer is not just a simple HTML builder, it
provides very powerful methods for easily generating HTML constructs
and registering callbacks. Example:

   #
   # Generating a <select> tag
   #

   # select an object from these items
   items = [1, 2, 3, 4]

   # the labels shown to the user
   labels = items.map {|i| i.to_s}

   # render it
   r.select_list(items).labels(labels).callback {|choosen| p choosen}

   # render a multi-select list, with objects 2 and 4 selected
   r.select_list(items).multi.labels(labels).selected([2,4])

=== Call/Answer mechanism ===

From callback handlers you can call other components which in turn
replace the current components view. The called component can later
return (or answer) back to the calling componenent. Example:

   class YesNoMessageBox < Wee::Component
     def initialize(msg)
       super()
       @msg = msg
     end

     def render(r)
       r.bold(@msg)
       r.form do
         r.submit_button.value('YES').callback { answer true }
         r.space
         r.submit_button.value('No').callback { answer false }
       end
     end
   end

   # Use call (or callcc) as in the Continuation section above
   # to call a component:
   call YesNoMessageBox.new('Really?')

The classical Hello World Example
---------------------------------

   require 'rubygems' if RUBY_VERSION < "1.9"
   require 'wee'

   class HelloWorld < Wee::Component
     def initialize
       super
       add_decoration Wee::PageDecoration.new(title="Hello World")
     end

     def render(r)
       r.h1 "Hello World from Wee!"
       r.div.onclick_callback { p "clicked" }.with("click here")
     end
   end

   Wee.run(HelloWorld) if __FILE__ == $0
   # Now point your browser to http://localhost:2000/

Installation
------------

   gem install wee

More Resources
--------------

http://rubyforge.org/projects/wee
http://www.ntecs.de/projects/wee/doc/rdoc/
http://github.com/mneumann/wee


Regards,

  Michael


[1]: http://www.seaside.st/
Baf83fa62a7481a08c40353795e11f44?d=identicon&s=25 Michael Neumann (mneumann)
on 2009-04-07 12:40
Michael Neumann wrote:
> Hi all,
>
> Around 4 years have passed since the last release of Wee.

Strange that my posting didn't get through to ruby-talk :(
Baf83fa62a7481a08c40353795e11f44?d=identicon&s=25 Michael Neumann (mneumann)
on 2009-04-07 13:29
Michael Neumann wrote:
> Michael Neumann wrote:
>> Hi all,
>>
>> Around 4 years have passed since the last release of Wee.
>
> Strange that my posting didn't get through to ruby-talk :(

(I'll try to post again. Sorry for any inconveniences)

Hi all,

Around 4 years have passed since the last release of Wee.

What is Wee?
============

Wee is a Seaside-inspired [1] web-framework for building highly-dynamic
component-based web-applications.

What's new?
===========

* 100% Rack based
* Support for continuations
* JQuery AJAX support
* Ruby 1.9 ready

Distinctive Features
====================

Wee is not just another web framework. It is completely different.

Continuations
-------------

You can use continuations to model the page flow of the your
application, in the same way as you'd call a method in a GUI
application. Continuations are optional; nothing in Wee depends on them.
Example:

   # you can write code like this:

   if callcc YesNoMessageBox.new('Really?')
     # do something
   else
     # something else
   end

Without continuations one has to use (ugly) Continuation Passing Style
(CPS):

   call YesNoMessageBox.new('Really?') do |res|
     if res
       # do something
     else
       # something else
     end
   end

Backtracking
------------

Backtracking means that the user can naturally use the browsers back
button despite Wee's statefulness. This is not taken for granted for
stateful web frameworks. Behind the scenes, Wee keeps multiple states
of the application around with only little help by the programmer.

Components
----------

Contrary to the widely used model/view/controller (MVC) paradigm, Wee
tighly couples the controller and the view within a *component*.
Components itself are highly decoupled from the rest of the application
and can be reused to construct more complex applications. The powerful
programmatic HTML rendering approach further reduces wasting the
programmers mind by avoiding switching files (controller/view) or
languages (Ruby/HTML). Therefore in Wee everything is written in Ruby.
The programmatic HTML renderer is not just a simple HTML builder, it
provides very powerful methods for easily generating HTML constructs
and registering callbacks. Example:

   #
   # Generating a <select> tag
   #

   # select an object from these items
   items = [1, 2, 3, 4]

   # the labels shown to the user
   labels = items.map {|i| i.to_s}

   # render it
   r.select_list(items).labels(labels).callback {|choosen| p choosen}

   # render a multi-select list, with objects 2 and 4 selected
   r.select_list(items).multi.labels(labels).selected([2,4])

Call/Answer mechanism
---------------------

From callback handlers you can call other components which in turn
replace the current components view. The called component can later
return (or answer) back to the calling componenent. Example:

   class YesNoMessageBox < Wee::Component
     def initialize(msg)
       super()
       @msg = msg
     end

     def render(r)
       r.bold(@msg)
       r.form do
         r.submit_button.value('YES').callback { answer true }
         r.space
         r.submit_button.value('No').callback { answer false }
       end
     end
   end

   # Use call (or callcc) as in the Continuation section above
   # to call a component:
   call YesNoMessageBox.new('Really?')

The classical Hello World Example
=================================

   require 'rubygems' if RUBY_VERSION < "1.9"
   require 'wee'

   class HelloWorld < Wee::Component
     def initialize
       super
       add_decoration Wee::PageDecoration.new(title="Hello World")
     end

     def render(r)
       r.h1 "Hello World from Wee!"
       r.div.onclick_callback { p "clicked" }.with("click here")
     end
   end

   Wee.run(HelloWorld) if __FILE__ == $0
   # Now point your browser to http://localhost:2000/

Installation
============

   gem install wee

More Resources
==============

* Wee at Rubyforge: http://rubyforge.org/projects/wee

* Wee at GitHub: http://github.com/mneumann/wee

* Documentation: http://www.ntecs.de/projects/wee/doc/rdoc/

Regards,

  Michael


[1]: http://www.seaside.st/
Baf83fa62a7481a08c40353795e11f44?d=identicon&s=25 Michael Neumann (mneumann)
on 2009-04-07 13:50
For some (yet) unknown reasons my announcement didn't make it to
ruby-talk. You can read the full text here:

http://www.ruby-forum.com/topic/183615#802610

Regards,

  Michael
04cdb622ce0aac272b61f23f373e2abf?d=identicon&s=25 Michael Granger (Guest)
on 2009-04-08 09:01
(Received via mailing list)
On Apr 7, 2009, at 3:39 AM, Michael Neumann wrote:

> Strange that my posting didn't get through to ruby-talk :(


I tried to post to announce BlueCloth 2.0 today and it still hasn't
come through either.
This topic is locked and can not be replied to.