[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
22/29: website: packages: /packages shows at most 30 packages.
From: |
Ludovic Courtès |
Subject: |
22/29: website: packages: /packages shows at most 30 packages. |
Date: |
Wed, 6 Dec 2017 09:24:27 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix-artwork.
commit 94e9756e61cd564ae365f9525f95da906c38db13
Author: Ludovic Courtès <address@hidden>
Date: Wed Dec 6 14:03:52 2017 +0100
website: packages: /packages shows at most 30 packages.
* website/apps/packages/templates/detailed-index.scm (detailed-index-t):
Add optional 'total' parameter and honor it.
* website/apps/packages/builder.scm (%max-packages-on-index): New variable.
(index-builder): Use 'take-at-most' to limit the number of packages shown.
(detailed-index-builder): Likewise, and pass the total to
'detailed-index-t'.
* website/apps/packages/utils.scm (take-at-most): New procedure.
---
website/apps/packages/builder.scm | 39 ++++++++++++++++++----
website/apps/packages/templates/detailed-index.scm | 7 ++--
website/apps/packages/utils.scm | 17 +++++++++-
3 files changed, 53 insertions(+), 10 deletions(-)
diff --git a/website/apps/packages/builder.scm
b/website/apps/packages/builder.scm
index 2382c5b..ba0592e 100644
--- a/website/apps/packages/builder.scm
+++ b/website/apps/packages/builder.scm
@@ -1,6 +1,23 @@
;;; GuixSD website --- GNU's advanced distro website
-;;; Initially written by sirgazil who waives all
-;;; copyright interest on this file.
+;;; Copyright © 2017 Ludovic Courtès <address@hidden>
+;;;
+;;; Initially written by sirgazil
+;;; who waives all copyright interest on this file.
+;;;
+;;; This file is part of GuixSD website.
+;;;
+;;; GuixSD website is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU Affero General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GuixSD website is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU Affero General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU Affero General Public License
+;;; along with GuixSD website. If not, see <http://www.gnu.org/licenses/>.
(define-module (apps packages builder)
#:use-module (apps aux lists)
@@ -66,18 +83,28 @@
;;; Helper builders.
;;;
+(define %max-packages-on-index
+ ;; Maximum number of packages shown on /packages.
+ 30)
+
(define (index-builder)
"Return a Haunt page listing some random packages."
- ;; TODO: Pass ~30 random Guix packages.
- (let ((context (list (cons "packages" (all-packages)))))
+ ;; TODO: Pick random packages.
+ (let ((context (list (cons "packages"
+ (take-at-most (all-packages)
+ %max-packages-on-index)))))
(make-page "packages/index.html" (index-t context) sxml->html)))
(define (detailed-index-builder)
"Return a Haunt page listing some random packages."
;; TODO: Pass ~30 random Guix packages.
- (let ((context (list (cons "packages" (all-packages)))))
- (make-page "packages/index.html" (detailed-index-t context) sxml->html)))
+ (let ((context (list (cons "packages"
+ (take-at-most (all-packages)
+ %max-packages-on-index)))))
+ (make-page "packages/index.html"
+ (detailed-index-t context (length (all-packages)))
+ sxml->html)))
(define (detailed-package-list-builder)
diff --git a/website/apps/packages/templates/detailed-index.scm
b/website/apps/packages/templates/detailed-index.scm
index 7dc6d7c..e785164 100644
--- a/website/apps/packages/templates/detailed-index.scm
+++ b/website/apps/packages/templates/detailed-index.scm
@@ -13,8 +13,9 @@
#:export (detailed-index-t))
-(define (detailed-index-t context)
- "Return SHTML index page for the package app."
+(define* (detailed-index-t context #:optional total)
+ "Return SHTML index page for the package app. TOTAL is the total number of
+packages to advertise."
(let ((packages (context-datum context "packages")))
(theme
#:title (list "Packages")
@@ -43,7 +44,7 @@
(p
(@ (class "limit-width centered-block"))
- "GNU Guix provides " ,(number* (length packages))
+ "GNU Guix provides " ,(number* (or total (length packages)))
" packages transparently "
(a (@ (href "https://hydra.gnu.org/jobset/gnu/master#tabs-status"))
"available as pre-built binaries")
diff --git a/website/apps/packages/utils.scm b/website/apps/packages/utils.scm
index 8944269..a5fe83c 100644
--- a/website/apps/packages/utils.scm
+++ b/website/apps/packages/utils.scm
@@ -38,7 +38,9 @@
#:use-module (ice-9 rdelim)
#:use-module (ice-9 popen)
#:use-module (web uri)
- #:export (package-description-shtml
+ #:export (take-at-most
+
+ package-description-shtml
package-synopsis-shtml
location->ilink
@@ -54,6 +56,19 @@
;;; Helper procedures.
;;;
+(define (take-at-most lst max)
+ "Take up to MAX elements from LST."
+ (let loop ((lst lst)
+ (result '())
+ (total 0))
+ (match lst
+ (()
+ (reverse result))
+ ((head . tail)
+ (if (>= total max)
+ (reverse result)
+ (loop tail (cons head result) (+ 1 total)))))))
+
(define (texinfo->shtml texi)
"Parse TEXI, a string, and return the corresponding SHTML."
;; 'texi-fragment->stexi' uses 'call-with-input-string', so make sure
- 18/29: website: base: Change some http to https., (continued)
- 18/29: website: base: Change some http to https., Ludovic Courtès, 2017/12/06
- 23/29: website: Hard-code file:// URL root when GUIX_WEB_SITE_LOCAL., Ludovic Courtès, 2017/12/06
- 20/29: website: Change http to https in URLs., Ludovic Courtès, 2017/12/06
- 25/29: website: packages: 'all-packages' memoizes its result., Ludovic Courtès, 2017/12/06
- 28/29: website: Insert surrounding spaces when flattening markup., Ludovic Courtès, 2017/12/06
- 29/29: website: Add pseudo-post about GPCE., Ludovic Courtès, 2017/12/06
- 14/29: website: packages: Add a newline between packages., Ludovic Courtès, 2017/12/06
- 09/29: website: packages: Implement patch links., Ludovic Courtès, 2017/12/06
- 16/29: website: base: Change http to https in some URLs on 'contribute'., Ludovic Courtès, 2017/12/06
- 27/29: website: contact: Tweak., Ludovic Courtès, 2017/12/06
- 22/29: website: packages: /packages shows at most 30 packages.,
Ludovic Courtès <=
- 26/29: website: Unify and rationalize tags for blog posts., Ludovic Courtès, 2017/12/06