link-checker commit: Apply parameters from cookie only when loading the "front" page.

changeset:   77:224ca98f526f
user:        ville
date:        Tue Jun 01 21:49:59 2004 +0000
files:       bin/checklink
description:
Apply parameters from cookie only when loading the "front" page.
Also, only load the cookie we set (not all possibly sent to us), when
deciding how to output the cookie options on the front page.
This should make the effect of the cookie more predictable.


diff -r 225fc4e71397 -r 224ca98f526f bin/checklink
--- a/bin/checklink	Tue Jun 01 19:18:33 2004 +0000
+++ b/bin/checklink	Tue Jun 01 21:49:59 2004 +0000
@@ -5,7 +5,7 @@
 # (c) 1999-2004 World Wide Web Consortium
 # based on Renaud Bruyeron's checklink.pl
 #
-# $Id: checklink,v 3.47 2004-06-01 19:18:33 ville Exp $
+# $Id: checklink,v 3.48 2004-06-01 21:49:59 ville Exp $
 #
 # This program is licensed under the W3C(r) Software License:
 #       http://www.w3.org/Consortium/Legal/copyright-software
@@ -112,7 +112,7 @@
   $PACKAGE       = 'W3C Link Checker';
   $PROGRAM       = 'W3C-checklink';
   $VERSION       = '3.9.3-dev';
-  my ($cvsver)   = q$Revision: 3.47 $ =~ /(\d+[\d\.]*\.\d+)/;
+  my ($cvsver)   = q$Revision: 3.48 $ =~ /(\d+[\d\.]*\.\d+)/;
   $REVISION      = sprintf('version %s [%s] (c) 1999-2004 W3C',
                            $VERSION, $cvsver);
   $AGENT         = sprintf('%s/%s [%s] %s',
@@ -285,21 +285,25 @@
   $Opts{_Self_URI} = $query->url(-relative => 1);
 
   # Backwards compatibility
+  my $uri = undef;
+  if ($uri = $query->param('url')) {
+    $query->param('uri', $uri) unless $query->param('uri');
+    $query->delete('url');
+  }
+  $uri = $query->param('uri');
+
+  if (! $uri) {
+    &html_header('', 1); # Set cookie only from results page.
+    &print_form($query);
+    &html_footer();
+    exit;
+  }
+
+  # Backwards compatibility
   if ($query->param('hide_dir_redirects')) {
     $query->param('hide_redirects', 'on');
     $query->param('hide_type', 'dir');
     $query->delete('hide_dir_redirects');
-  }
-  if (my $uri = $query->param('url')) {
-    $query->param('uri', $uri) unless $query->param('uri');
-    $query->delete('url');
-  }
-
-  # Override undefined values from the cookie, if we got one.
-  if (my %cookie = $query->cookie($PROGRAM)) {
-    while (my ($key, $value) = each %cookie) {
-      $query->param($key, $value) unless defined($query->param($key));
-    }
   }
 
   $Opts{Summary_Only} = 1 if $query->param('summary');
@@ -317,7 +321,7 @@
 
   $Opts{Depth} = -1 if ($query->param('recursive') && $Opts{Depth} == 0);
   if (my $depth = $query->param('depth')) {
-    # Ignore invalid depth silently for now.
+    # @@@ Ignore invalid depth silently for now.
     $Opts{Depth} = $1 if ($depth =~ /(-?\d+)/);
   }
 
@@ -343,15 +347,6 @@
       }
     }
     $cookie = $query->cookie(%cookie);
-  }
-
-  my $uri = $query->param('uri');
-
-  if (! $uri) {
-    &html_header('', 1); # Set cookie only from results page.
-    &print_form($query);
-    &html_footer();
-    exit;
   }
 
   undef $query; # Not needed any more.
@@ -2066,6 +2061,15 @@
 {
   my ($q) = @_;
 
+  # Override undefined values from the cookie, if we got one.
+  my $got_cookie = 0;
+  if (my %cookie = $q->cookie($PROGRAM)) {
+    $got_cookie = 1;
+    while (my ($key, $value) = each %cookie) {
+      $q->param($key, $value) unless defined($q->param($key));
+    }
+  }
+
   my $chk = ' checked="checked"';
   $q->param('hide_type', 'all') unless $q->param('hide_type');
 
@@ -2078,7 +2082,7 @@
   my $dep = &encode($q->param('depth')              || '');
 
   my $cookie_options = '';
-  if ($q->cookie()) {
+  if ($got_cookie) {
     $cookie_options = "
     <label for=\"cookie1\"><input type=\"radio\" id=\"cookie1\" name=\"cookie\" value=\"nochanges\" checked=\"checked\"> Don't modify saved options</label>
     <label for=\"cookie2\"><input type=\"radio\" id=\"cookie2\" name=\"cookie\" value=\"set\"> Save these options</label>

Received on Thursday, 5 August 2010 14:47:09 UTC