From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Patches: Progressive Enhancement Date: Wed, 28 Aug 2013 14:34:26 +0200 Message-ID: <87ppsydmel.fsf@gnu.org> References: <87r4dqsjqy.fsf@gnu.org> <87vc2silld.fsf_-_@honeybear.home> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53309) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEexg-00018m-8P for guix-devel@gnu.org; Wed, 28 Aug 2013 08:35:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VEexZ-0000lI-MJ for guix-devel@gnu.org; Wed, 28 Aug 2013 08:35:00 -0400 Received: from hera.aquilenet.fr ([141.255.128.1]:50827) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEexZ-0000lA-Bp for guix-devel@gnu.org; Wed, 28 Aug 2013 08:34:53 -0400 In-Reply-To: <87vc2silld.fsf_-_@honeybear.home> (Alex Sassmannshausen's message of "Mon, 26 Aug 2013 16:16:14 +0200") List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Alex Sassmannshausen Cc: guix-devel@gnu.org Hi Alex, Alex Sassmannshausen skribis: > The first patch tidies the CSS in (insert-css). > > The second patch uses fold-values from (sxml fold) to achieve what my > previous patch did without the use of set! (essentially change the page > so that it does not assume JavaScript to display all content elegantly). > > Output is visible at www.atheia.org/guix/list-packages.html again, and > it validates correctly. Looks great! > From 361b7aa0eff3681a8b0a47b7139fb7e84d7c8f71 Mon Sep 17 00:00:00 2001 > From: Alex Sassmannshausen > Date: Mon, 26 Aug 2013 15:53:38 +0200 > Subject: [PATCH 1/2] list-packages: Tidy CSS in preparation for split into > external file. > > * build-aux/list-packages.scm (insert-css): Tidy CSS alignment etc. Applied. > From ed5771c1d5a18c31634ef075d6fe1eee70b32d6b Mon Sep 17 00:00:00 2001 > From: Alex Sassmannshausen > Date: Mon, 26 Aug 2013 15:55:28 +0200 > Subject: [PATCH 2/2] list-packages: Progressive Enhancement approach to J= S. > > * build-aux/list-packages.scm (package->sxml): Modify formal params, > docstring. Introduce logic for fold-values process. Instead of =E2=80=9CModify...=E2=80=9D, please write =E2=80=9CAdd parameter= s foo and bar.=E2=80=9D. > --- a/build-aux/list-packages.scm > +++ b/build-aux/list-packages.scm > @@ -29,6 +29,7 @@ exec guile -l "$0" \ > #:use-module (guix gnu-maintenance) > #:use-module (gnu packages) > #:use-module (sxml simple) > + #:use-module (sxml fold) > #:use-module (web uri) > #:use-module (ice-9 match) > #:use-module (srfi srfi-1) > @@ -48,8 +49,10 @@ exec guile -l "$0" \ > (equal? (gnu-package-name package) name)) > gnu)))) >=20=20 > -(define (package->sxml package) > - "Return HTML-as-SXML representing PACKAGE." > +(define (package->sxml package previous lid l) > + "Return built HTML-as-SXML representing PACKAGEs, collected in > +PREVIOUS. Include a call to the JavaScript prep_pkg_descs function, ever= y time > +the length of LID (increasing) is 15 or when L (decreasing) is 1." It should be =E2=80=9CReturn 3 values: the HTML-as-SXML for PACKAGE, etc.= =E2=80=9D Also, PREVIOUS is a list of previously processed packages right? That should be mentioned in the docstring. A more descriptive name for =E2=80=98lid=E2=80=99 would be =E2=80=98descrip= tion-ids=E2=80=99, and its type should be mentioned in the docstring. =E2=80=98l=E2=80=99 could be renamed to =E2=80=98remaining=E2=80=99, since = it=E2=80=99s a count of remaining packages, IIUC. > + (define (insert-tr description-id js?) > + (define (insert-js-call lid) > + "Return an sxml call to prep_pkg_descs, with up to 15 elements of = lid as > +formal parameters." > + (define (lid->js-argl) > + "Parse a Scheme list into a JavaScript style arguments list." > + (define (helper l) > + (if (null? l) > + "" ; No more args, done with= list. > + (string-append ", '" (car l) "'" ; Append a further arg. > + (helper (cdr l))))) > + > + (string-append "'" (car lid) "'" ; Initial arg. > + (helper (cdr lid)))) This looks nicer with (ice-9 match) pattern matching and =E2=80=98string-jo= in=E2=80=99: (define (list->js-argl) (match lid (() ; empty list (is it possible?) "") ((lid ...) (string-append "'" (string-join lid "', '") "'")))) > + (cond ((=3D l 1) ; Last package in pac= kages > + (reverse ; Fold has reversed pac= kages > + (cons (insert-tr description-id 'js) ; Only return sxml > + previous))) This code path returns a single value, whereas the others return 3. In general it=E2=80=99s better for procedures to always return the same number= of values, to avoid confusion. > + ,@(fold-values package->sxml packages '() '() (length package= s))) Great that you converted it to functional style. :-) So I think these comments are mostly cosmetic, and then we should be done with this patch. Thanks, Ludo=E2=80=99.