>From d7aaff23102a5ecfe1f6a579b13360385b8f004b Mon Sep 17 00:00:00 2001 From: Alex Sassmannshausen
Date: Tue, 20 Aug 2013 01:38:30 +0200 Subject: [PATCH] list-packages: Externalise CSS file. * build-aux/list-packages.scm (%load-directory): New variable. (%css-file): New variable. (%js-file): New variable. (insert-css): Read CSS from external file, and return object for sxml->xml. (insert-js): Read JS from external file, and return object for sxml->xml. * build-aux/package-list.css: New CSS file. * build-aux/package-list.js: New JS file. --- build-aux/list-packages.scm | 156 +++++++------------------------------------ build-aux/package-list.css | 74 ++++++++++++++++++++ build-aux/package-list.js | 43 ++++++++++++ 3 files changed, 142 insertions(+), 131 deletions(-) create mode 100644 build-aux/package-list.css create mode 100644 build-aux/package-list.js diff --git a/build-aux/list-packages.scm b/build-aux/list-packages.scm index 6303066..6ad66d4 100755 --- a/build-aux/list-packages.scm +++ b/build-aux/list-packages.scm @@ -27,11 +27,13 @@ exec guile -l "$0" \ #:use-module (guix packages) #:use-module (guix licenses) #:use-module (guix gnu-maintenance) + #:use-module (guix build utils) #:use-module (gnu packages) #:use-module (sxml simple) #:use-module (web uri) #:use-module (ice-9 match) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) #:export (list-packages)) ;;; Commentary: @@ -185,134 +187,25 @@ prep_pkg_descs even when the number of IDs is smaller than GROUP-COUNTER." "^"))) +(define %load-directory + (string-append (dirname (current-filename)))) + +(define %css-file + "/package-list.css") +(define %js-file + "/package-list.js") + (define (insert-css) - "Return the CSS for the list-packages page." - (format #t -"")) + "Return inlined CSS, sourced from %css-file." + `(style (@ (type "text/css")) + ,(with-input-from-file (string-append %load-directory %css-file) + (cute dump-port <> (current-output-port))))) (define (insert-js) - "Return the JavaScript for the list-packages page." - (format #t -"")) + "Return inlined JS, sourced from %js-file." + `(style (@ (type "text/javascript")) + ,(with-input-from-file (string-append %load-directory %js-file) + (cute dump-port <> (current-output-port))))) (define (list-packages . args) @@ -328,16 +221,17 @@ with gnu.org server-side include and all that." (let ((packages (sort (fold-packages cons '()) (lambda (p1 p2) (string (package-name p1) (package-name p2)))))) - (format #t " + (format #t "