[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
09/29: website: packages: Implement patch links.
From: |
Ludovic Courtès |
Subject: |
09/29: website: packages: Implement patch links. |
Date: |
Wed, 6 Dec 2017 09:24:23 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix-artwork.
commit 676ea57868b02e6896a4ae92385116a4002844a9
Author: Ludovic Courtès <address@hidden>
Date: Sat Jul 29 18:31:41 2017 +0200
website: packages: Implement patch links.
* website/apps/packages/utils.scm (package-patches): Implement, using
code from former web site.
---
website/apps/packages/utils.scm | 53 ++++++++++++++++++++++++++++++++++++++---
1 file changed, 50 insertions(+), 3 deletions(-)
diff --git a/website/apps/packages/utils.scm b/website/apps/packages/utils.scm
index 0d4304e..a6a4674 100644
--- a/website/apps/packages/utils.scm
+++ b/website/apps/packages/utils.scm
@@ -28,6 +28,8 @@
#:use-module (guix packages)
#:use-module (guix utils)
#:use-module (guix build utils)
+ #:use-module (guix build download)
+ #:use-module (guix download)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (texinfo)
@@ -35,6 +37,7 @@
#:use-module (ice-9 match)
#:use-module (ice-9 rdelim)
#:use-module (ice-9 popen)
+ #:use-module (web uri)
#:export (package-description-shtml
package-synopsis-shtml
@@ -140,8 +143,6 @@ vocabulary."
(list))
-;;; TODO: Stub. Implement.
-;;; https://bitbucket.org/sirgazil/guixsd-website/issues/42/
(define (package-patches package)
"Return the list of patches for the given PACKAGE.
@@ -151,7 +152,53 @@ vocabulary."
RETURN (list)
A list of <link> objects as defined in (apps packages types)
representing patches."
- (list))
+ (define patch-url
+ (match-lambda
+ ((? string? patch)
+ (string-append
+ "//git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/patches/"
+ (basename patch)))
+ ((? origin? patch)
+ (uri->string
+ (first (maybe-expand-mirrors (string->uri
+ (match (origin-uri patch)
+ ((? string? uri) uri)
+ ((head . tail) head)))
+ %mirrors))))))
+
+ (define patch-name
+ (match-lambda
+ ((? string? patch)
+ (basename patch))
+ ((? origin? patch)
+ (match (origin-uri patch)
+ ((? string? uri) (basename uri))
+ ((head . tail) (basename head))))))
+
+ (define (snippet-link)
+ (let* ((loc (or (package-field-location package 'source)
+ (package-location package)))
+ (link (location->ilink loc)))
+ (ilink "snippet" (ilink-url link))))
+
+ (define patches
+ (map (lambda (patch)
+ (ilink `(tt ,(patch-name patch)) (patch-url patch)))
+ (match (package-source package)
+ (#f '())
+ ((? origin? o) (origin-patches o)))))
+
+ (define snippet
+ (match (package-source package)
+ (#f
+ #f)
+ ((? origin? o)
+ (and (origin-snippet o)
+ (snippet-link)))))
+
+ (if snippet
+ (cons snippet patches)
+ patches))
(define (package-url-path package)
- 06/29: website: packages: Interpret synopsis/description Texinfo., (continued)
- 06/29: website: packages: Interpret synopsis/description Texinfo., Ludovic Courtès, 2017/12/06
- 21/29: website: packages: Gracefully deal with empty package descriptions., Ludovic Courtès, 2017/12/06
- 24/29: website: packages: Remove links to package issues., Ludovic Courtès, 2017/12/06
- 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 <=
- 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, 2017/12/06
- 26/29: website: Unify and rationalize tags for blog posts., Ludovic Courtès, 2017/12/06