From owner-freebsd-www@FreeBSD.ORG Fri Apr 8 13:40:14 2005 Return-Path: Delivered-To: freebsd-www@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9CBC116A4CE; Fri, 8 Apr 2005 13:40:14 +0000 (GMT) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.185]) by mx1.FreeBSD.org (Postfix) with ESMTP id C0F8043D5C; Fri, 8 Apr 2005 13:40:13 +0000 (GMT) (envelope-from max@love2party.net) Received: from [212.227.126.207] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1DJtiW-00061t-00; Fri, 08 Apr 2005 15:40:12 +0200 Received: from [84.163.233.210] (helo=donor.laier.local) by mrelayng.kundenserver.de with asmtp (TLSv1:RC4-MD5:128) (Exim 3.35 #1) id 1DJtiW-000753-00; Fri, 08 Apr 2005 15:40:12 +0200 Resent-From: Max Laier Resent-To: freebsd-www@freebsd.org Resent-Date: Fri, 8 Apr 2005 15:37:25 +0200 Resent-Message-ID: <200504081537.25423.max@love2party.net> From: Max Laier To: freebsd-www@freebsd.org Date: Fri, 8 Apr 2005 15:40:02 +0200 User-Agent: KMail/1.8 MIME-Version: 1.0 Message-Id: <200504081532.19834.max@love2party.net> Content-Type: multipart/signed; boundary="nextPart26509298.xbQl9BczT9"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:61c499deaeeba3ba5be80f48ecc83056 cc: monthly@freebsd.org Subject: [CGI] (Bi-)Monthly XML-composer X-BeenThere: freebsd-www@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: FreeBSD Project Webmasters List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Apr 2005 13:40:14 -0000 --nextPart26509298.xbQl9BczT9 Content-Type: multipart/mixed; boundary="Boundary-01=_0moVCALeEYrhdP+" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_0moVCALeEYrhdP+ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, [ okay, I should set the attachment content-type to text/plain as well, I guess - sorry if this turns into a dup ] as discussed here briefly after the last round of the status reports, Julia= n=20 has come up with a CGI-script that helps to fill the bi-monthly status repo= rt=20 xml-template. I extended it slightly to take care of the newer features. = In=20 contrast to Julian's original approach, this one also sets "Content-Type:=20 text/plain" so that you get a download of the resulting xml, rather than a= =20 html to copy and paste from. I found that easier to handle esp. in=20 cli-environments. In preparation on the next round of status-reports, we'd like to get someth= ing=20 along those lines on the FreeBSD website ASAP. Hence I really appreciate=20 review and especially style nits ("cooperate identity" etc.). Thanks in advance, and many thanks to Julian for coming up with the prototy= pe. =2D-=20 /"\ Best regards, | mlaier@freebsd.org \ / Max Laier | ICQ #67774661 X http://pf4freebsd.love2party.net/ | mlaier@EFnet / \ ASCII Ribbon Campaign | Against HTML Mail and News --Boundary-01=_0moVCALeEYrhdP+ Content-Type: text/plain; charset="us-ascii"; name="newmailto.cgi" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="newmailto.cgi" #!/usr/bin/perl -w ###########################################################################= ##### use CGI qw(:all); use strict; ###########################################################################= ##### my $Submit =3D param("Submit"); my $debug =3D param("debug") || ""; my $NumDevelopers =3D 3; my $NumLinks =3D 4; my $NumTasks =3D 5; my @messages; ###########################################################################= ##### # # Routine to format some xml nicely # sub xml { my($Indent, $TagEtc, @Text) =3D @_; my($Tag, $Etc) =3D split(' ', $TagEtc, 2); my $Spaces =3D " " x ($Indent*3); if (!@Text) { # No text in the tag return ("$Spaces<$TagEtc >\n"); } elsif (@Text =3D=3D 1) { # Bottom level tag - output on one line return ("$Spaces<$TagEtc>@Text\n"); } else { # This is not a bottom level tag - output a new line after starting tag return ("$Spaces<$TagEtc>\n", @Text, "$Spaces\n"); } } # # As above to format indented text but no tag # sub xmltext { my($Indent, @Text) =3D @_; my $Spaces =3D " " x ($Indent*3); return map { "$Spaces$_\n" } @Text; } ###########################################################################= ##### my $mailto =3D "monthly\@freebsd.org"; my $url =3D url; ###########################################################################= ##### if ($Submit) { my $errors =3D 0; my @hidden; my $Project =3D param("Project") || ""; my $Category =3D param("Category") || "misc"; push(@hidden, hidden("Project")); my @contacts; foreach my $Num (1..$NumDevelopers) { my $fname =3D param("FirstName$Num") || ""; my $lname =3D param("LastName$Num") || ""; my $email =3D param("Email$Num") || ""; push(@hidden, hidden("FirstName$Num")); push(@hidden, hidden("LastName$Num")); push(@hidden, hidden("Email$Num")); next unless $fname || $lname || $email; my @name; push(@name, xml(4, 'given', $fname)) if $fname; push(@name, xml(4, 'common', $lname)) if $lname; my @person; push(@person, xml(3, 'name', "", @name)) if @name; push(@person, xml(3, 'email', $email)) if $email; push(@contacts, xml(2, 'person', "", @person)); } if (!@contacts) { ++$errors; push(@messages, b("Please specify at least one contact")); } my @links; foreach my $Num (1..$NumLinks) { my $url =3D param("Url$Num") || ""; my $desc =3D param("Desc$Num") || ""; push(@hidden, hidden("Url$Num")); push(@hidden, hidden("Desc$Num")); next unless $url; my @link; if ($desc) { push(@links, xml(2, "url href=3D\"$url\"", $desc)); } else { push(@links, xml(2, "url href=3D\"$url\"")); } } my @tasks; foreach my $Num (1..$NumTasks) { my $desc =3D param("Task$Num") || ""; $desc =3D~ s/\r//g; my @desc =3D split("\n", $desc); push(@hidden, hidden("Task$Num")); next unless $desc; push(@tasks, xml(2, "task", "",xmltext(3, @desc))); } my $info =3D param("SubmittedInfo") || ""; push(@hidden, hidden("SubmittedInfo")); $info =3D~ s/\r//g; my @info =3D split("\n", $info); my $title =3D "FreeBSD project submission output"; my @contents =3D xml(0, "project cat=3D\'$Category\'", xml(1, "title", $Project), "\n", xml(1, "contact", "", @contacts), "\n", xml(1, "links", "", @links), "\n", xml(1, "body", xml(2, "p", "", xmltext(3, @info))), # Ensure it's a list "\n", xml(1, "help", "", @tasks), ); my $contents =3D join('', @contents); $contents =3D "\n$contents"; if (!$errors) { # print=20 # (header, # start_html(-title =3D> $title), # h1($title), # "Copy this form, touch up as needed, and mail it to $mailto", # br, # start_form(-name =3D> 'EditForm'), # @hidden, # submit(-name =3D> "Edit",=20 # -label =3D> "Edit Contents"), # end_form, # "\n", # start_form(-name =3D> 'MailForm',=20 #? -action =3D> "mailto:$mailto"), # -method =3D> 'GET', # -action =3D> "mailto:$mailto?Subject=3Dxxx&Body=3DAAAA"), # hidden("CONTENTS", $contents), # submit(-name =3D> "Mail",=20 # -label =3D> "Mail Contents"), # end_form, # hr, # "
\n",
#		   $contents.
#		   "
\n", # hr); # # print &cgi_context if ($debug); # print end_html; # exit; print "Content-Type: text/plain\n\n"; print $contents; exit; } } ###########################################################################= ##### my @DeveloperTable; foreach my $Num (1..$NumDevelopers) { push(@DeveloperTable, TR(td(textfield(-name =3D> "FirstName$Num", -size =3D> 20)), td(textfield(-name =3D> "LastName$Num", -size =3D> 20)), td(textfield(-name =3D> "Email$Num", -size =3D> 32)))); } my @LinksTable; foreach my $Num (1..$NumLinks) { push(@LinksTable, TR(td(textfield(-name =3D> "Url$Num", -size =3D> 55)), td(textfield(-name =3D> "Desc$Num", -size =3D> 20)))); } my @TaskTable; foreach my $Num (1..$NumTasks) { push(@TaskTable, TR(td(textarea(-name =3D> "Task$Num", -rows =3D> 3, -cols =3D> 60)))); } print (header, start_html(-title =3D> "FreeBSD Project Report", -BGCOLOR =3D> "#FFFFFF"), =20 b(font({ -color =3D> "#008080", -size =3D> "+4"}, "Submitting a FreeBSD Project Status Report")), hr, join("
\n", @messages, ""), p, "To submit status information about a FreeBSD project, fill out the foll= owing:", br, start_form(), hidden(-name =3D> "ij_emailaddr", -value =3D> $mailto), hidden(-name =3D> "ij_subject", -value =3D> "Project monthly report"), hidden(-name =3D> "ij_confirmurl", -value =3D> "/organization/confirm.ht= m"), =20 h3("Project:"), textfield(-name =3D> "Project", -size =3D> "32"), h3("Category:"), scrolling_list(-name =3D> "Category", -values =3D> ['proj', 'docs', 'ker= n', 'arch', 'ports', 'vendor', 'misc'], -default =3D> ['proj'], -size = =3D> 7, -multiple =3D> 'false', -lables =3D> {'proj'=3D> 'Projects (non-spec= ific)', 'docs' =3D> 'Documentation', 'kern' =3D> 'Kernel', 'arch' =3D> 'Arch= itectures', 'ports' =3D> 'Ports', 'vendor' =3D> 'Vendor / 3rd party software', 'misc' =3D> 'Miscellaneous' }), =20 h3("Developers:"), blockquote(table({"BORDER" =3D> 1, "COLS" =3D> 3, "WIDTH" =3D> "80%", "NOSAVE" =3D> 1}, TR(td("First Name"), td("Family Name"), td("Email address")), @DeveloperTable)), =20 h3("Links:"), blockquote(table({"BORDER" =3D> 1, "COLS" =3D> 2, "WIDTH" =3D> "80%", "NOSAVE" =3D> 1}, TR(td("Url"), td("Description (optional)")), @LinksTable)), =20 h3("Present status:"), blockquote(textarea(-name =3D> "SubmittedInfo", -rows =3D> 7, -cols =3D> 60)), h3("Open tasks (optional):"), blockquote(table({"BORDER" =3D> 1, "COLS" =3D> 5, "WIDTH" =3D> "80%", "NOSAVE" =3D> 1}, TR(td("Description")), @TaskTable)), submit(-name =3D> "Submit", -label =3D> "Download XML"), reset(-value =3D> "Reset"), br, end_form(), hr, end_html); ###########################################################################= ##### __END__ ###########################################################################= ##### --Boundary-01=_0moVCALeEYrhdP+-- --nextPart26509298.xbQl9BczT9 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (FreeBSD) iD8DBQBCVom5XyyEoT62BG0RAop6AJwPw10GTKdAUr3RZW9BuEqJMMa90gCcDjvG FGmByfdLB2XMV66XRFPhwgc= =6Qr/ -----END PGP SIGNATURE----- --nextPart26509298.xbQl9BczT9--