* final pdfreaders

svn path=/trunk/; revision=16594
This commit is contained in:
e-user 2010-09-07 08:39:22 +00:00
parent 2137e6a882
commit 7b8b0a874f
5 changed files with 128 additions and 1 deletions

View File

@ -1,3 +1,14 @@
2010-09-07 Alexander Kahl <e-user@fsfe.org>
* Makefile.PL: Initial creation, check for Perl modules only
* tools/build.sh: Also run Makefile.PL (early)
* templates: Initial creation, location for Template Toolkit
templates
* templates/README.directory: Initial creation
* templates/pdfreaders-mail.tt2: Initial creation
* cgi-bin/pdfcontest.pl: Initial creation
* campaigns/pdfreaders/index.en.xhtml: Initial creation
2006-12-05 Werner Koch <wk@g10code.com>
* about/people/person-koch.en.xml: Removed me as HoO. Also for

View File

@ -81,7 +81,7 @@
</p>
<p>
<label for="email">E-mail</label>
<input id="email" name="email" type="email" />
<input id="email" name="email" type="text" />
</p>
<p>
<label for="group">Group or association (optional)</label>
@ -91,6 +91,9 @@
<label for="contact">Would you be available to get in contact with the institution?</label>
<input id="contact" name="contact" type="checkbox"/>
</p>
<p style="position: absolute; top: -9999px; left: -9999px;">
<input id="url" name="url" type="text"/>
</p>
<p style="text-align:center">
<input type="submit" value="Submit" />
</p>

90
cgi-bin/pdfcontest.pl Executable file
View File

@ -0,0 +1,90 @@
#!/usr/bin/env perl
use 5.008;
=head1 DESCRIPTION
PDFreaders campaign "Commercials on Public websites" form processing script.
=head1 AUTHOR
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/pdfcontest.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/index.en.html");
$form->validates_presence_of ('institution-name');
$form->validates_presence_of ('institution-country');
$form->validate_format ('institution-url', type => 'url');
$form->validates_presence_of ('institution-address');
$form->validates_presence_of ('name');
$form->validate_format ('email', type => 'email');
# Group is optional
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 = { institution_name => $query->param ('institution-name'),
institution_country => $query->param ('institution-country'),
institution_address => $query->param ('institution-address'),
institution_url => $query->param ('institution-url'),
opened => sprintf ('%d-%.2d-%.2d', $dt->year, $dt->month, $dt->day),
name => $query->param ('name'),
email => $query->param ('email'),
group => $query->param ('group') || '',
contact => $query->param ('contact') };
$template->process ('pdfreaders-mail.tt2', $data, \$mail);
open MAIL, "|/usr/lib/sendmail -t -f web\@fsfeurope.org";
print MAIL $mail;
close MAIL;
my $output = <<'EOF';
<div id="flash">
<p>All data recorded, we will get in touch with you very soon.</p>
</div>
EOF
$content->content ($output);
$content->render

View File

@ -0,0 +1,2 @@
This directory contains files that are to be runtime-processed by Template
Toolkit.

View File

@ -0,0 +1,21 @@
From: web@fsfeurope.org
To: pdfreaders@lists.fsfe.org
Subject: [PDFReaders] New bug for [% institution_country %]
Content-Type: text/plain
A new PDFReaders bug has been reported by [% name %] <[% email %]>
for [% institution_country %]. [% name %] is [% IF !contact %]not [% END %]available for contact.
Please validate and use the following XML snippet if appropriate:
---
<bug institution-name="[% institution_name %]"
institution-address="[% institution_address %]"
institution-url="[% institution_url %]"
opened="[% opened %]"
closed=""
name="[% name %]"
group="[% group %]"
/>
---