]> xenbits.xensource.com Git - people/aperard/emesinae.git/commitdiff
CGI: Include bugid as a path element instead of a CGI argument.
authorIan Campbell <ian.campbell@citrix.com>
Fri, 24 May 2013 12:11:04 +0000 (13:11 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 24 May 2013 12:36:33 +0000 (13:36 +0100)
This means that a bug URL changes from
http://.../test/bug.pl?id=N
to
http://.../test/bug/N

This is apparently much friendlier to search engines.

While there generate a 404 for a missing bug.

CGI/bug.pl
CGI/common.pl
TODO
config/examples/test/apache.conf
config/examples/xen-bugs.xenproject.org/apache.conf
config/examples/xen-bugs.xenproject.org/emesinae.conf
scripts/control.pl

index ba0bb6f6a70f705ab0dcb63142c6a523c393aa2f..3e812aa9b0f0ed2c77e46b0263b6b7a261d7991a 100755 (executable)
@@ -25,35 +25,28 @@ require 'common.cgi';
 readconfig;
 my $dbh = opendb;
 
-
-print header( -charset => 'utf-8', );
-
-my $bugid = param("id");
-if ( !$bugid ) {
+sub fourohfour()
+{
+    my $id = shift;
+    print header( -charset => 'utf-8', -status => '404 Not Found');
     print start_html(
-        -title => $c{TrackerName} . ": No Bug Number Given",
+        -title => $c{TrackerName} . ": 404 - Not found",
         -style => { 'src' => $c{StyleSheet} }
     );
 
-    print h1("No Bug Number Given");
-    print p( ["Ooops. Bug id paramter missing."] );
+    print h1("404 - Not Found");
+    print p([ "No Bugs Here...", "Cannot find bug at: " .code(htmlsanit(url(-absolute=>1)))]);
     print end_html;
     exit(0);
 }
 
-my $bug = Emesinae::Bug->new( $dbh, ID => $bugid );
-if ( !$bug ) {
-    print start_html(
-        -title => $c{TrackerName} . ": #$bugid - Unknown Bug Number",
-        -style => { 'src' => $c{StyleSheet} }
-    );
+my $bugid = url(-relative=>1);
+fourohfour() unless $bugid =~ m/[0-9]+/;
 
-    print h1("#$bugid - Unknown Bug Number");
-    print p( ["Ooops. This bug doesn't seem to exist."] );
-    print end_html;
-    exit(0);
-}
+my $bug = Emesinae::Bug->new( $dbh, ID => $bugid );
+fourohfour() unless $bug;
 
+print header( -charset => 'utf-8', );
 print start_html(
     -title => $c{TrackerName} . ": #$bugid - " . htmlsanit( $bug->{title} ),
     -style => { 'src' => $c{StyleSheet} }
index 6cd69d6f45f9ca8132baff2eba59ff3c17ac7b75..068fa34c84be75ce369e94be238f17b380c4db1c 100644 (file)
@@ -6,7 +6,7 @@ sub cgipath {
 sub buglink {
     my $b   = shift;
     my $t   = shift or $b->{title};
-    my $url = cgipath( "bug.cgi?id=" . $b->{id} );
+    my $url = cgipath( "bug/" . $b->{id} );
     return a( { href => $url }, $t );
 }
 
@@ -15,7 +15,7 @@ sub msglink {
     my $t    = shift;
     my %attr = @_;
 
-    my $url = cgipath( "message.cgi?id=" . $m->{id} );
+    my $url = cgipath( "message/" . $m->{id} );
     $url .= "&part=" . $attr{part} if $attr{part};
     $url .= "&raw=" . $attr{raw}   if $attr{raw};
 
diff --git a/TODO b/TODO
index fee165bc6785d8ddfcdfc5bc2bf70a56a59083fc..e522e93c011324034c753885e8bebdbb857e7712 100644 (file)
--- a/TODO
+++ b/TODO
@@ -21,7 +21,6 @@ control.pl:
     - how and where to record their actions.
     - bug-dist list is sufficient perhaps?
  - SEO
-    - use path based paramters (e.g. /bugs/1 etc) which is nicer for search engines.
     - make sure there is an index page of all bugs for them to start from
  - Enable Perl taint mode?
 
index 0cfd80f4297287bde16a08958028b0f6560b7cc5..2d1aa88759eb32aa0d3441ae0d9168a8682e2594 100644 (file)
@@ -1,5 +1,6 @@
 # Insert into /etc/apache2/sites-available/bugs.xenproject.org
-       ScriptAlias /test/ /srv/test/lib/emesinae/cgi-bin/
+       ScriptAliasMatch /test/bug/.* /srv/test/lib/emesinae/cgi-bin/bug.cgi
+       ScriptAlias /test/ /srv/test/lib/emesinae/cgi-bin/bugs.cgi
        <Directory "/srv/test/lib/emesinae/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
index 817255b5871c0f3a1831557f778eb70432da2bde..6beab76ffd77e67615858a70ca1c2e4bafe659f8 100644 (file)
@@ -22,7 +22,8 @@
                allow from all
        </Directory>
 
-       ScriptAlias /xen-devel/ /srv/xen-devel-bugs/lib/emesinae/cgi-bin/
+       ScriptAliasMatch /xen/bug/.* /srv/xen-devel-bugs/lib/emesinae/cgi-bin/bug.cgi
+       ScriptAlias /xen/ /srv/xen-devel-bugs/lib/emesinae/cgi-bin/bugs.cgi
        <Directory "/srv/xen-devel-bugs/lib/emesinae/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
index 2acd6165e86f6de8abf3ef4bb5c5d39f03c12131..82bdaad5eeb709f900354114a55b4e0afd7cb74f 100644 (file)
@@ -40,7 +40,7 @@ $c{SpoolDir}        = "/srv/xen-devel-bugs/var/spool/";
 $c{ArchiveIncoming} = 1;
 
 # Path component of the CGI URL
-$c{CGIPath}         = "/xen-devel/";
+$c{CGIPath}         = "/xen/";
 
 $c{LockDir} = "/srv/xen-devel-bugs/var/lock/";
 
index e7b3f6f3581c1dcbd77466f2589346fa99f50754..702ca6f2e55c450d1834409337588ab3d5b403b8 100755 (executable)
@@ -399,7 +399,7 @@ while (<M>) {
 
 sub bugurl ($) {
     my $bn = shift;
-    return "http://" . $c{TrackerHost} . $c{CGIPath} . "bug.cgi?id=$bn";
+    return "http://" . $c{TrackerHost} . $c{CGIPath} . "bug/$bn";
 }
 
 push @reply, ( "", "Modified/created Bugs:" ) if %bugs;