Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 33310 invoked from network); 2 Mar 2010 19:16:38 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Mar 2010 19:16:38 -0000 Received: (qmail 46939 invoked by uid 500); 2 Mar 2010 19:16:32 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 46907 invoked by uid 500); 2 Mar 2010 19:16:32 -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 46899 invoked by uid 99); 2 Mar 2010 19:16:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Mar 2010 19:16:32 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jchris@gmail.com designates 209.85.220.209 as permitted sender) Received: from [209.85.220.209] (HELO mail-fx0-f209.google.com) (209.85.220.209) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Mar 2010 19:16:24 +0000 Received: by fxm1 with SMTP id 1so665448fxm.35 for ; Tue, 02 Mar 2010 11:16:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:content-type:mime-version :subject:from:in-reply-to:date:content-transfer-encoding:message-id :references:to:x-mailer; bh=8QuJmmnkGhIavv7YZ4o/OULTRqj9w9BszwPbfx2nGKc=; b=HvJ/uWSVJwlu1cLT77/ur5GzIXE1KpQpMbwIaKSPrhMCixf8GbhjQDlj2bVSv2kDQG vd379TFJ3Yhkssz246P6A84D/f/U75JZ/yU9qqPLaO06RE8gqSMIQVYNTAqpIbV+qyT+ 5VKc8RdcPlCRUm6OdtlpIGdYpWN8u8zupxfNA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; b=Pk+GXQxfkbetP7zD26Rd/Zeq4Pc+deeyTTqVLJf8o9bHhepFh42gFpWIW3/ScsRALs SjQLarxAcM/UF5roQOfhshzZMj/trtnKXkER145N1MrQGOWSF7WY3bPFuJzaD6jGjBHN WYEf0IlOnI9K1Y2tJhvQYjok6FFTdxYtH5dYg= Received: by 10.223.77.136 with SMTP id g8mr7133488fak.10.1267557362806; Tue, 02 Mar 2010 11:16:02 -0800 (PST) Received: from ?192.168.1.104? (c-98-248-172-14.hsd1.ca.comcast.net [98.248.172.14]) by mx.google.com with ESMTPS id 18sm7721253fks.5.2010.03.02.11.16.00 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 02 Mar 2010 11:16:01 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1077) Subject: Re: Implementing next and previous links From: J Chris Anderson In-Reply-To: Date: Tue, 2 Mar 2010 11:15:57 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: <3A7E9A0D-0535-4B36-831E-6AB88A526F2A@gmail.com> References: <21a5a18d1003021103m466b3363p9c549e25792f72af@mail.gmail.com> To: user@couchdb.apache.org X-Mailer: Apple Mail (2.1077) On Mar 2, 2010, at 11:11 AM, Saq Imtiaz wrote: > Hi Sean! What a small world. Funny running in to you here! What are = you > using couchdb for? >=20 > Yes the goal is for the application to be self-contained within = couchdb so > that replication for instance, copies the application logic and the = data. > I've had a very nice conversation with jchris on #couchdb and he's > essentially confirmed my feeling that if I want prettier links than = using > ?startkey type urls, I'll need to rewrite them clientside after = performing > additional queries. Yes and no. Start out by writing your application with ugly links. Then look at the = _rewrite handler you can add to design docs. This is not well documented = yet (there is JS tests for it). It should be able to make your URLs = pretty. Cheers, Chris >=20 > If anyone else has different ideas on how to do this within the = described > constraints I'd be happy to hear them. > Cheers, > Saq >=20 > On Tue, Mar 2, 2010 at 20:03, Sean Clark Hess = wrote: >=20 >> Hey Saq! It's been a while. How have you been? >>=20 >> Is an application layer out of the question? >>=20 >> On Tue, Mar 2, 2010 at 11:16 AM, Saq Imtiaz wrote: >>=20 >>> Hi guys. I'm getting to know couchdb with an aim to writing a = "blog-like" >>> application where you display one post at a time. Posts have a >>> chronological >>> order and each post has "next post" and "previous post" links. >>>=20 >>> I was hoping to get some input on the best way to implement these = links. >>> I've done a fair bit of reading on the wiki and mailing list = archives >>> (especially discussions around paging). I'm looking to create a = couchapp >>> where I can render the essential information as HTML in couchdb and = only >>> make additional requests from the clientside for comments. An = additional >> a >>> consideration is that I'd like to be able to use the url rewriting = in >>> couchdb 0.11 to have "meaningful" links to each post, e.g.: = /date/title >>> (where title=3Ddocid) >>>=20 >>> What I've done so far is to give each "post" document an id which >>> corresponds to its title and a numerical "date_created" attribute. I = have >> a >>> view function that emits ([doc.date_created,doc._id],doc) >>>=20 >>> Then I load a specific page using = myview?key=3D["201003021333","docid"] >>> I suppose I can use the total_rows and offset to predict whether or = not >>> there should be next and previous links but I'm not sure if there = are any >>> hidden caveats here? >>>=20 >>> For the next link I can use: >>> myview?startkey=3D["201002261927010000"]&limit=3D1&skip=3D1 >>> For the previous link: >>> myview?startkey=3D["201002261927010000"]&limit=3D1&descending=3Dtrue >>>=20 >>> Alternatively I could load the first page using >>> myview?startkey=3D["201002261927010000"]&limit=3D2 and use the = "next" >> document >>> retrieved to create the link to the next page. >>>=20 >>> However, this leaves me with a link to the previous page that is >> impossible >>> to rewrite to a /date/title type of format. Is there any way to work >> around >>> this or is this a limitation that has to be lived with? >>>=20 >>> My last resort would be to create "ugly" links using startkey query >>> arguments serverside and then use clientside code to fetch the = necessary >>> information to change the links to have "prettier" href values. This = way >>> the >>> static html served by couchdb has working navigation and the UI >>> improvements >>> are happening clientside. >>>=20 >>> Is there anyway at all to respond to a request for a specific = document >> (by >>> doc._id) or other attribute with the document in question but also = the >>> previous and next document? >>>=20 >>> Many thanks, >>> Saq >>>=20 >>=20