1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
3 ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
4 ;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
6 ;;; This file is part of GNU Guix.
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21 (define-module (gnu packages javascript)
22 #:use-module ((guix licenses) #:prefix license:)
23 #:use-module (gnu packages)
24 #:use-module (gnu packages base)
25 #:use-module (gnu packages compression)
26 #:use-module (gnu packages lisp)
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix git-download)
30 #:use-module (guix build-system trivial)
31 #:use-module (guix build-system minify))
33 (define-public font-mathjax
41 "https://github.com/mathjax/MathJax/archive/"
43 (file-name (string-append name "-" version ".tar.gz"))
46 "1r72di4pg4i6pfhcskkxqmf1158m81ki6a7lbw6nz4zh7xw23hy4"))))
47 (build-system trivial-build-system)
49 `(#:modules ((guix build utils))
52 (use-modules (guix build utils)
54 (set-path-environment-variable
55 "PATH" '("bin") (map (match-lambda
59 (let ((install-directory (string-append %output "/share/fonts/mathjax")))
60 (mkdir-p install-directory)
61 (zero? (system* "tar" "-C" install-directory "-xvf"
62 (assoc-ref %build-inputs "source")
63 ,(string-append "MathJax-" version "/fonts")
68 (home-page "https://www.mathjax.org/")
69 (synopsis "Fonts for MathJax")
70 (description "This package contains the fonts required for MathJax.")
71 (license license:asl2.0)))
73 (define-public js-mathjax
75 (inherit font-mathjax)
78 `(#:modules ((guix build utils))
81 (use-modules (guix build utils)
85 (set-path-environment-variable
86 "PATH" '("bin") (map (match-lambda
90 (set-path-environment-variable
91 "GUIX_LOCPATH" '("lib/locale")
92 (list (assoc-ref %build-inputs "glibc-utf8-locales")))
93 (setenv "LANG" "en_US.UTF-8")
94 (let ((install-directory (string-append %output "/share/javascript/mathjax")))
95 (system* "tar" "xvf" (assoc-ref %build-inputs "source")
96 ,(string-append "MathJax-" (package-version font-mathjax)
99 (mkdir-p install-directory)
100 (symlink (string-append (assoc-ref %build-inputs "font-mathjax")
101 "/share/fonts/mathjax")
102 (string-append install-directory "/fonts"))
106 (let ((installed (string-append install-directory
108 (string-drop file 1))))
109 (format #t "~a -> ~a~%" file installed)
111 ((string-match "\\.js$" file)
112 (mkdir-p (dirname installed))
113 (let ((minified (open-pipe* OPEN_READ "uglify-js" file)))
114 (call-with-output-file installed
116 (dump-port minified port)))))
118 (install-file file (dirname installed))))))
119 (find-files "."))))))
121 `(("font-mathjax" ,font-mathjax)
122 ("glibc-utf8-locales" ,glibc-utf8-locales)
123 ("uglify-js" ,uglify-js)
124 ,@(package-native-inputs font-mathjax)))
125 (synopsis "JavaScript display engine for LaTeX, MathML, and AsciiMath")
126 (description "MathJax is a JavaScript display engine for LaTeX, MathML,
127 and AsciiMath notation that works in all modern browsers. It requires no
128 plugins or software to be installed on the browser. So the page author can
129 write web documents that include mathematics and be confident that readers will
130 be able to view it naturally and easily.")))
132 (define-public js-respond
138 (uri (string-append "https://github.com/scottjehl/Respond/"
139 "archive/" version ".tar.gz"))
140 (file-name (string-append name "-" version ".tar.gz"))
143 "0ds1ya2a185jp93mdn07159c2x8zczwi960ykrawpp62bwk2n93d"))))
144 (build-system trivial-build-system)
146 `(#:modules ((guix build utils))
149 (use-modules (guix build utils)
153 (set-path-environment-variable
154 "PATH" '("bin") (map (match-lambda
158 (let ((install-directory (string-append %output
159 "/share/javascript/respond/")))
161 (assoc-ref %build-inputs "source")
163 (mkdir-p install-directory)
164 (let* ((file "src/respond.js")
165 (installed (string-append install-directory "respond.min.js")))
166 (let ((minified (open-pipe* OPEN_READ "uglify-js" file)))
167 (call-with-output-file installed
168 (cut dump-port minified <>)))))
170 (home-page "https://github.com/scottjehl/Respond")
172 `(("uglify-js" ,uglify-js)
176 (synopsis "Polyfill for min/max-width CSS3 Media Queries")
177 (description "The goal of this script is to provide a fast and lightweight
178 script to enable responsive web designs in browsers that don't support CSS3
180 (license license:expat)))
182 (define-public js-html5shiv
184 (name "js-html5shiv")
188 (uri (string-append "https://github.com/aFarkas/html5shiv/"
189 "archive/" version ".tar.gz"))
190 (file-name (string-append name "-" version ".tar.gz"))
193 "0inlbpxpqzdyi24lqagzf7l24zxg0y02xcpqs2h4npjscazzw7hg"))))
194 (build-system minify-build-system)
195 (home-page "https://github.com/aFarkas/html5shiv")
196 (synopsis "Enable HTML5 sectioning elements in legacy browsers")
197 (description "The HTML5 Shiv enables use of HTML5 sectioning elements in
198 legacy Internet Explorer and provides basic HTML5 styling for Internet
199 Explorer 6-9, Safari 4.x (and iPhone 3.x), and Firefox 3.x.")
200 ;; From the file "MIT and GPL2 licenses.md":
202 ;; This software is licensed under a dual license system (MIT or GPL
203 ;; version 2). This means you are free to choose with which of both
204 ;; licenses (MIT or GPL version 2) you want to use this library.
205 (license (list license:expat license:gpl2))))
207 (define-public js-json2
208 (let ((commit "031b1d9e6971bd4c433ca85e216cc853f5a867bd")
212 (version (string-append "2016-10-28." revision "-" (string-take commit 7)))
216 (url "https://github.com/douglascrockford/JSON-js.git")
218 (file-name (string-append name "-" version "-checkout"))
221 "1fvb6b2y5sd3sqdgcj683sdxcbxdii34q0ysc9wg0dq1sy81l11v"))))
222 (build-system minify-build-system)
224 `(#:javascript-files '("json2.js"
226 "json_parse_state.js"
228 (home-page "https://github.com/douglascrockford/JSON-js")
229 (synopsis "JSON encoders and decoders")
230 (description "The files in this collection implement JSON
231 encoders/decoders in JavaScript.
233 @code{json2.js}: This file creates a JSON property in the global object, if
234 there isn't already one, setting its value to an object containing a stringify
235 method and a parse method. The @code{parse} method uses the @code{eval}
236 method to do the parsing, guarding it with several regular expressions to
237 defend against accidental code execution hazards. On current browsers, this
238 file does nothing, preferring the built-in JSON object.
240 @code{json_parse.js}: This file contains an alternative JSON @code{parse}
241 function that uses recursive descent instead of @code{eval}.
243 @code{json_parse_state.js}: This files contains an alternative JSON
244 @code{parse} function that uses a state machine instead of @code{eval}.
246 @code{cycle.js}: This file contains two functions, @code{JSON.decycle} and
247 @code{JSON.retrocycle}, which make it possible to encode cyclical structures
248 and DAGs in JSON, and to then recover them. This is a capability that is not
249 provided by ES5. @code{JSONPath} is used to represent the links.")
250 (license license:public-domain))))
252 (define-public js-strftime
258 (uri (string-append "https://github.com/samsonjs/strftime/"
259 "archive/v" version ".tar.gz"))
260 (file-name (string-append name "-" version ".tar.gz"))
263 "1iya43w7y26y2dp9l4d40bhjc4scb5a9mng5ng5c8hsqr82f1375"))))
264 (build-system minify-build-system)
266 `(#:javascript-files '("strftime.js")))
267 (home-page "https://github.com/samsonjs/strftime")
268 (synopsis "Implementation of strftime to JavaScript")
269 (description "This is an implementation of the @code{strftime} procedure
270 for JavaScript. It works in (at least) node.js and browsers. It supports
271 localization and timezones. Most standard specifiers from C are supported as
272 well as some other extensions from Ruby.")
273 (license license:expat)))
275 (define-public js-highlight
277 (name "js-highlight")
281 (uri (string-append "https://github.com/isagalaev/highlight.js/"
282 "archive/" version ".tar.gz"))
283 (file-name (string-append name "-" version ".tar.gz"))
286 "1jjn9mj7fwq4zpr6is438bscf03b3q8jkj0k5c3fc6pkmjnhw939"))))
287 (build-system minify-build-system)
289 `(#:javascript-files '("src/highlight.js")))
290 (home-page "https://github.com/isagalaev/highlight.js")
291 (synopsis "Syntax highlighting for JavaScript")
292 (description "Highlight.js is a syntax highlighter written in JavaScript.
293 It works in the browser as well as on the server. It works with pretty much
294 any markup, doesn’t depend on any framework and has automatic language
296 (license license:bsd-3)))
298 (define-public js-datatables
300 (name "js-datatables")
304 (uri (string-append "https://datatables.net/releases/DataTables-"
308 "1y9xqyqyz7x1ls3ska71pshl2hpiy3qnw1f7wygyslbhy4ssgf57"))))
309 (build-system minify-build-system)
311 `(#:javascript-files '("media/js/dataTables.bootstrap.js"
312 "media/js/jquery.dataTables.js")))
315 (home-page "https://datatables.net")
316 (synopsis "DataTables plug-in for jQuery")
317 (description "DataTables is a table enhancing plug-in for the jQuery
318 Javascript library, adding sorting, paging and filtering abilities to plain
319 HTML tables with minimal effort.")
320 (license license:expat)))
322 (define-public js-selectize
324 (name "js-selectize")
328 (uri (string-append "https://github.com/selectize/selectize.js/"
329 "archive/v" version ".tar.gz"))
330 (file-name (string-append name "-" version ".tar.gz"))
333 "0756p49aaz34mw2dx8k1gxf210mngfrri25vkba0j7wihd2af8gn"))))
334 (build-system minify-build-system)
335 (arguments `(#:javascript-files '("src/selectize.js")))
336 (home-page "http://selectize.github.io/selectize.js/")
337 (synopsis "Hybrid widget between a textbox and <select> box")
338 (description "Selectize is the hybrid of a textbox and @code{<select>}
339 box. It's jQuery based and it has autocomplete and native-feeling keyboard
340 navigation; it is useful for tagging, contact lists, etc.")
341 (license license:asl2.0)))
343 (define-public js-es5-shim
349 (uri (string-append "https://github.com/es-shims/es5-shim/"
350 "archive/v" version ".tar.gz"))
351 (file-name (string-append name "-" version ".tar.gz"))
354 "0yfndyijz0ykddzprpvfjb2453gzpn528klmwycwbqc1bqd3m1hl"))))
355 (build-system minify-build-system)
356 (arguments `(#:javascript-files
359 (home-page "https://github.com/es-shims/es5-shim")
360 (synopsis "ECMAScript 5 compatibility shims for legacy JavaScript engines")
361 (description "@code{es5-shim.js} patches a JavaScript context to contain
362 all ECMAScript 5 methods that can be faithfully emulated with a legacy
363 JavaScript engine. @code{es5-sham.js} patches other ES5 methods as closely as
364 possible. Many of these shams are intended only to allow code to be written
365 to ES5 without causing run-time errors in older engines. In many cases, this
366 means that these shams cause many ES5 methods to silently fail.")
367 (license license:expat)))