<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/mailer_process.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -15,7 +15,7 @@ class Mail
   def valid?
     unless defined?(@valid)
       @valid = true
-      if recipients.blank? and !@required.detect{|name,_| name == config['recipients_field']}
+      if recipients.blank? and !@required.any? {|name,_| name == config['recipients_field']}
         errors['form'] = 'Recipients are required.'
         @valid = false
       end
@@ -25,7 +25,7 @@ class Mail
         @valid = false
       end
       
-      if from.blank? and !@required.detect{|name,_| name == config['from_field']}
+      if from.blank? and !@required.any? {|name,_| name == config['from_field']}
         errors['form'] = 'From is required.'
         @valid = false
       end</diff>
      <filename>app/models/mail.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 module MailerTags
   include Radiant::Taggable
-  
+
   def config
     page = self
     until page.part(:mailer) or (not page.parent)
@@ -12,20 +12,20 @@ module MailerTags
 
   desc %{ All mailer-related tags live inside this one. }
   tag &quot;mailer&quot; do |tag|
-    if !Mail.valid_config?(config)
-      &quot;Mailer config is not valid (see Mailer.valid_config?)&quot;
-    else
+    if Mail.valid_config?(config)
       tag.expand
+    else
+      &quot;Mailer config is not valid (see Mailer.valid_config?)&quot;
     end
   end
-  
+
   desc %{
     Will expand if and only if there is an error with the last mail.
 
     If you specify the &quot;on&quot; attribute, it will only expand if there
     is an error on the named attribute, and will make the error
     message available to the mailer:error:message tag.}
-  tag &quot;mailer:error&quot; do |tag|
+  tag &quot;mailer:if_error&quot; do |tag|
     if mail = tag.locals.page.last_mail
       if on = tag.attr['on']
         if error = mail.errors[on]
@@ -39,9 +39,9 @@ module MailerTags
       end
     end
   end
-  
+
   desc %{Outputs the error message.}
-  tag &quot;mailer:error:message&quot; do |tag|
+  tag &quot;mailer:if_error:message&quot; do |tag|
     tag.locals.error_message
   end
 
@@ -51,16 +51,18 @@ module MailerTags
     Usage:
     &lt;pre&gt;&lt;code&gt;  &lt;r:mailer:form&gt;...&lt;/r:mailer:form&gt;&lt;/code&gt;&lt;/pre&gt;}
   tag &quot;mailer:form&quot; do |tag|
-    results = [%(&lt;a name=&quot;mailer&quot;&gt;&lt;/a&gt;)]
-    results &lt;&lt; %(&lt;form action=&quot;/pages/#{tag.locals.page.id}/mail#mailer&quot; method=&quot;post&quot; #{mailer_attrs(tag)}&quot;&gt;)
+    tag.attr['id'] ||= 'mailer'
+    results = []
+    action = Radiant::Config['mailer.post_to_page?'] ? tag.locals.page.url : &quot;/pages/#{tag.locals.page.id}/mail#{tag.attr['id']}&quot;
+    results &lt;&lt; %(&lt;form action=&quot;#{action}&quot; method=&quot;post&quot; #{mailer_attrs(tag)}&quot;&gt;)
     results &lt;&lt;   tag.expand
     results &lt;&lt; %(&lt;/form&gt;)
   end
-  
+
   desc %{
     Outputs a bit of javascript that will cause the enclosed content
     to be displayed when mail is successfully sent.}
-  tag &quot;mailer:form:success&quot; do |tag|
+  tag &quot;mailer:if_success&quot; do |tag|
     results = [%(&lt;div id=&quot;mail_sent&quot; style=&quot;display:none&quot;&gt;)]
     results &lt;&lt; tag.expand
     results &lt;&lt; %(&lt;/div&gt;)
@@ -119,12 +121,14 @@ module MailerTags
     tag.attr['name'] = tag.locals.parent_tag_name
 
     value = (tag.attr['value'] || tag.expand)
-    selected = (prior_value(tag, tag.locals.parent_tag_name) == value)
+    prev_value = prior_value(tag, tag.locals.parent_tag_name)
+    checked = tag.attr.delete('selected') || tag.attr.delete('checked')
+    selected = prev_value ? prev_value == value : checked
 
     if tag.locals.parent_tag_type == 'select'
       %(&lt;option value=&quot;#{value}&quot;#{%( selected=&quot;selected&quot;) if selected} #{mailer_attrs(tag)}&gt;#{tag.expand}&lt;/option&gt;)
     elsif tag.locals.parent_tag_type == 'radiogroup'
-      %(&lt;input type=&quot;radio&quot; value=&quot;#{value}&quot;#{%( selected=&quot;selected&quot;) if selected} #{mailer_attrs(tag)} /&gt;)
+      %(&lt;input type=&quot;radio&quot; value=&quot;#{value}&quot;#{%( checked=&quot;checked&quot;) if selected} #{mailer_attrs(tag)} /&gt;)
     end
   end
 
@@ -140,7 +144,18 @@ module MailerTags
       mail.data.to_hash.to_yaml.to_s
     end
   end
-  
+
+  desc %{
+    Renders the contained block if a named datum was submitted via a mailer form.  Used in the 'email', 'email_html' and 'mailer' parts
+    to generate the resulting email.
+  }
+  tag 'mailer:if_value' do |tag|
+    name = tag.attr['name']
+    eq = tag.attr['equals']
+    mail = tag.locals.page.last_mail || tag.globals.page.last_mail
+    tag.expand if name &amp;&amp; mail.data[name] &amp;&amp; (eq.blank? || eq == mail.data[name])
+  end
+
   def prior_value(tag, tag_name=tag.attr['name'])
     if mail = tag.locals.page.last_mail
       mail.data[tag_name]
@@ -151,8 +166,8 @@ module MailerTags
 
   def mailer_attrs(tag, extras={})
     attrs = {
-      'id' =&gt; tag.attr['name'], 
-      'class' =&gt; nil, 
+      'id' =&gt; tag.attr['name'],
+      'class' =&gt; nil,
       'size' =&gt; nil}.merge(extras)
     result = attrs.collect do |k,v|
       v = (tag.attr[k] || v)
@@ -162,7 +177,7 @@ module MailerTags
     result &lt;&lt; %(name=&quot;mailer[#{tag.attr['name']}]&quot;) unless tag.attr['name'].blank?
     result.join(' ')
   end
-  
+
   def add_required(result, tag)
     result &lt;&lt; %(&lt;input type=&quot;hidden&quot; name=&quot;mailer[required][#{tag.attr['name']}]&quot; value=&quot;#{tag.attr['required']}&quot; /&gt;) if tag.attr['required']
     result</diff>
      <filename>lib/mailer_tags.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 class MailerExtension &lt; Radiant::Extension
-  version &quot;0.2&quot;
+  version &quot;0.3&quot;
   description &quot;Provides support for email forms and generic mailing functionality.&quot;
-  url &quot;http://github.com/ntalbott/radiant-mailer-extension&quot;
+  url &quot;http://github.com/radiant/radiant-mailer-extension&quot;
 
   define_routes do |map|
     map.resources :mail, :path_prefix =&gt; &quot;/pages/:page_id&quot;, :controller =&gt; &quot;mail&quot;
@@ -10,11 +10,7 @@ class MailerExtension &lt; Radiant::Extension
   def activate
     Page.class_eval do
       include MailerTags
-      attr_accessor :last_mail
+      include MailerProcess
     end
   end
-  
-  def deactivate
-  end
-    
 end
\ No newline at end of file</diff>
      <filename>mailer_extension.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>200701b6d91a48f8e2c49cf77cc585dd74c27004</id>
    </parent>
  </parents>
  <author>
    <name>Sean Cribbs</name>
    <email>seancribbs@gmail.com</email>
  </author>
  <url>http://github.com/radiant/radiant-mailer-extension/commit/c461ee46211d92a59f7ea3ef12b0f3cba0ce787c</url>
  <id>c461ee46211d92a59f7ea3ef12b0f3cba0ce787c</id>
  <committed-date>2008-09-30T13:51:21-07:00</committed-date>
  <authored-date>2008-09-30T13:51:21-07:00</authored-date>
  <message>Add some tags, make mail forms postable to the page's URL.</message>
  <tree>098ab4790607eea7d56aa3f5a9d02f713707c64a</tree>
  <committer>
    <name>Sean Cribbs</name>
    <email>seancribbs@gmail.com</email>
  </committer>
</commit>
