Make static links use query redirects

Rather than redirect to an old URL, and then display the same thing as
a query, just redirect to the query screen.  While we are at it,
define /r/* to be any valid query, which opens up a lot of potential
for linking to different parts of Gerrit.

Change-Id: I93a43e5bfe2e7c3b766e8ba9a05cc1901a285920
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/UrlModule.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/UrlModule.java
index ce350a3..ba8f7b6 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/UrlModule.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/UrlModule.java
@@ -23,7 +23,6 @@
 import com.google.gerrit.httpd.raw.SshInfoServlet;
 import com.google.gerrit.httpd.raw.StaticServlet;
 import com.google.gerrit.httpd.raw.ToolServlet;
-import com.google.gerrit.reviewdb.RevId;
 import com.google.gwtexpui.server.CacheControlFilter;
 import com.google.inject.Key;
 import com.google.inject.Provider;
@@ -60,16 +59,16 @@
     serve("/com/google/gerrit/launcher/*").with(notFound());
     serve("/servlet/*").with(notFound());
 
-    serve("/all").with(screen(PageLinks.ALL_MERGED));
+    serve("/all").with(query("status:merged"));
     serve("/mine").with(screen(PageLinks.MINE));
-    serve("/open").with(screen(PageLinks.ALL_OPEN));
+    serve("/open").with(query("status:open"));
     serve("/settings").with(screen(PageLinks.SETTINGS));
-    serve("/watched").with(screen(PageLinks.MINE_WATCHED));
-    serve("/starred").with(screen(PageLinks.MINE_STARRED));
+    serve("/watched").with(query("is:watched status:open"));
+    serve("/starred").with(query("is:starred"));
 
     serveRegex( //
         "^/([1-9][0-9]*)/?$", //
-        "^/r/(I?[0-9a-fA-F]{4," + RevId.LEN + "})/?$" //
+        "^/r/(.+)/?$" //
     ).with(changeQuery());
   }
 
@@ -122,6 +121,18 @@
     });
   }
 
+  private Key<HttpServlet> query(final String query) {
+    return key(new HttpServlet() {
+      private static final long serialVersionUID = 1L;
+
+      @Override
+      protected void doGet(final HttpServletRequest req,
+          final HttpServletResponse rsp) throws IOException {
+        toGerrit(PageLinks.toChangeQuery(query), req, rsp);
+      }
+    });
+  }
+
   private Key<HttpServlet> key(final HttpServlet servlet) {
     final Key<HttpServlet> srv =
         Key.get(HttpServlet.class, UniqueAnnotations.create());