[ANN] Amrita2 initial release

T

Taku Nakajima

I released Amrita2 1.9.1, the first version of new Amrita.
Get it from

http://rubyforge.org/projects/amrita2/

This release contains Amrita2-Rails bridge based on Jamis Buck's work
and the Amrita2 version of Todo list Tutorial.

Here is one of two Amrita2-Rails sample applications. I think you can
get a feeling of Amrita2 if you know Todo list tutorial of Rails.

http://manuals.rubyonrails.com/read/book/7

A part of template
---------------------------------------------------------------------------
Not done:<br />
<div id='not_done'>
<input id="item_done" name="item[done]" type="checkbox" value="1" />
<span> </span>
<span id='description' />
<span> </span>
<a id='edit_link' href="/todo/edit/">Edit</a>
<span> </span>
<a id='destroy_link' href="/todo/destroy/">
Destroy</a>

</div>
---------------------------------------------------------------------------

Helper methods for VIEW code.
---------------------------------------------------------------------------
module TodoHelper
# Presentation Object for Todo Record
class TodoPO
def initialize(r)
@r = r
end

# passive PO method:
# The result of this method will be inserted in HTML output.
def description
@r.description
end

# active PO method:
# m is a template Module with method for dynamic element.
# If a method has a parameter for it, one of methods of that module
# should be called by PO object.
def item_done(m)
m.item_done(nil, :eek:nclick => %[document.location.href="/todo/toggle_check/#{@r.id}"])
end

def edit_link(m)
m.edit_link("Edit", :href=>"/todo/edit/#{@r.id}")
end

def destroy_link(m)
m.destroy_link("Destroy", :href=>"/todo/destroy/#{@r.id}",
:eek:nclick=>%[return confirm("Are you sure you want to delete this entry: #{description}")])
end
end

# Presentation Object for 'list' method
# The result of this method will be used by Amrita2 for tempalte expansion
def list_po
{
:done => controller.done.collect do |r|
TodoPO.new(r)
end,
:not_done => controller.not_done.collect do |r|
TodoPO.new(r)
end
}
end
end
---------------------------------------------------------------------------

And there is another version which I think is more flexible and better
for maintainance. This version uses the new parts template like this.
---------------------------------------------------------------------------
<div id='parts'>
<input id='checkbox_on' checked="checked" type="checkbox"
value="$1" onclick='document.location.href="$2"' />
<input id='checkbox_off' type="checkbox" value="$1"
onclick='document.location.href="$2"' />
<a id='link' href="$2">$1</a>
<a id='confirm_link' href="$2" onclick="return confirm('$3');">$1</a>
</div>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top