General Question

I posted a question yesterday about the Mailer extension, and it occurs
to me that it might have come off too “needy”. I am just starting with
Rails and Ruby, and stumbled across Radiant, which can already do about
80% of what I need “out of the box”. Could someone tell me, in general
terms, if I will need to learn to fully develop in Rails before I can
do things like validate a form submission within Radiant? Does being
able to create an extension equate with being able to create a Rails
app? Or will I be able to skate along without coming all the way up
that learning curve, and learn as I have always done, by picking apart
other people’s solutions and modifying them to my needs?

Thanks!

Walter

hi All.

longtime lurker, first time caller…

I am finding Keith Bingham’s asset foo to be dealing with images
admirably, but not other content_types, I see code to handle it, so I
dive in…

At this point confusion sets in, so I thought I’d ask what the plan was
for non image content_types, as some supporting code appears to be
there… (ported from mephisto?)

Any pointers as to the right direction to proceed would be very much
appreciated.

cheers,


doug lang tel: +44 (1273) 808949
*nix sysadmin http://www.netdotnet.net/
technical consultant mailto:[email protected]

Walter Lee D. wrote:

I posted a question yesterday about the Mailer extension, and it occurs
to me that it might have come off too “needy”. I am just starting with
Rails and Ruby, and stumbled across Radiant, which can already do about
80% of what I need “out of the box”. Could someone tell me, in general
terms, if I will need to learn to fully develop in Rails before I can
do things like validate a form submission within Radiant? Does being
able to create an extension equate with being able to create a Rails
app? Or will I be able to skate along without coming all the way up
that learning curve, and learn as I have always done, by picking apart
other people’s solutions and modifying them to my needs?

Learning Rails would definitely help you understand how Radiant works,
but Radiant does a number of things on it’s own that aren’t particularly
Railsish. Creating your own extensions would definitely help you get the
hang of Radiant, but unfortunately documentation is a bit thin right now
so you will probably need to resort to reading the source code more
often than not. Studying the way other extensions are written will also
help.

Sorry not to answer your other question right away. In general if you
want a form in Radiant that displays error messages you need to create a
number of tags for displaying error messages.

Here’s an example from a small plugin I wrote for the Ruby Lang Web site
to simplify subscribing to the Ruby-Mailing lists:

<r:subscribe>
<r:unless_success>
Mailing-lists are a great way to keep your finger on the pulse of
the Ruby community.

 <r:form id="subscriptions-form">
   <h2>Subscribe or Unsubscribe</h2>

   <r:if_error><p class="error"><r:error_message /></p></r:if_error>

   <p>
     Mailing List:   <r:list_select /><br />
     First Name:     <r:first_name_input /><br />
     Last Name:      <r:last_name_input /><br />
     E-mail Address: <r:email_input /><br />
     Action:         <r:action_select />
   </p>
   <div class="buttons">
     <input class="button" type="submit" value="Submit Form" />
   </div>
 </r:form>

</r:unless_success>

<r:if_success>

Confirmation E-mail


You should receive a confirmation message within a few minutes.
Once you have received the message, follow the instructions it
contains to complete the process.


<r:link>Subscribe to another mailing list…</r:link>


</r:if_success>
</r:subscribe>

You can see this in action here:

http://www.ruby-lang.org/en/community/mailing-lists/

In a nutshell the form tag on the Subscribe page submits to the current
URL. The Subscribe page then has a chance to process the request. It
checks for a post and if it’s a post it processes the request. If there
are no errors it sets success to true and the part in the <r:if_success>
tags renders. If it can’t process the form because their are errors it
sets the error message and that will be displayed above the form.

Extremely messy, I know, especially by Rails standards, but this is the
cleanest implementation I could come up with that worked with tags.

I’ve attached the complete Behavior for your perusal that was designed
to work with 0.5.2. It works slightly differently on mental and the 0.6
release candidates because behaviors have been merged with the Page
class, but this is the general idea.

On Mar 28, 2007, at 10:32 AM, John W. Long wrote:

It checks for a post and if it’s a post it processes the request. If
there are no errors it sets success to true and the part in the
<r:if_success> tags renders

Exactly what I was trying to do with Mailer. I see, I will need to get
my nails dirty and write additional code. Not terrifying, and you have
given me an enormous leg up.

Thanks!

Walter

I am working on this as we speak. I was in Mexico for a few weeks and
lost track of this, but in the last few days I have gotten back to
it. I have added pagination and tagging (for images, but articles
aren’t far behind) and am working on other data types soon. Really
the only problem is a thumbnail, I should just make a generic “non-
image” thumbnail and build the rest when I have time. I have also
switched this from acts_as_attachment to attachment_foo and now
mini_magick is also supported.

And yes, lot’s of the code is stolen from Mephisto.

I should have a version usable by other people in the next few days.
The svn repository will also be changing, as I have a new host.

If you are impatient, in the model by acts_as_taggable, it limits the
asset type to “image”. Change this and do something in the views to
call a generic icon and it will work…

Keith B.
Tel: +49-7731-79838380
[email protected]

Keith B. wrote:

I should have a version usable by other people in the next few days.
The svn repository will also be changing, as I have a new host.

rocking good news! will keep an eye on it all

If you are impatient, in the model by acts_as_taggable, it limits the
asset type to “image”. Change this and do something in the views to
call a generic icon and it will work…

heh, am looking at it now… cheers for swiftresponse…

big thanks to all really, radiant++

cheers,


doug lang tel: +44 (1273) 808949
*nix sysadmin http://www.netdotnet.net/
technical consultant mailto:[email protected]