[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/29: website: packages: Implement grouping by letter.
From: |
Ludovic Courtès |
Subject: |
05/29: website: packages: Implement grouping by letter. |
Date: |
Wed, 6 Dec 2017 09:24:22 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix-artwork.
commit ccc5964a475e6e5b089a29698a6d782998c5239c
Author: Ludovic Courtès <address@hidden>
Date: Sat Jul 29 17:28:10 2017 +0200
website: packages: Implement grouping by letter.
* website/apps/packages/utils.scm (packages/group-by-letter): Implement.
---
website/apps/packages/utils.scm | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/website/apps/packages/utils.scm b/website/apps/packages/utils.scm
index 1a15084..4e435be 100644
--- a/website/apps/packages/utils.scm
+++ b/website/apps/packages/utils.scm
@@ -9,6 +9,7 @@
#:use-module (apps packages types)
#:use-module (guix packages)
#:use-module (guix utils)
+ #:use-module (ice-9 match)
#:export (location->ilink
package-build-issues
package-issues?
@@ -100,8 +101,6 @@
(package-version package))))
-;;; TODO: Dummy. Implement it.
-;;; (https://bitbucket.org/sirgazil/guixsd-website/issues/38/)
(define (packages/group-by-letter packages)
"Return a list of alphabetically grouped packages.
@@ -111,6 +110,20 @@
RETURN (list)
A list of lists of packages where each list corresponds to the
packages whose name starts with a specific letter."
- (cond ((null? packages) '())
- (else
- (map (lambda (letter) (cons letter packages)) alphabet))))
+ (define (starts-with-digit? package)
+ (char-set-contains? char-set:digit
+ (string-ref (package-name package) 0)))
+
+ (define (starts-with-letter? letter)
+ (let ((letter (string-downcase letter)))
+ (lambda (package)
+ (string-prefix? letter (package-name package)))))
+
+ (map (lambda (letter)
+ (match letter
+ ("0-9"
+ (cons letter (filter starts-with-digit? packages)))
+ (_
+ (cons letter
+ (filter (starts-with-letter? letter) packages)))))
+ alphabet))
- branch master updated (ae2d020 -> 81db25f), Ludovic Courtès, 2017/12/06
- 02/29: website: packages: Ignore third-party packages., Ludovic Courtès, 2017/12/06
- 04/29: website: utils: 'paginate' correctly handles the case with zero items., Ludovic Courtès, 2017/12/06
- 03/29: website: posts: Add missing tags and harmonize., Ludovic Courtès, 2017/12/06
- 05/29: website: packages: Implement grouping by letter.,
Ludovic Courtès <=
- 11/29: website: "download", not "test"., Ludovic Courtès, 2017/12/06
- 08/29: website: packages: Fix typo., Ludovic Courtès, 2017/12/06
- 07/29: website: packages: Add the commit in package source URLs., Ludovic Courtès, 2017/12/06
- 12/29: website: packages: Mark GNU packages in the listing., Ludovic Courtès, 2017/12/06
- 15/29: website: downloads: Change http to https in alpha.gnu.org URL., Ludovic Courtès, 2017/12/06
- 13/29: website: packages: Correctly compute supported systems., Ludovic Courtès, 2017/12/06
- 10/29: website: Use actual GuixSD screenshots., Ludovic Courtès, 2017/12/06
- 17/29: website: base: Change http to https in 'graphics'., Ludovic Courtès, 2017/12/06
- 19/29: website: base: Change URLs in 'data' from http to https., Ludovic Courtès, 2017/12/06
- 06/29: website: packages: Interpret synopsis/description Texinfo., Ludovic Courtès, 2017/12/06