Browse Source

merged test versions of petition page to include form submission process

svn path=/trunk/; revision=16903
pull/8/head
samtuke 11 years ago
parent
commit
9101ce1693
3 changed files with 206 additions and 6 deletions
  1. +98
    -6
      campaigns/pdfreaders/petition.en.xhtml
  2. +85
    -0
      cgi-bin/pdfpetition.pl
  3. +23
    -0
      templates/pdfreaders-petition-mail.tt2

+ 98
- 6
campaigns/pdfreaders/petition.en.xhtml View File

@ -35,16 +35,108 @@
<p>Sincerely,</p>
<p>The Undersigned</p>
<hr />
<p><em>To sign the petition, email <a href="mailto:pdfreaders@lists.fsfe.org?subject=I Sign The Petition">pdfreaders@lists.fsfe.org</a>. </em>We update the list of signatories several times a day, so please allow some time for your signature to appear.</p>
<h2>List of signatories</h2>
<form action="/cgi-bin/pdfpetition.pl" method="post">
<p>
<label for="name">Name <span class="required-asterisk">*</span></label>
<input id="name" name="name" type="text" />
</p>
<p>
<label for="surname">surname <span class="required-asterisk">*</span></label>
<input id="surname" name="surname" type="text" />
</p>
<p>
<label for="email">Your E-mail <span class="required-asterisk">*</span></label>
<input id="email" name="email" type="email" />
</p>
<p>
<label for="email">On Belhalf of</label>
<input id="group" name="group" type="text" />
</p>
<p>
<label for="country">Country of the institution (in English) <span class="required-asterisk">*</span></label>
<select id="country" name="country">
<option>Aland</option>
<option>Albania</option>
<option>Austria</option>
<option>Belarus</option>
<option>Belgium</option>
<option>Bosnia and Herzegovina</option>
<option>Bulgaria</option>
<option>Croatia</option>
<option>Cyprus</option>
<option>Czech Republic</option>
<option>Denmark</option>
<option>Estonia</option>
<option>Faroe Islands</option>
<option>Finland</option>
<option>France</option>
<option>Germany</option>
<option>Greece</option>
<option>Hungary</option>
<option>Iceland</option>
<option>Ireland</option>
<option>Italy</option>
<option>Latvia</option>
<option>Liechtenstein</option>
<option>Lithuania</option>
<option>Luxembourg</option>
<option>Macedonia</option>
<option>Malta</option>
<option>Moldova</option>
<option>Montenegro</option>
<option>Netherlands</option>
<option>Norway</option>
<option>Poland</option>
<option>Portugal</option>
<option>Romania</option>
<option>Russian Federation</option>
<option>Serbia</option>
<option>Slovakia</option>
<option>Slovenia</option>
<option>Spain</option>
<option>Sweden</option>
<option>Switzerland</option>
<option>Turkey</option>
<option>Ukraine</option>
<option>United Kingdom</option>
</select>
</p>
<p>
<label>Receive Newsletter</label>
<input name="newsletter" type="checkbox" checked="checked" />
</p>
<p class="n">
<label for="url">If you're a bot please enter something here to have our system happily ignore all of your efforts</label>
<input id="url" name="url" type="text" />
</p>
<p>
<input type="submit" value="Sign Petition" />
</p>
</form>
<hr />
<p><em>We update the list of signatories several times a day, so please allow some time for your signature to appear.</em></p>
<h2>List of signatories</h2>
</body>
<text id="osig">Organizations</text>
<text id="bsig">Businesses</text>
<text id="osig">Businesses</text>
<text id="bsig">Organizations</text>
<text id="isig">Individuals</text>
<timestamp>$Date: 2010-09-07 16:38:57 +0200 (Tue, 07 Sep 2010) $ $Author: maelle $</timestamp>
</html>

+ 85
- 0
cgi-bin/pdfpetition.pl View File

@ -0,0 +1,85 @@
#!/usr/bin/env perl
use 5.008;
=head1 DESCRIPTION
PDFreaders petition form processing script.
=head1 AUTHOR
Sam Tuke <mail@samtuke.com>, extending Alexander Kahl <e-user@fsfe.org>
=cut
use Cwd qw (abs_path);
use File::Basename qw (dirname);
my $root;
BEGIN { $root = abs_path (dirname (__FILE__).'/..') };
use lib "$root/tools";
use CGI;
use DateTime;
use Template;
use WebBuild::FormValidation;
use WebBuild::DynamicContent;
use strict;
use warnings;
use constant TEMPLATE => "$root/templates/pdfreaders-petition-mail.tt2.xml";
use constant UPLOAD => "$root/upload/pdfreaders";
# Start actual logic
my $form = WebBuild::FormValidation->new;
my $content = WebBuild::DynamicContent->new;
my $query = CGI->new;
$content->layout ("$root/campaigns/pdfreaders/petition.en.html");
$form->validates_presence_of ('name');
$form->validates_presence_of ('surname');
$form->validates_presence_of ('country');
$form->validate_format ('email', type => 'email');
if ($form->has_errors)
{
$content->content ($form->get_errors);
$content->render;
exit;
}
elsif ($query->param ('url')) # Bot!!
{
exit;
}
# Record data here
my $template = Template->new ({ INCLUDE_PATH => "$root/templates" });
my $mail;
my $dt = DateTime->now;
my $data = { country => $query->param ('country'),
date => sprintf ('%d-%.2d-%.2d', $dt->year, $dt->month, $dt->day),
name => $query->param ('name'),
surname => $query->param ('surname'),
email => $query->param ('email'),
group => $query->param ('group') || '',
newsletter => $query->param ('newsletter') };
$template->process ('pdfreaders-petition-mail.tt2', $data, \$mail);
open MAIL, "|/usr/lib/sendmail -t";
print MAIL $mail;
close MAIL;
my $output = <<'EOF';
<div id="flash">
<p>Thank you for signing - your signature has been recorded, and will be added shortly.</p>
</div>
EOF
$content->content ($output);
$content->render

+ 23
- 0
templates/pdfreaders-petition-mail.tt2 View File

@ -0,0 +1,23 @@
From: samtuke@fsfeurope.org
MIME-Version: 1.0
To: samtuke@fsfe.org
Subject: [PDFReaders] petition signature
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
A new PDFReaders petition signature has been submitted.
Please validate and use the following XML snippet if appropriate:
---
<sig
name="[% name %]"
surname="[% surname %]"
email="[% email %]"
group="[% group %]"
country="[% country %]"
nl=[[% IF newsletter %]X[% ELSE %] [% END %]]
date="[% date %]"
/>
---

Loading…
Cancel
Save