[NUUG fiksgatami] [patch] Avoid some hardcoded fixmystreet.com references

Petter Reinholdtsen pere at hungry.com
Wed Jan 14 20:59:15 CET 2009


[Matthew Somerville]
> Thanks :-) On all but the first though - HTTP redirects must be
> absolute, not relative (RFC2616 14.30). I guess you'll need to add
> OPTION_BASE_URL (if I remember correctly) to the lines.

Right.  Here is a new version of those parts.

Index: web/index.cgi
===================================================================
RCS file: /repos/mysociety/bci/web/index.cgi,v
retrieving revision 1.238
diff -u -3 -p -r1.238 index.cgi
--- web/index.cgi       10 Jan 2009 18:37:45 -0000      1.238
+++ web/index.cgi       14 Jan 2009 19:56:54 -0000
@@ -60,7 +60,8 @@ sub main {
                 $q->param('phone', $row[6]);
                 $q->param('partial', $partial);
             } else {
-                print $q->redirect(-location => 'http://www.fixmystreet.com/report/' . $id);
+                my $base = mySociety::Config::get('BASE_URL');
+                print $q->redirect(-location => $base . '/report/' . $id);
             }
         }
     }
@@ -725,7 +726,8 @@ sub display_location {
     my %input_h = map { $_ => $q->param($_) ? ent($q->param($_)) : '' } @vars;

     if ($input{y} =~ /favicon/) {
-        print $q->redirect(-location => 'http://www.fixmystreet.com/favicon.ico', -status => 301);
+        my $base = mySociety::Config::get('BASE_URL');
+        print $q->redirect(-location => $base . '/favicon.ico', -status => 301);
         return '';
     }
     my($error, $easting, $northing);
Index: web/rss.cgi
===================================================================
RCS file: /repos/mysociety/bci/web/rss.cgi,v
retrieving revision 1.26
diff -u -3 -p -r1.26 rss.cgi
--- web/rss.cgi 8 Dec 2008 10:54:16 -0000       1.26
+++ web/rss.cgi 14 Jan 2009 19:56:54 -0000
@@ -42,7 +42,8 @@ sub main {
     } elsif ($type eq 'all_problems') {
         $out = mySociety::Alert::generate_rss($type, $xsl, '');
     } else {
-        print $q->redirect('http://www.fixmystreet.com/alert');
+        my $base = mySociety::Config::get('BASE_URL');
+        print $q->redirect($base . '/alert');
         exit;
     }
     print $q->header( -type => 'application/xml; charset=utf-8' );
@@ -77,7 +78,8 @@ sub rss_local_problems {
             $error = shift;
         };
         unless ($error) {
-            print $q->redirect(-location => "http://www.fixmystreet.com/rss/$x/$y");
+            my $base = mySociety::Config::get('BASE_URL');
+            print $q->redirect(-location => $base . "/rss/$x/$y");
         }
         return '';
     } else {


Happy hacking,
-- 
Petter Reinholdtsen


More information about the fiksgatami mailing list