unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Alex Sassmannshausen <alex.sassmannshausen@gmail.com>
Cc: guix-devel@gnu.org, Alex Sassmannshausen <alex@pompo.co>
Subject: Re: [PATCH] Generate multiple paginated packages pages.
Date: Sat, 12 Nov 2016 15:34:16 +0100	[thread overview]
Message-ID: <87twbcn4wn.fsf@gnu.org> (raw)
In-Reply-To: <20161111200339.7062-2-alex@pompo.co> (Alex Sassmannshausen's message of "Fri, 11 Nov 2016 21:03:39 +0100")

Hello Alex!

Alex Sassmannshausen <alex.sassmannshausen@gmail.com> 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	other threads:[~2016-11-12 14:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-11 20:03 [PATCH] A patch to generate paginated packages page Alex Sassmannshausen
2016-11-11 20:03 ` [PATCH] Generate multiple paginated packages pages Alex Sassmannshausen
2016-11-12 14:34   ` Ludovic Courtès [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-11-29 23:22 [PATCH] Revised generate multiple package pages Alex Sassmannshausen
2016-11-29 23:22 ` [PATCH] Generate multiple paginated packages pages Alex Sassmannshausen
2016-12-04 20:51   ` Ludovic Courtès
2016-12-05 10:16     ` Alex Sassmannshausen
2016-12-08 10:00       ` Ludovic Courtès
2016-12-08 10:54         ` Jan Synáček
2016-12-08 11:29         ` Alex Sassmannshausen
2016-12-08 11:36           ` John Darrington
2016-12-08 12:02             ` Alex Sassmannshausen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87twbcn4wn.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=alex.sassmannshausen@gmail.com \
    --cc=alex@pompo.co \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).