From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH] Generate multiple paginated packages pages. Date: Sat, 12 Nov 2016 15:34:16 +0100 Message-ID: <87twbcn4wn.fsf@gnu.org> References: <20161111200339.7062-1-alex@pompo.co> <20161111200339.7062-2-alex@pompo.co> 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]:39050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c5ZNz-0002Fu-NZ for guix-devel@gnu.org; Sat, 12 Nov 2016 09:34:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c5ZNy-0000zv-Ss for guix-devel@gnu.org; Sat, 12 Nov 2016 09:34:27 -0500 In-Reply-To: <20161111200339.7062-2-alex@pompo.co> (Alex Sassmannshausen's message of "Fri, 11 Nov 2016 21:03:39 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." 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" To: Alex Sassmannshausen Cc: guix-devel@gnu.org, Alex Sassmannshausen Hello Alex! Alex Sassmannshausen skribis: > * website/www.scm (%web-pages): Add prototype code for generating our > packages pages. > * website/www/packages.scm (all-packages): Re-factor to > `packages-by-grouping`. > (paginated-packages-page): New procedure. > (packages-page): Tweak for use by `paginated-packages-page` as well as > standalone. > (issues-page): Use `packages-by-grouping`. Neat! I had in mind something that would involve JS code in the browser and would allow people to make generic searches. However, what you suggest has the advantage of not requiring JS at all and it=E2=80=99s convenient as well, so I guess we should go for it. :-) > diff --git a/website/www.scm b/website/www.scm > index 459629f..489260e 100644 > --- a/website/www.scm > +++ b/website/www.scm > @@ -293,7 +293,17 @@ Distribution.") > ("download/index.html" ,download-page) > ("help/index.html" ,help-page) > ("security/index.html" ,security-page) > - ;; ("packages/index.html" ,packages-page) ; Need Guix > + ;; Paged packages pages! Need Guix > + ;; Not 100% if this how the website is supposed to work. Would > + ;; appreciate comment on this. > + ;; ,@(map (lambda (grouping) > + ;; `(,(string-append "packages/" grouping ".html") > + ;; (paginated-packages-page ,grouping))) > + ;; (cons "0-9" (map string '(#\a #\b #\c #\d #\e #\f #\g #\h > + ;; #\i #\j #\k #\l #\m #\n #\o #\p > + ;; #\q #\r #\s #\t #\u #\v #\w #\x > + ;; #\y #\z)))) Yes this should work. > -(define (all-packages) > - "Return the list of all package objects, sorted by name." > - (sort (fold-packages (lambda (package lst) > - (cons (or (package-replacement package) > - package) > - lst)) > - '()) > - (lambda (p1 p2) > - (string - (package-name p2))))) > - > -(define (packages-page) > +(define packages-by-grouping > + (let ((packages (sort (fold-packages (lambda (package lst) > + (cons (or (package-replacement package) > + package) > + lst)) > + '()) > + (lambda (p1 p2) > + (string + (package-name p2)))))) I think we should keep =E2=80=98all-packages=E2=80=99 instead of inlining i= t here. > + ;; fixme: Ensure these pages work. > + (p "You can browse packages indexed by their first lette= r, or=20 > +you can view " > + (a (@ (href "/software/guix/packages/all")) > + "all packages on a single page.")) What about generating a list of links instead, like: (map (lambda (group) `(a (@ (href ,(group-file-name group))) ,(group-name group))) %groups) where: (define %groups ;; List of package groups. (cons "0-9" (map string '(#\a =E2=80=A6)))) (define (group-file-name group) (match group ("0-9" "0-9.html") =E2=80=A6)) =E2=80=A6 ? With these changes, that=E2=80=99s OK for me. I=E2=80=99ll adjust the cron job on hydra.gnu.org to generate all the pages= when it=E2=80=99s committed. Thank you! Ludo=E2=80=99.