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.