Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 63788419E for ; Tue, 21 Jun 2011 14:19:23 +0000 (UTC) Received: (qmail 92846 invoked by uid 500); 21 Jun 2011 14:19:21 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 92811 invoked by uid 500); 21 Jun 2011 14:19:21 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 92803 invoked by uid 99); 21 Jun 2011 14:19:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Jun 2011 14:19:21 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of gsf747@gmail.com designates 209.85.161.180 as permitted sender) Received: from [209.85.161.180] (HELO mail-gx0-f180.google.com) (209.85.161.180) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Jun 2011 14:19:14 +0000 Received: by gxk10 with SMTP id 10so3581922gxk.11 for ; Tue, 21 Jun 2011 07:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to :content-type; bh=9uOWB+FKxYhBZTI1QuMUEopyTWLwbGTUpIZ3seHNduQ=; b=CXlXkbCfjF7AtCT0D9SnT48FqwYIPBsPAYwSZ5ko63F4gN+4WL3cjolSVmA3TMrrvZ 4hpJx7jx/9ApD8O/3ufx1WNJ1pW52WwuqqxaEOti7So+ThFvKUxBaCcLQmBb5/4T3qb0 EHwSDyMvMtJwWAU83gEBArKU2I15Q3NISoJpk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=QUK2W+GL2zfbDQ2V+sjQ+iZavxBOu6zqgyta9diQsNXAxfXCPQrteYoRC+JRvUIJqm sQW8zx99WVfSa+1A/pNAn9OW07vixuWeFmnDjG01lcCxwNTLoaed5oWiLQjOqXEQyk14 yuzgZy/o5CtNsLr3bIC4/8erS43HYgDLzlRq4= Received: by 10.236.156.133 with SMTP id m5mr6993399yhk.456.1308665933061; Tue, 21 Jun 2011 07:18:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.43.229 with HTTP; Tue, 21 Jun 2011 07:18:33 -0700 (PDT) From: Gabriel Farrell Date: Tue, 21 Jun 2011 10:18:33 -0400 Message-ID: Subject: rewrite rules for alphabetic browse To: user@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org I'm putting together a site where I have artists and works of art. I would like to browse those artists and works alphabetically, with URLs like http://example.com/artists/a and http://example.com/works/b. I have a view called type_name: function(doc) { if (doc.type && doc.name) { emit([doc.type, doc.name]); } } My "artists" list renders the results from that view in a template. I can get the first page of artists with a rewrite like this: { "from": "artists/a", "to": "_list/artists/type_name", "query": { "startkey": ["artist", "a"], "endkey": ["artist", "aZZZZZ"] } }, How would I generalize this for all letters of the alphabet? I want to do something like the following, but the last ":startkey" isn't substituted: { "from": "artists/:startkey", "to": "_list/artists/type_name", "query": { "startkey": ["artist", ":startkey"], "endkey": ["artist", ":startkeyZZZZZ"] } }, I can achieve something close by extending the URL to http://example.com/artists/a/aZZZZZ and using the following rewrite: { "from": "artists/:startkey/:endkey", "to": "_list/artists/type_name", "query": { "startkey": ["artist", ":startkey"], "endkey": ["artist", ":endkey"] } }, The URL is uglier but it works. Is there any way to make the shorter URL work? Frankly, I think some of my trouble is that, coming from other web frameworks, I'm not used to my URLs being constrained in this way. I want to be able to grab the request path, munge it all over with JavaScript, then send it on to my lists, shows, views, etc.