Bug 113071

Summary: [patch] improve query-pr.cgi
Product: Documentation Reporter: edwin
Component: Books & ArticlesAssignee: Simon L. B. Nielsen <simon>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff
none
query-pr.cgi.diff.2
none
dosendpr.diff none

Description edwin 2007-05-28 01:40:03 UTC
<Mavvie> See http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/106049
<Mavvie> If you see the URL at "Download diff-2", you see that it has ?'s and &'s in it.
<Mavvie> when entering this on the command line, to download with fetch, I have to use 's around the URL to download it.
<Mavvie> The second thing is, when I download it with fetch, the filename of the file downloaded is "query-pr.cgi?pr=106049&getpatch=2"
<Mavvie> For both I have a solution :-)
<Cydex> Mavvie: hooray
<Mavvie> The patch-number can be incorpearted in the PR number. For example, instead of pr=106049&getpatch=2 you can use pr=106049-2 
<Mavvie> And for the filename you can specify the content-location and filename in the HTTP header:
<Cydex> Good idea!
<Mavvie> Content-Disposition: inline; filename="patch-2.diff"'
<Mavvie> that should make the name of the downloaded file to patch-2.diff.
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2007-05-28 01:41:42 UTC
Responsible Changed
From-To: freebsd-www->shaun

Shaun@ said he was interested in these patches
Comment 2 edwin 2007-05-28 02:21:47 UTC
This one also takes care of the other type of downloadable types:
shar, txt, uu, diff.

Index: query-pr.cgi
===================================================================
RCS file: /home/dcvs/www/en/cgi/query-pr.cgi,v
retrieving revision 1.61
diff -u -r1.61 query-pr.cgi
--- query-pr.cgi	10 Jan 2007 17:47:39 -0000	1.61
+++ query-pr.cgi	28 May 2007 01:20:38 -0000
@@ -29,6 +29,13 @@
 # $FreeBSD: www/en/cgi/query-pr.cgi,v 1.61 2007/01/10 17:47:39 danger Exp $
 #
 
+#
+# Note: this is a script to run on a webserver. If you want to do tests
+# on the command-line, use the QUERY_STRING environment variable to
+# pass parameters to the script:
+#	$ QUERY_STRING=pr=bin/106049 ./query-pr.cgi
+#
+
 use strict;
 
 use MIME::Base64;                      # ports/converters/p5-MIME-Base64
@@ -39,7 +46,7 @@
 require './query-pr-lib.pl';
 
 use constant HTTP_HEADER        => "Content-type: text/html; charset=UTF-8\r\n\r\n";
-use constant HTTP_HEADER_PATCH  => "Content-type: text/plain; charset=UTF-8\r\n\r\n";
+use constant HTTP_HEADER_PATCH  => "Content-type: text/plain; charset=UTF-8\r\nContent-Disposition: inline; filename=\"%s\"\r\n\r\n";
 
 use constant SECT_HEADER        => 1;
 use constant SECT_SFIELDS       => 2;
@@ -80,6 +87,7 @@
 my $f = "";
 my $PR = -1;
 my $getpatch = -1;
+my $mimepatch = "";
 my $inpatch = 0;
 my $patchendhint = 0;
 my $category;
@@ -149,7 +157,7 @@
 $fmt{'patchblock_thead'} = <<EOF;
 <table class="patchblock" cellspacing="0" cellpadding="3">
   <tr class="info"><td>
-    <b>Download <a href="${scriptname}?pr=%%(pr)&amp;getpatch=%%(1)">%%(2)</a></b>
+    <b>Download <a href="${scriptname}?prp=%%(pr)-%%(1)-%%(3)">%%(2)</a></b>
   </td></tr>
 <tr><td class="content"><pre>
 EOF
@@ -246,12 +254,31 @@
 		$PR       = lc $val if ($key eq "pr" or $key eq "q");
 		$PR       = lc $key if ($key =~ /^(?:$valid_category\/)?$valid_pr$/i);
 		$category = lc $val if ($key eq "cat");
-		$getpatch = lc $val if ($key eq "getpatch");
+
+		if ($key eq "prp") {
+			if ( lc ($val) =~ /^(\d+)\-(\d+)-(.+)$/ ) {
+				$PR = $1;
+				$getpatch = $2;
+				$mimepatch = $3;
+			}
+		}
 	}
 }
 
 unless (!$iscgi) {
-	print HTTP_HEADER_PATCH if ($getpatch > 0 or $f eq "raw");
+	if ($getpatch > 0 or $f eq "raw") {
+		if ($mimepatch eq "diff") {
+			printf HTTP_HEADER_PATCH,"patch-$getpatch.diff"
+		} elsif ($mimepatch eq "shar") {
+			printf HTTP_HEADER_PATCH,"shar-$getpatch.sh"
+		} elsif ($mimepatch eq "uu") {
+			printf HTTP_HEADER_PATCH,"patch-$getpatch.uu"
+		} elsif ($mimepatch eq "txt") {
+			printf HTTP_HEADER_PATCH,"txt-$getpatch.txt"
+		} else {
+			printf HTTP_HEADER_PATCH,"unknown-$getpatch.txt"
+		}
+	}
 }
 
 ($category, $PR) = ($1, $2)
@@ -988,7 +1015,7 @@
 		$lastcol = undef;
 		$lastrev = undef;
 
-		sprint('patchblock_thead', $patchnum, htmlclean($1))
+		sprint('patchblock_thead', $patchnum, htmlclean($1), "txt")
 			unless ($getpatch);
 
 		return 1;
@@ -1001,7 +1028,7 @@
 		$lastcol = undef;
 		$lastrev = undef;
 
-		sprint('patchblock_thead', $patchnum, "patch-$patchnum.diff")
+		sprint('patchblock_thead', $patchnum, "patch-$patchnum.diff", "diff")
 			unless ($getpatch);
 	}
 
@@ -1012,7 +1039,7 @@
 		$lastcol = undef;
 		$lastrev = undef;
 
-		sprint('patchblock_thead', $patchnum, "patch-$patchnum.shar")
+		sprint('patchblock_thead', $patchnum, "shar-$patchnum.sh", "shar")
 			unless ($getpatch);
 	}
 
@@ -1042,7 +1069,7 @@
 			$patchnum++;
 			return 1 if ($getpatch and $patchnum != $getpatch);
 		}
-		sprint('patchblock_thead', $patchnum, "patch-$patchnum.uu")
+		sprint('patchblock_thead', $patchnum, "patch-$patchnum.uu", "uu")
 			unless ($getpatch or $inpatch);
 
 		$inpatch |= PATCH_UUENC;
-- 
Edwin Groothuis      |            Personal website: http://www.mavetju.org
edwin@mavetju.org    |              Weblog: http://www.mavetju.org/weblog/
Comment 3 Shaun Amott freebsd_committer freebsd_triage 2007-05-31 02:45:55 UTC
Here's an updated version with a few tweaks plus a fix for the URL
parser.

-- 
Shaun Amott // PGP: 0x6B387A9A
"A foolish consistency is the hobgoblin
of little minds." - Ralph Waldo Emerson
Comment 4 Shaun Amott freebsd_committer freebsd_triage 2007-05-31 03:12:02 UTC
Responsible Changed
From-To: shaun->simon

02:19 <@Mavvie> go for it! 
02:19 <@Mavvie> it's commit time! 
02:22 <@Cydex> Mavvie: we need a doc person 
02:22 <@Cydex> Chimera is absent :-( 
02:23 <@Mavvie> Assign the PR to him, stating that you approved it. 
02:24 <@Mavvie> that's the best way to go I think. 
02:24 <@Mavvie> workflows workflows workflows... 

Feel free to bounce this back to me if you don't have time to look at 
it.
Comment 5 Shaun Amott freebsd_committer freebsd_triage 2007-06-10 14:09:18 UTC
We've got another little patch for the web PR submit script. Speaks for
itself, I think. :-)

-- 
Shaun Amott // PGP: 0x6B387A9A
"A foolish consistency is the hobgoblin
of little minds." - Ralph Waldo Emerson
Comment 6 dfilter service freebsd_committer freebsd_triage 2007-06-12 20:38:40 UTC
simon       2007-06-12 19:38:31 UTC

  FreeBSD doc repository

  Modified files:
    en/cgi               query-pr.cgi 
  Log:
  - Send a patch file-name in the HTTP header via the
    Content-Disposition header.
  - When downloading/referring to a particular patch embed the patch
    number with the PR instead of using two different CGI variables.
    This means that there aren't "&" in the patch URL's anymore which
    makes things simpler for sh(1) like shells, by not requiring quoting
    of URLs when using a command line tool, such as fetch(1), to
    download patches.
  - In HTML-ifying of URL's, handle when a URL contains a PR like string
    which can e.g. be seen in PR www/113071.
  - Add a comment about how to test script via the command line.
  
  Submitted by:   edwin, shaun
  PR:             www/113071
  
  Revision  Changes    Path
  1.62      +37 -9     www/en/cgi/query-pr.cgi
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 7 dfilter service freebsd_committer freebsd_triage 2007-06-12 21:03:13 UTC
simon       2007-06-12 20:03:05 UTC

  FreeBSD doc repository

  Modified files:
    en/cgi               dosendpr.cgi 
  Log:
  Add missing space in From when "building" the PR.
  
  Submitted by:   shaun
  PR:             www/113071
  Hijacked unrelated PR for patch:        shaun
  
  Revision  Changes    Path
  1.34      +2 -2      www/en/cgi/dosendpr.cgi
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 8 Simon L. B. Nielsen freebsd_committer freebsd_triage 2007-06-16 08:59:42 UTC
State Changed
From-To: open->closed

Patch committed, thanks for the submission :-)