all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#27049: [PATCH 2/2] gnu: Add js-mathjax.
       [not found] <20170602203308.7606-1-arunisaac@systemreboot.net>
@ 2017-06-02 20:33 ` Arun Isaac
  2017-06-03 13:53   ` Ludovic Courtès
       [not found] ` <20170602203308.7606-2-arunisaac@systemreboot.net>
  1 sibling, 1 reply; 7+ messages in thread
From: Arun Isaac @ 2017-06-02 20:33 UTC (permalink / raw)
  To: 27049

* gnu/packages/javascript.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
* gnu/packages/javascript.scm (js-mathjax): New variable.
---
 gnu/local.mk                |  1 +
 gnu/packages/javascript.scm | 90 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 91 insertions(+)
 create mode 100644 gnu/packages/javascript.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index e7d5ee2f4..efeb57ab9 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -208,6 +208,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/irc.scm  			\
   %D%/packages/iso-codes.scm			\
   %D%/packages/java.scm				\
+  %D%/packages/javascript.scm			\
   %D%/packages/jemalloc.scm			\
   %D%/packages/jrnl.scm				\
   %D%/packages/julia.scm			\
diff --git a/gnu/packages/javascript.scm b/gnu/packages/javascript.scm
new file mode 100644
index 000000000..de8567dc4
--- /dev/null
+++ b/gnu/packages/javascript.scm
@@ -0,0 +1,90 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages javascript)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages compression)
+  #:use-module (gnu packages fonts)
+  #:use-module (gnu packages lisp)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix build-system trivial))
+
+(define-public js-mathjax
+  (package
+    (name "js-mathjax")
+    (version "2.7.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "https://github.com/mathjax/MathJax/archive/"
+             version ".tar.gz"))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32
+         "0sbib5lk0jrvbq6s72ag6ss3wjlz5wnk07ddxij1kp96yg3c1d1b"))))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils)
+                      (ice-9 match)
+                      (ice-9 regex))
+         (setenv "PATH" (string-join (map (match-lambda
+                                            ((_ . input-path)
+                                             (string-append input-path "/bin")))
+                                          %build-inputs)
+                                     ":"))
+         (let ((install-directory (string-append %output "/share/javascript/mathjax")))
+           (system* "tar" "xvf" (assoc-ref %build-inputs "source")
+                    "MathJax-2.7.1/unpacked" "--strip" "2")
+           (mkdir-p install-directory)
+           (symlink (string-append (assoc-ref %build-inputs "font-mathjax")
+                                   "/share/fonts/mathjax")
+                    (string-append install-directory "/fonts"))
+
+           (for-each
+            (lambda (file)
+              (let ((install-path (string-append install-directory
+                                                 ;; remove prefix "."
+                                                 (string-drop file 1))))
+                (format #t "~a -> ~a~%" file install-path)
+                (cond
+                 ((string-match "\\.js$" file)
+                  (mkdir-p (dirname install-path))
+                  (system (format #f "uglify-js ~a > ~a" file install-path)))
+                 (else
+                  (install-file file (dirname install-path))))))
+            (find-files "."))))))
+    (native-inputs
+     `(("font-mathjax" ,font-mathjax)
+       ("gzip" ,gzip)
+       ("tar" ,tar)
+       ("uglify-js" ,uglify-js)))
+    (home-page "https://www.mathjax.org/")
+    (synopsis "JavaScript display engine for LaTeX, MathML, and AsciiMath")
+    (description "MathJax is a JavaScript display engine for LaTeX, MathML,
+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.")
+    (license license:asl2.0)))
-- 
2.12.2

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

* bug#27049: [PATCH 2/2] gnu: Add js-mathjax.
       [not found] ` <20170602203308.7606-2-arunisaac@systemreboot.net>
@ 2017-06-02 20:37   ` Arun Isaac
       [not found]   ` <b6247965.AEAAK4p8Z1kAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZMcyv@mailjet.com>
  1 sibling, 0 replies; 7+ messages in thread
From: Arun Isaac @ 2017-06-02 20:37 UTC (permalink / raw)
  To: 27049


These are WIP patches. Please provide feedback.

> +         (setenv "PATH" (string-join (map (match-lambda
> +                                            ((_ . input-path)
> +                                             (string-append input-path "/bin")))
> +                                          %build-inputs)
> +                                     ":"))

It would be nice if this was handled by the trivial-build-system
itself. Almost all trivial-build-system packages I can think of need
some variant of this.

> +                (cond
> +                 ((string-match "\\.js$" file)
> +                  (mkdir-p (dirname install-path))
> +                  (system (format #f "uglify-js ~a > ~a" file install-path)))

I have to use `system' instead of `system*' here, because I need to make
use of ">" to redirect output to a file.

While minifying some files, an ascii decoding error is reported. I'm yet
to sort that out.

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

* bug#27049: [PATCH 2/2] gnu: Add js-mathjax.
       [not found]   ` <b6247965.AEAAK4p8Z1kAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZMcyv@mailjet.com>
@ 2017-06-03 13:30     ` Ludovic Courtès
  0 siblings, 0 replies; 7+ messages in thread
From: Ludovic Courtès @ 2017-06-03 13:30 UTC (permalink / raw)
  To: Arun Isaac; +Cc: 27049

Hi,

Arun Isaac <arunisaac@systemreboot.net> skribis:

> These are WIP patches. Please provide feedback.
>
>> +         (setenv "PATH" (string-join (map (match-lambda
>> +                                            ((_ . input-path)
>> +                                             (string-append input-path "/bin")))
>> +                                          %build-inputs)
>> +                                     ":"))
>
> It would be nice if this was handled by the trivial-build-system
> itself. Almost all trivial-build-system packages I can think of need
> some variant of this.

You could use ‘set-path-environment-variable’ from (guix build utils) to
slightly simplify this.

>> +                (cond
>> +                 ((string-match "\\.js$" file)
>> +                  (mkdir-p (dirname install-path))
>> +                  (system (format #f "uglify-js ~a > ~a" file install-path)))
>
> I have to use `system' instead of `system*' here, because I need to make
> use of ">" to redirect output to a file.

That’s OK, though you could also use ‘open-input-pipe’ from (ice-9
popen):

  (let ((minified (open-pipe* OPEN_READ "uglify-js" file)))
    (call-with-output-file installed
      (lambda (port)
        (dump-port minified port))))

> While minifying some files, an ascii decoding error is reported. I'm yet
> to sort that out.

You might need to run that in a UTF-8 locale, which requires adding
glibc-utf8-locales as an input etc.

HTH!

Ludo’.

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

* bug#27049: [PATCH 2/2] gnu: Add js-mathjax.
  2017-06-02 20:33 ` bug#27049: [PATCH 2/2] gnu: Add js-mathjax Arun Isaac
@ 2017-06-03 13:53   ` Ludovic Courtès
  2017-06-04 18:57     ` Arun Isaac
       [not found]     ` <5f4eeea0.AEQALLKfIdMAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZNFgw@mailjet.com>
  0 siblings, 2 replies; 7+ messages in thread
From: Ludovic Courtès @ 2017-06-03 13:53 UTC (permalink / raw)
  To: Arun Isaac; +Cc: 27049

Arun Isaac <arunisaac@systemreboot.net> skribis:

> * gnu/packages/javascript.scm: New file.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
> * gnu/packages/javascript.scm (js-mathjax): New variable.

[...]

> +           (for-each
> +            (lambda (file)
> +              (let ((install-path (string-append install-directory
> +                                                 ;; remove prefix "."
> +                                                 (string-drop file 1))))
> +                (format #t "~a -> ~a~%" file install-path)
> +                (cond
> +                 ((string-match "\\.js$" file)
> +                  (mkdir-p (dirname install-path))
> +                  (system (format #f "uglify-js ~a > ~a" file install-path)))
> +                 (else
> +                  (install-file file (dirname install-path))))))
> +            (find-files "."))))))

Nitpick: in GNU “path” is used to denote search paths; we use “file
names” for files.  So s/install-path/installed-file/ or something like
that.

(I already wrote about ‘system’ in another message.)

Otherwise LGTM, thanks!

Ludo’.

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

* bug#27049: [PATCH 2/2] gnu: Add js-mathjax.
  2017-06-03 13:53   ` Ludovic Courtès
@ 2017-06-04 18:57     ` Arun Isaac
       [not found]     ` <5f4eeea0.AEQALLKfIdMAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZNFgw@mailjet.com>
  1 sibling, 0 replies; 7+ messages in thread
From: Arun Isaac @ 2017-06-04 18:57 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 27049

[-- Attachment #1: Type: text/plain, Size: 75 bytes --]


I've made all suggested changes. Please find attached a new patchset.


[-- Attachment #2: mathjax-series.patch --]
[-- Type: text/x-patch, Size: 7460 bytes --]

From 7d843968b04960c93b7238cb4557064d03ef4f84 Mon Sep 17 00:00:00 2001
From: Arun Isaac <arunisaac@systemreboot.net>
Date: Sat, 3 Jun 2017 01:42:15 +0530
Subject: [PATCH 1/2] gnu: Add font-mathjax.

* gnu/packages/fonts.scm (font-mathjax): New variable.
---
 gnu/packages/fonts.scm | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/gnu/packages/fonts.scm b/gnu/packages/fonts.scm
index 73d76a461..59e60dc29 100644
--- a/gnu/packages/fonts.scm
+++ b/gnu/packages/fonts.scm
@@ -19,6 +19,7 @@
 ;;; Copyright © 2017 Alex Griffin <a@ajgrf.com>
 ;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
 ;;; Copyright © 2017 Brendan Tildesley <brendan.tildesley@openmailbox.org>
+;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1227,3 +1228,42 @@ Ensuring readability and clarity at both large and small sizes, these icons
 have been optimized for beautiful display on all common platforms and display
 resolutions.")
    (license license:asl2.0)))
+
+(define-public font-mathjax
+  (package
+    (name "font-mathjax")
+    (version "2.7.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "https://github.com/mathjax/MathJax/archive/"
+             version ".tar.gz"))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32
+         "0sbib5lk0jrvbq6s72ag6ss3wjlz5wnk07ddxij1kp96yg3c1d1b"))))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils)
+                      (ice-9 match))
+         (set-path-environment-variable
+          "PATH" '("bin") (map (match-lambda
+                                 ((_ . input)
+                                  input))
+                               %build-inputs))
+         (let ((install-directory (string-append %output "/share/fonts/mathjax")))
+           (mkdir-p install-directory)
+           (zero? (system* "tar" "-C" install-directory "-xvf"
+                           (assoc-ref %build-inputs "source")
+                           "MathJax-2.7.1/fonts" "--strip" "2"))))))
+    (native-inputs
+     `(("gzip" ,gzip)
+       ("tar" ,tar)))
+    (home-page "https://www.mathjax.org/")
+    (synopsis "Fonts for MathJax")
+    (description "This package contains the fonts required for MathJax.")
+    (license license:asl2.0)))
-- 
2.12.2

From 01850ce06c0a55677266bae865a3c16e4f710094 Mon Sep 17 00:00:00 2001
From: Arun Isaac <arunisaac@systemreboot.net>
Date: Sat, 3 Jun 2017 01:57:51 +0530
Subject: [PATCH 2/2] gnu: Add js-mathjax.

* gnu/packages/javascript.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
* gnu/packages/javascript.scm (js-mathjax): New variable.
---
 gnu/local.mk                |  1 +
 gnu/packages/javascript.scm | 85 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+)
 create mode 100644 gnu/packages/javascript.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 0449e8adc..0ab215971 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -208,6 +208,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/irc.scm  			\
   %D%/packages/iso-codes.scm			\
   %D%/packages/java.scm				\
+  %D%/packages/javascript.scm			\
   %D%/packages/jemalloc.scm			\
   %D%/packages/jrnl.scm				\
   %D%/packages/julia.scm			\
diff --git a/gnu/packages/javascript.scm b/gnu/packages/javascript.scm
new file mode 100644
index 000000000..6746ad1d2
--- /dev/null
+++ b/gnu/packages/javascript.scm
@@ -0,0 +1,85 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages javascript)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages compression)
+  #:use-module (gnu packages fonts)
+  #:use-module (gnu packages lisp)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix build-system trivial))
+
+(define-public js-mathjax
+  (package
+    (inherit font-mathjax)
+    (name "js-mathjax")
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils)
+                      (ice-9 match)
+                      (ice-9 popen)
+                      (ice-9 regex))
+         (set-path-environment-variable
+          "PATH" '("bin") (map (match-lambda
+                                 ((_ . input)
+                                  input))
+                               %build-inputs))
+         (set-path-environment-variable
+          "GUIX_LOCPATH" '("lib/locale")
+          (list (assoc-ref %build-inputs "glibc-utf8-locales")))
+         (setenv "LANG" "en_US.UTF-8")
+         (let ((install-directory (string-append %output "/share/javascript/mathjax")))
+           (system* "tar" "xvf" (assoc-ref %build-inputs "source")
+                    "MathJax-2.7.1/unpacked" "--strip" "2")
+           (mkdir-p install-directory)
+           (symlink (string-append (assoc-ref %build-inputs "font-mathjax")
+                                   "/share/fonts/mathjax")
+                    (string-append install-directory "/fonts"))
+
+           (for-each
+            (lambda (file)
+              (let ((installed (string-append install-directory
+                                              ;; remove prefix "."
+                                              (string-drop file 1))))
+                (format #t "~a -> ~a~%" file installed)
+                (cond
+                 ((string-match "\\.js$" file)
+                  (mkdir-p (dirname installed))
+                  (let ((minified (open-pipe* OPEN_READ "uglify-js" file)))
+                    (call-with-output-file installed
+                      (lambda (port)
+                        (dump-port minified port)))))
+                 (else
+                  (install-file file (dirname installed))))))
+            (find-files "."))))))
+    (native-inputs
+     `(("font-mathjax" ,font-mathjax)
+       ("glibc-utf8-locales" ,glibc-utf8-locales)
+       ("uglify-js" ,uglify-js)
+       ,@(package-native-inputs font-mathjax)))
+    (synopsis "JavaScript display engine for LaTeX, MathML, and AsciiMath")
+    (description "MathJax is a JavaScript display engine for LaTeX, MathML,
+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.")))
-- 
2.12.2


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

* bug#27049: [PATCH 2/2] gnu: Add js-mathjax.
       [not found]     ` <5f4eeea0.AEQALLKfIdMAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZNFgw@mailjet.com>
@ 2017-06-05 10:10       ` Ludovic Courtès
  2017-06-05 13:48         ` Arun Isaac
  0 siblings, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2017-06-05 10:10 UTC (permalink / raw)
  To: Arun Isaac; +Cc: 27049

Arun Isaac <arunisaac@systemreboot.net> skribis:

> I've made all suggested changes. Please find attached a new patchset.
>
> From 7d843968b04960c93b7238cb4557064d03ef4f84 Mon Sep 17 00:00:00 2001
> From: Arun Isaac <arunisaac@systemreboot.net>
> Date: Sat, 3 Jun 2017 01:42:15 +0530
> Subject: [PATCH 1/2] gnu: Add font-mathjax.
>
> * gnu/packages/fonts.scm (font-mathjax): New variable.

[...]

> From 01850ce06c0a55677266bae865a3c16e4f710094 Mon Sep 17 00:00:00 2001
> From: Arun Isaac <arunisaac@systemreboot.net>
> Date: Sat, 3 Jun 2017 01:57:51 +0530
> Subject: [PATCH 2/2] gnu: Add js-mathjax.
>
> * gnu/packages/javascript.scm: New file.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
> * gnu/packages/javascript.scm (js-mathjax): New variable.

Both LGTM, thank you!

Ludo’.

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

* bug#27049: [PATCH 2/2] gnu: Add js-mathjax.
  2017-06-05 10:10       ` Ludovic Courtès
@ 2017-06-05 13:48         ` Arun Isaac
  0 siblings, 0 replies; 7+ messages in thread
From: Arun Isaac @ 2017-06-05 13:48 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 27049-done


Pushed!

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

end of thread, other threads:[~2017-06-05 13:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20170602203308.7606-1-arunisaac@systemreboot.net>
2017-06-02 20:33 ` bug#27049: [PATCH 2/2] gnu: Add js-mathjax Arun Isaac
2017-06-03 13:53   ` Ludovic Courtès
2017-06-04 18:57     ` Arun Isaac
     [not found]     ` <5f4eeea0.AEQALLKfIdMAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZNFgw@mailjet.com>
2017-06-05 10:10       ` Ludovic Courtès
2017-06-05 13:48         ` Arun Isaac
     [not found] ` <20170602203308.7606-2-arunisaac@systemreboot.net>
2017-06-02 20:37   ` Arun Isaac
     [not found]   ` <b6247965.AEAAK4p8Z1kAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZMcyv@mailjet.com>
2017-06-03 13:30     ` Ludovic Courtès

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.