Initial checkin of 'Hendrix' - mozilla.org web-to-news feedback system.

This commit is contained in:
gerv%gerv.net 2004-12-28 15:00:27 +00:00
Родитель 12dedfb94b
Коммит 6bf5b5212c
10 изменённых файлов: 493 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,56 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Hendrix Feedback System.
*
* The Initial Developer of the Original Code is
* Gervase Markham.
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** */
#header-img {
float: right;
border: 1px grey solid;
}
p.error {
color: red;
}
.footnote {
font-size: small;
}
h1 {
font-size: x-large;
}
input[type="text"] {
font-family: monospace;
}
#name, #email {
width: 25em;
}
#subject, #comments {
width: 45em;
}
#comments {
height: 20ex;
}

Двоичные данные
webtools/hendrix/hendrix.jpg Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 6.6 KiB

117
webtools/hendrix/index.cgi Executable file
Просмотреть файл

@ -0,0 +1,117 @@
#!/usr/bin/perl -wT
# -*- Mode: perl; indent-tabs-mode: nil -*-
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is the Hendrix Feedback System.
#
# The Initial Developer of the Original Code is
# Gervase Markham.
# Portions created by the Initial Developer are Copyright (C) 2004
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# ***** END LICENSE BLOCK *****
use strict;
# This application requires installation of the "Email::Send" (note: not
# Mail::Send) module.
use Template;
use CGI;
use Email::Send qw(NNTP);
# use CGI::Carp qw(fatalsToBrowser);
# Configuration
my $newsgroup = "netscape.public.mozilla.test";
my $server = "news.mozilla.org";
my $cgi = new CGI;
my $form = $cgi->Vars;
my $vars;
$vars->{'form'} = $form;
$vars->{'newsgroup'} = $newsgroup;
my $template = Template->new({
INCLUDE_PATH => ["template"],
PRE_CHOMP => 1,
TRIM => 1,
FILTERS => {
email => \&emailFilter,
},
}) || die("Template creation failed.\n");
my $action = $cgi->param("action");
if (!$action) {
# If no action, show the submission form
print "Content-Type: text/html\n\n";
$template->process("index.html.tmpl", $vars)
|| die("Template process failed: " . $template->error() . "\n");
}
elsif ($action eq "submit") {
# Format the parameters and send to the newsgroup.
# Check for compulsory parameters
if (!$form->{'name'} || !$form->{'subject'} || !$form->{'product'}) {
throwError("bad_parameters");
}
my $message;
my $headers;
$template->process("message-headers.txt.tmpl", $vars, \$headers)
|| die("Template process failed: " . $template->error() . "\n");
$template->process("message.txt.tmpl", $vars, \$message)
|| die("Template process failed: " . $template->error() . "\n");
# Post formatted message to newsgroup
my $newsMsg = Email::Simple->new($headers . "\n\n" . $message);
my $success = send NNTP => $newsMsg, $server;
throwError("cant_post") if (!$success);
# Give user feedback on success
$vars->{'headers'} = $headers;
$vars->{'message'} = $message;
print "Content-Type: text/html\n\n";
$template->process("submit-successful.html.tmpl", $vars)
|| die("Template process failed: " . $template->error() . "\n");
}
else {
die("Unknown action $action\n");
}
exit;
# Simple email obfuscation
sub emailFilter {
my ($var) = @_;
$var =~ s/\@/_at_/;
return $var;
}
sub throwError {
my ($error) = @_;
$vars->{'error'} = $error;
print "Content-Type: text/html\n\n";
$template->process("error.html.tmpl", $vars)
|| die("Template process failed: " . $template->error() . "\n");
exit;
}

Просмотреть файл

@ -0,0 +1,55 @@
[%# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is the Hendrix Feedback System.
#
# The Initial Developer of the Original Code is
# Gervase Markham.
# Portions created by the Initial Developer are Copyright (C) 2004
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# ***** END LICENSE BLOCK ***** %]
[% PROCESS header.html.tmpl
title = "Hendrix - Error" %]
<p>Unfortunately, there is a problem with your submission, as follows:
</p>
[% SWITCH error %]
[% CASE "bad_parameters" %]
<p class="error">
You need to give both your name and a summary of your feedback.
</p>
<p>Please press Back and fill in the missing field(s).</p>
[% CASE "cant_post" %]
<p class="error">
We are unable to send your feedback to the server.
</p>
<p>Please try again later. Your feedback is reproduced below so you can
save it somewhere.</p>
<pre>
[% message FILTER html %]
</pre>
[% CASE DEFAULT %]
The error is unknown. Please try again later.
[% END %]
[% PROCESS footer.html.tmpl %]

Просмотреть файл

@ -0,0 +1,26 @@
[%# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is the Hendrix Feedback System.
#
# The Initial Developer of the Original Code is
# Gervase Markham.
# Portions created by the Initial Developer are Copyright (C) 2004
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# ***** END LICENSE BLOCK ***** %]
</body>
</html>

Просмотреть файл

@ -0,0 +1,42 @@
[%# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is the Hendrix Feedback System.
#
# The Initial Developer of the Original Code is
# Gervase Markham.
# Portions created by the Initial Developer are Copyright (C) 2004
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# ***** END LICENSE BLOCK ***** %]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>[% title %]</title>
<link rel="stylesheet" href="hendrix.css">
</head>
<body>
<img id="header-img" src="hendrix.jpg">
[% IF NOT h1 AND title %]
[% h1 = title %]
[% END %]
[% IF h1 %]
<h1>[% h1 %]</h1>
[% END %]

Просмотреть файл

@ -0,0 +1,96 @@
[%# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is the Hendrix Feedback System.
#
# The Initial Developer of the Original Code is
# Gervase Markham.
# Portions created by the Initial Developer are Copyright (C) 2004
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# ***** END LICENSE BLOCK ***** %]
[% PROCESS header.html.tmpl
title = "Hendrix - mozilla.org Feedback System"
%]
<p>This is Hendrix - the mozilla.org system for leaving quick and general feedback. If you have a specific and detailed bug report, please file it in
<a href="http://bugzilla.mozilla.org/enter_bug.cgi">Bugzilla</a>.</p>
<form id="feedback-form" method="GET">
<table id="feedback-table">
<tr>
<td class="label">Name:</td>
<td class="widget">
<input id="name" name="name" type="text"
value="[% form.email FILTER html %]"/>
</td>
</tr>
<tr>
<td class="label">Email (optional):</td>
<td class="widget">
<input id="email" name="email" type="text"
value="[% form.email FILTER html %]"/>
</td>
</tr>
<tr>
<td class="label">
Product:
</td>
<td class="widget">
<select id="product" name="product">
<option name="Firefox">Firefox</option>
<option name="Thunderbird">Thunderbird</option>
<option name="Mozilla Suite">Mozilla Suite</option>
<option name="Camino">Camino</option>
<option name="Other">Other (please state)</option>
</select>
</td>
</tr>
<tr>
<td class="label">
Feedback Summary:
</td>
<td class="widget">
<input id="subject" name="subject" type="text"
value="[% form.subject FILTER html %]"/>
</td>
</tr>
<tr>
<td class="label">
Detailed Comments:
</td>
<td class="widget">
<textarea id="comments" name="comments" wrap="hard"
>[% form.comments FILTER html %]</textarea>
</td>
</tr>
</table>
<input type="hidden" name="action" value="submit"/>
[%# Add JS to only enable button when form is filled in %]
<input id="send-feedback" type="submit" value="Send Feedback"/>
</form>
<p>Information from this form is placed in the newsgroup
<tt>[% newsgroup %]</tt> where it can be viewed by any mozilla.org contributor.
</p>
<p class="footnote">Why "Hendrix"? The late
<a href="http://en.wikipedia.org/wiki/Jimi_Hendrix">Jimi Hendrix</a>
is credited with making popular the technique of making feedback useful in the creation of music :-).</p>
[% PROCESS footer.html.tmpl %]

Просмотреть файл

@ -0,0 +1,33 @@
[%# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is the Hendrix Feedback System.
#
# The Initial Developer of the Original Code is
# Gervase Markham.
# Portions created by the Initial Developer are Copyright (C) 2004
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# ***** END LICENSE BLOCK ***** %]
[% from = form.name %]
[% IF form.email %]
[% from = BLOCK %]
[% from %] <[% form.email FILTER email %]>
[% END %]
[% END %]
Newsgroups: [% newsgroup %]
From: [% from %]
X-Hendrix-Product: [% form.product %]
Subject: [Hendrix] [% form.subject %]

Просмотреть файл

@ -0,0 +1,32 @@
[%# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is the Hendrix Feedback System.
#
# The Initial Developer of the Original Code is
# Gervase Markham.
# Portions created by the Initial Developer are Copyright (C) 2004
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# ***** END LICENSE BLOCK ***** %]
Name: [% form.name %]
[% IF form.email %]
Email: [% form.email FILTER email %]
[% END %]
Product: [% form.product %]
Summary: [% form.subject %]
Comments:
[%+ form.comments %]

Просмотреть файл

@ -0,0 +1,36 @@
[%# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is the Hendrix Feedback System.
#
# The Initial Developer of the Original Code is
# Gervase Markham.
# Portions created by the Initial Developer are Copyright (C) 2004
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# ***** END LICENSE BLOCK ***** %]
[% PROCESS header.html.tmpl
title = "Hendrix - Submission Successful" %]
<p>Thank you for your feedback, and for using our software.</p>
<p>Your message was:</p>
<pre>
[% message FILTER html %]
</pre>
[% PROCESS footer.html.tmpl %]