guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Generate multiple paginated packages pages.


From: Ludovic Courtès
Subject: Re: [PATCH] Generate multiple paginated packages pages.
Date: Sat, 12 Nov 2016 15:34:16 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Hello Alex!

Alex Sassmannshausen <address@hidden> 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’s 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 p1)
> -                    (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 p1)
> +                        (package-name p2))))))

I think we should keep ‘all-packages’ instead of inlining it here.

> +                ;; fixme: Ensure these pages work.
> +                (p "You can browse packages indexed by their first letter, 
> or 
> +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 …))))

  (define (group-file-name group)
    (match group
      ("0-9" "0-9.html")
      …))

  …

?

With these changes, that’s OK for me.

I’ll adjust the cron job on hydra.gnu.org to generate all the pages when
it’s committed.

Thank you!

Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]