From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:37720) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j424i-0007YY-0R for guix-patches@gnu.org; Tue, 18 Feb 2020 07:34:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j424g-0004Xu-TG for guix-patches@gnu.org; Tue, 18 Feb 2020 07:34:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:33650) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j424g-0004Xh-PT for guix-patches@gnu.org; Tue, 18 Feb 2020 07:34:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j424g-0006Tr-NZ for guix-patches@gnu.org; Tue, 18 Feb 2020 07:34:02 -0500 Subject: [bug#39547] [PATCH v2 2/2] website: Provide JSON sources list used by Software Heritage. Resent-Message-ID: From: zimoun Date: Tue, 18 Feb 2020 13:32:46 +0100 Message-Id: <20200218123246.32473-2-zimon.toutoune@gmail.com> In-Reply-To: <20200218123246.32473-1-zimon.toutoune@gmail.com> References: <20200218123246.32473-1-zimon.toutoune@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 39547@debbugs.gnu.org Cc: zimoun Format discussed here . * website/apps/packages/builder.scm (origin->json): Add list modifier. * website/apps/packages/builder.scm (sources-json-builder): New procedure. --- website/apps/packages/builder.scm | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/website/apps/packages/builder.scm b/website/apps/packages/builder.scm index d3a777e..49721f6 100644 --- a/website/apps/packages/builder.scm +++ b/website/apps/packages/builder.scm @@ -74,6 +74,7 @@ (flatten (list (index-builder) + (sources-json-builder) (packages-json-builder) (packages-builder) (package-list-builder)))) @@ -88,7 +89,7 @@ ;; Maximum number of packages shown on /packages. 30) -(define (origin->json origin) +(define (origin->json origin transformer) (define method (origin-method origin)) @@ -105,7 +106,7 @@ ((eq? svn-fetch method) 'svn) (else #nil))) ,@(cond ((eq? url-fetch method) - `(("url" . ,(list->vector + `(("url" . ,(transformer (resolve (match uri ((? string? url) (list url)) @@ -136,7 +137,7 @@ ,@(if cpe-name `(("cpe_name" . ,cpe-name)) '()) ,@(if cpe-version `(("cpe_version" . ,cpe-version)) '()) ,@(if (origin? (package-source package)) - `(("source" . ,(origin->json (package-source package)))) + `(("source" . ,(origin->json (package-source package) list->vector))) '()) ("synopsis" . ,(package-synopsis package)) ,@(if (package-home-page package) @@ -155,6 +156,21 @@ (list->vector (map package->json (all-packages))) scm->json)) +(define (sources-json-builder) + "Return a JSON page listing all the sources. + +See ." + (define (package->json package) + `(,@(if (origin? (package-source package)) + (origin->json (package-source package) car) + `(("type" . "no-origin") + ("name" . ,(package-name package)))))) + + (make-page "sources.json" + `(("sources" . ,(list->vector (map package->json (all-packages)))) + ("version" . "1")) + scm->json)) + (define (index-builder) "Return a Haunt page listing some random packages." (define (sample n from) -- 2.25.0