Pretty URLs for individual commits.
authorChuck Hagenbuch <chuck@horde.org>
Mon, 1 Nov 2010 20:41:39 +0000 (16:41 -0400)
committerChuck Hagenbuch <chuck@horde.org>
Mon, 1 Nov 2010 20:41:39 +0000 (16:41 -0400)
chora/.htaccess
chora/lib/Chora.php

index e13edfd..7e738d7 100644 (file)
@@ -6,4 +6,6 @@ Allow from all
     RewriteCond   %{REQUEST_FILENAME} !-f
     RewriteRule   ^browse/(.*)$ browsedir.php?f=$1 [QSA]
     RewriteRule   ^([a-z-\/]+)/-/browse/(.*)$ browsedir.php?f=$2&rt=$1 [QSA]
+    RewriteRule   ^commits/(.*)$ patchsets.php?ps=$1 [QSA]
+    RewriteRule   ^([a-z-\/]+)/-/commits/(.*)$ patchsets.php?ps=$2&rt=$1 [QSA]
 </IfModule>
index 392d54b..018ed55 100644 (file)
@@ -114,7 +114,9 @@ class Chora
         $script .= '.php';
 
         if ($GLOBALS['conf']['options']['urls'] == 'rewrite') {
-            if (in_array($script, array('browsefile.php', 'browsedir.php'))) {
+            switch ($script) {
+            case 'browsefile.php':
+            case 'browsedir.php':
                 if (substr($uri, 0, 1) == '/') {
                     $script = "browse$uri";
                 } else {
@@ -122,7 +124,16 @@ class Chora
                 }
                 $script = urlencode(isset($args['rt']) ? $args['rt'] : $GLOBALS['acts']['rt']) . "/-/$script";
                 unset($arglist['rt']);
-            } else {
+                break;
+
+            case 'patchsets.php':
+                if (!empty($args['ps'])) {
+                    $script = urlencode(isset($args['rt']) ? $args['rt'] : $GLOBALS['acts']['rt']) . '/-/commits/' . $args['ps'];
+                    unset($arglist['ps']);
+                }
+                break;
+
+            default:
                 $script .= '/' . $uri;
             }
         } elseif (!empty($uri)) {
@@ -130,7 +141,6 @@ class Chora
         }
 
         return Horde::url($script)->add($arglist)->setAnchor($anchor);
-
     }
 
     /**
@@ -466,5 +476,4 @@ class Chora
             ? $log
             : preg_replace($GLOBALS['conf']['tickets']['regexp'], $GLOBALS['conf']['tickets']['replacement'], $log);
     }
-
 }