unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#27449] [PATCH] gnu: Add js-respond.
@ 2017-06-22 15:19 Ricardo Wurmus
  2017-06-22 16:13 ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Ricardo Wurmus @ 2017-06-22 15:19 UTC (permalink / raw)
  To: 27449; +Cc: Ricardo Wurmus

* gnu/packages/javascript.scm (js-respond): New variable.
---
 gnu/packages/javascript.scm | 51 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/gnu/packages/javascript.scm b/gnu/packages/javascript.scm
index 6746ad1d2..43bc0bbf6 100644
--- a/gnu/packages/javascript.scm
+++ b/gnu/packages/javascript.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -83,3 +84,53 @@ and AsciiMath notation that works in all modern browsers.  It requires no
 plugins or software to be installed on the browser.  So the page author can
 write web documents that include mathematics and be confident that readers will
 be able to view it naturally and easily.")))
+
+(define-public js-respond
+  (package
+    (name "js-respond")
+    (version "1.4.2")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://github.com/scottjehl/Respond/"
+                                  "archive/" version ".tar.gz"))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "0ds1ya2a185jp93mdn07159c2x8zczwi960ykrawpp62bwk2n93d"))))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils)
+                      (ice-9 match)
+                      (ice-9 popen)
+                      (srfi srfi-26))
+         (set-path-environment-variable
+          "PATH" '("bin") (map (match-lambda
+                                 ((_ . input)
+                                  input))
+                               %build-inputs))
+         (let ((install-directory (string-append %output
+                                                 "/share/javascript/respond/")))
+           (system* "tar" "xvf"
+                    (assoc-ref %build-inputs "source")
+                    "--strip" "1")
+           (mkdir-p install-directory)
+           (let* ((file "src/respond.js")
+                  (installed (string-append install-directory "respond.min.js")))
+             (let ((minified (open-pipe* OPEN_READ "uglify-js" file)))
+               (call-with-output-file installed
+                 (cut dump-port minified <>)))))
+         #t)))
+    (home-page "https://github.com/scottjehl/Respond")
+    (native-inputs
+     `(("uglify-js" ,uglify-js)
+       ("source" ,source)
+       ("gzip" ,gzip)
+       ("tar" ,tar)))
+    (synopsis "Polyfill for min/max-width CSS3 Media Queries")
+    (description "The goal of this script is to provide a fast and lightweight
+script to enable responsive web designs in browsers that don't support CSS3
+Media Queries.")
+    (license license:expat)))
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [bug#27449] [PATCH] gnu: Add js-respond.
  2017-06-22 15:19 [bug#27449] [PATCH] gnu: Add js-respond Ricardo Wurmus
@ 2017-06-22 16:13 ` Ludovic Courtès
  2017-06-23  6:20   ` bug#27449: " Ricardo Wurmus
  0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2017-06-22 16:13 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: 27449

Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> skribis:

> * gnu/packages/javascript.scm (js-respond): New variable.

LGTM.

> +    (build-system trivial-build-system)
> +    (arguments
> +     `(#:modules ((guix build utils))
> +       #:builder
> +       (begin
> +         (use-modules (guix build utils)
> +                      (ice-9 match)
> +                      (ice-9 popen)
> +                      (srfi srfi-26))
> +         (set-path-environment-variable
> +          "PATH" '("bin") (map (match-lambda
> +                                 ((_ . input)
> +                                  input))
> +                               %build-inputs))
> +         (let ((install-directory (string-append %output
> +                                                 "/share/javascript/respond/")))
> +           (system* "tar" "xvf"
> +                    (assoc-ref %build-inputs "source")
> +                    "--strip" "1")
> +           (mkdir-p install-directory)
> +           (let* ((file "src/respond.js")
> +                  (installed (string-append install-directory "respond.min.js")))
> +             (let ((minified (open-pipe* OPEN_READ "uglify-js" file)))
> +               (call-with-output-file installed
> +                 (cut dump-port minified <>)))))
> +         #t)))

Should we turn this into a ‘javascript-build-system’?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#27449: [PATCH] gnu: Add js-respond.
  2017-06-22 16:13 ` Ludovic Courtès
@ 2017-06-23  6:20   ` Ricardo Wurmus
  2017-06-23  9:33     ` [bug#27449] " Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Ricardo Wurmus @ 2017-06-23  6:20 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 27449-done


Ludovic Courtès <ludo@gnu.org> writes:

> Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> skribis:
>
>> * gnu/packages/javascript.scm (js-respond): New variable.
>
> LGTM.

Thanks.  Pushed to master with b37b48f81.

>> +    (build-system trivial-build-system)
>> +    (arguments
>> +     `(#:modules ((guix build utils))
>> +       #:builder
>> +       (begin
>> +         (use-modules (guix build utils)
>> +                      (ice-9 match)
>> +                      (ice-9 popen)
>> +                      (srfi srfi-26))
>> +         (set-path-environment-variable
>> +          "PATH" '("bin") (map (match-lambda
>> +                                 ((_ . input)
>> +                                  input))
>> +                               %build-inputs))
>> +         (let ((install-directory (string-append %output
>> +                                                 "/share/javascript/respond/")))
>> +           (system* "tar" "xvf"
>> +                    (assoc-ref %build-inputs "source")
>> +                    "--strip" "1")
>> +           (mkdir-p install-directory)
>> +           (let* ((file "src/respond.js")
>> +                  (installed (string-append install-directory "respond.min.js")))
>> +             (let ((minified (open-pipe* OPEN_READ "uglify-js" file)))
>> +               (call-with-output-file installed
>> +                 (cut dump-port minified <>)))))
>> +         #t)))
>
> Should we turn this into a ‘javascript-build-system’?

This is a simplified version of what js-mathjax does, so that seems like
a good template for minifying JavaScript files.  I’m just not sure how
to generalise this, because projects don’t always put all their
unminified .js files in a single directory and we can’t just minify all
.js files, because

  a) they might already be minified,
  b) they might require compilation / concatenation.

Maybe we should wait until we have some more experience with how other
JS projects handle this.  I’m going to package a few more JS things for
r-shiny; if a pattern should pop up I’m going to poor it into a build
system.

-- Ricardo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [bug#27449] [PATCH] gnu: Add js-respond.
  2017-06-23  6:20   ` bug#27449: " Ricardo Wurmus
@ 2017-06-23  9:33     ` Ludovic Courtès
  0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2017-06-23  9:33 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: 27449-done

Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> skribis:

> This is a simplified version of what js-mathjax does, so that seems like
> a good template for minifying JavaScript files.  I’m just not sure how
> to generalise this, because projects don’t always put all their
> unminified .js files in a single directory and we can’t just minify all
> .js files, because
>
>   a) they might already be minified,
>   b) they might require compilation / concatenation.
>
> Maybe we should wait until we have some more experience with how other
> JS projects handle this.  I’m going to package a few more JS things for
> r-shiny; if a pattern should pop up I’m going to poor it into a build
> system.

If we can’t come up with a full build system, perhaps a (guix build
javascript) module could at least provide a ‘minify’ procedure that
invokes uglify, or something like that?

Ludo’.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-06-23  9:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-22 15:19 [bug#27449] [PATCH] gnu: Add js-respond Ricardo Wurmus
2017-06-22 16:13 ` Ludovic Courtès
2017-06-23  6:20   ` bug#27449: " Ricardo Wurmus
2017-06-23  9:33     ` [bug#27449] " Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).