From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Sassmannshausen Subject: Re: Patches: Trivial (add div), Progressive Enhancement, Externalise CSS/JS Date: Tue, 20 Aug 2013 01:55:30 +0200 Message-ID: <878uzxkzgt.fsf@honeybear.home> References: <87r4dqsjqy.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VBYMY-0002Id-95 for guix-devel@gnu.org; Mon, 19 Aug 2013 18:55:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VBYMS-0007WN-Pu for guix-devel@gnu.org; Mon, 19 Aug 2013 18:55:50 -0400 In-Reply-To: <87r4dqsjqy.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Mon, 19 Aug 2013 00:43:17 +0200") List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel@gnu.org --=-=-= Content-Type: text/plain Hello, Working on the second patch series, I still run into the problem with (cute) or (dump-port). >> The alternative, inlining the CSS and JS in the resulting HTML, >> which is I think what was proposed, has been implemented as >> suggested, but I'm running into an error Ludovic> Can you send the backtrace that you get, and/or the error Ludovic> message? Please find attached the error I get during compilation, and the patch to get the code to the state where I'm at (to be applied after the previous 3 patches I sent tonight). Any help appreciated. Best wishes, Alex --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-list-packages-Externalise-CSS-file.patch >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 + (format #t " GNU Guix - GNU Distribution - GNU Project ") - (insert-css) - (insert-js) - (format #t "") + ;; Inline CSS and JS into the header of the HTML document. + (sxml->xml (insert-css)) + (sxml->xml (insert-js)) + (format #t "") - (sxml->xml (packages->sxml packages)) - (format #t " + (sxml->xml (packages->sxml packages)) + (format #t "
diff --git a/build-aux/package-list.css b/build-aux/package-list.css new file mode 100644 index 0000000..6596aa6 --- /dev/null +++ b/build-aux/package-list.css @@ -0,0 +1,74 @@ +/* license: CC0 */ +a { + transition: all 0.3s; +} +div#intro { + margin-bottom: 2em; +} +div#intro div, div#intro p { + padding:0.5em; +} +div#intro div { + float:left; +} +div#intro img { + float:left; + padding:0.75em; +} +table#packages, table#packages tr, table#packages tbody, table#packages td, table#packages th { + border: 0px solid black; + clear: both; +} +table#packages tr:nth-child(even) { + background-color: #FFF; +} +table#packages tr:nth-child(odd) { + background-color: #EEE; +} +table#packages tr:hover, table#packages tr:focus, table#packages tr:active { + background-color: #DDD; +} +table#packages tr:first-child, table#packages tr:first-child:hover, table#packages tr:first-child:focus, table#packages tr:first-child:active { + background-color: #333; + color: #fff; +} +table#packages td { + margin:0px; + padding:0.2em 0.5em; +} +table#packages td:first-child { + width:10%; + text-align:center; +} +table#packages td:nth-child(2) { + width:30%; +} +table#packages td:last-child { + width:60%; +} +img.package-logo { + float: left; + padding: 0.75em; +} +table#packages span { + font-weight: 700; +} +table#packages span a { + float: right; + font-weight: 500; +} +a#top { + position:fixed; + right:10px; + bottom:10px; + font-size:150%; + background-color:#EEE; + padding:10px 7.5px 0 7.5px; + text-decoration:none; + color:#000; + border-radius:5px; +} +a#top:hover, a#top:focus { + background-color:#333; + color:#fff; +} diff --git a/build-aux/package-list.js b/build-aux/package-list.js new file mode 100644 index 0000000..8b2971a --- /dev/null +++ b/build-aux/package-list.js @@ -0,0 +1,43 @@ +// license: CC0 +function show_hide(idThing) +{ + if(document.getElementById && document.createTextNode) { + var thing = document.getElementById(idThing); + /* Used to change the link text, depending on whether description is + collapsed or expanded */ + var thingLink = thing.previousSibling.lastChild.firstChild; + if (thing) { + if (thing.style.display == "none") { + thing.style.display = ""; + thingLink.data = 'Collapse'; + } else { + thing.style.display = "none"; + thingLink.data = 'Expand'; + } + } + } +} +/* Add controllers used for collapse/expansion of package descriptions */ +function prep(idThing) +{ + var tdThing = document.getElementById(idThing).parentNode; + if (tdThing) { + var aThing = tdThing.firstChild.appendChild(document.createElement('a')); + aThing.setAttribute('href', 'javascript:void(0)'); + aThing.setAttribute('title', 'show/hide package description'); + aThing.appendChild(document.createTextNode('Expand')); + aThing.onclick=function(){show_hide(idThing);}; + /* aThing.onkeypress=function(){show_hide(idThing);}; */ + } +} +/* Take n element IDs, prepare them for javascript enhanced +display and hide the IDs by default. */ +function bulk_show_hide() +{ + if(document.getElementById && document.createTextNode) { + for(var i=0; i ...] In unknown file: ?: 10 [apply-smob/1 #] In ice-9/boot-9.scm: 63: 9 [call-with-prompt prompt0 ...] In ice-9/eval.scm: 432: 8 [eval # #] In unknown file: ?: 7 [call-with-input-string "(apply (@ (list-packages) list-packages)\n (cdr (command-line)))" ...] In ice-9/command-line.scm: 180: 6 [# #] In unknown file: ?: 5 [eval (apply (@ # list-packages) (cdr #)) #] In build-aux/list-packages.scm: 229: 4 [list-packages] 201: 3 [insert-css] In ice-9/boot-9.scm: 793: 2 [call-with-input-file "/home/alex/projects/guix/build-aux/package-list.css" ...] In ice-9/r4rs.scm: 172: 1 [with-input-from-port #> ...] In build-aux/list-packages.scm: 202: 0 [#] build-aux/list-packages.scm:202:8: In procedure #: build-aux/list-packages.scm:202:8: Wrong number of arguments to # --=-=-=--