gnu: python-unidecode: Fix typo in description.
[jackhill/guix/guix.git] / gnu / packages / javascript.scm
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>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
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.
12 ;;;
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.
17 ;;;
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/>.
20
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))
32
33 (define-public font-mathjax
34 (package
35 (name "font-mathjax")
36 (version "2.7.2")
37 (source
38 (origin
39 (method url-fetch)
40 (uri (string-append
41 "https://github.com/mathjax/MathJax/archive/"
42 version ".tar.gz"))
43 (file-name (string-append name "-" version ".tar.gz"))
44 (sha256
45 (base32
46 "1r72di4pg4i6pfhcskkxqmf1158m81ki6a7lbw6nz4zh7xw23hy4"))))
47 (build-system trivial-build-system)
48 (arguments
49 `(#:modules ((guix build utils))
50 #:builder
51 (begin
52 (use-modules (guix build utils)
53 (ice-9 match))
54 (set-path-environment-variable
55 "PATH" '("bin") (map (match-lambda
56 ((_ . input)
57 input))
58 %build-inputs))
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")
64 "--strip" "2"))))))
65 (native-inputs
66 `(("gzip" ,gzip)
67 ("tar" ,tar)))
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)))
72
73 (define-public js-mathjax
74 (package
75 (inherit font-mathjax)
76 (name "js-mathjax")
77 (arguments
78 `(#:modules ((guix build utils))
79 #:builder
80 (begin
81 (use-modules (guix build utils)
82 (ice-9 match)
83 (ice-9 popen)
84 (ice-9 regex))
85 (set-path-environment-variable
86 "PATH" '("bin") (map (match-lambda
87 ((_ . input)
88 input))
89 %build-inputs))
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)
97 "/unpacked")
98 "--strip" "2")
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"))
103
104 (for-each
105 (lambda (file)
106 (let ((installed (string-append install-directory
107 ;; remove prefix "."
108 (string-drop file 1))))
109 (format #t "~a -> ~a~%" file installed)
110 (cond
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
115 (lambda (port)
116 (dump-port minified port)))))
117 (else
118 (install-file file (dirname installed))))))
119 (find-files "."))))))
120 (native-inputs
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.")))
131
132 (define-public js-respond
133 (package
134 (name "js-respond")
135 (version "1.4.2")
136 (source (origin
137 (method url-fetch)
138 (uri (string-append "https://github.com/scottjehl/Respond/"
139 "archive/" version ".tar.gz"))
140 (file-name (string-append name "-" version ".tar.gz"))
141 (sha256
142 (base32
143 "0ds1ya2a185jp93mdn07159c2x8zczwi960ykrawpp62bwk2n93d"))))
144 (build-system trivial-build-system)
145 (arguments
146 `(#:modules ((guix build utils))
147 #:builder
148 (begin
149 (use-modules (guix build utils)
150 (ice-9 match)
151 (ice-9 popen)
152 (srfi srfi-26))
153 (set-path-environment-variable
154 "PATH" '("bin") (map (match-lambda
155 ((_ . input)
156 input))
157 %build-inputs))
158 (let ((install-directory (string-append %output
159 "/share/javascript/respond/")))
160 (system* "tar" "xvf"
161 (assoc-ref %build-inputs "source")
162 "--strip" "1")
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 <>)))))
169 #t)))
170 (home-page "https://github.com/scottjehl/Respond")
171 (native-inputs
172 `(("uglify-js" ,uglify-js)
173 ("source" ,source)
174 ("gzip" ,gzip)
175 ("tar" ,tar)))
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
179 Media Queries.")
180 (license license:expat)))
181
182 (define-public js-html5shiv
183 (package
184 (name "js-html5shiv")
185 (version "3.7.3")
186 (source (origin
187 (method url-fetch)
188 (uri (string-append "https://github.com/aFarkas/html5shiv/"
189 "archive/" version ".tar.gz"))
190 (file-name (string-append name "-" version ".tar.gz"))
191 (sha256
192 (base32
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":
201 ;;
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))))
206
207 (define-public js-json2
208 (let ((commit "031b1d9e6971bd4c433ca85e216cc853f5a867bd")
209 (revision "1"))
210 (package
211 (name "js-json2")
212 (version (string-append "2016-10-28." revision "-" (string-take commit 7)))
213 (source (origin
214 (method git-fetch)
215 (uri (git-reference
216 (url "https://github.com/douglascrockford/JSON-js.git")
217 (commit commit)))
218 (file-name (string-append name "-" version "-checkout"))
219 (sha256
220 (base32
221 "1fvb6b2y5sd3sqdgcj683sdxcbxdii34q0ysc9wg0dq1sy81l11v"))))
222 (build-system minify-build-system)
223 (arguments
224 `(#:javascript-files '("json2.js"
225 "json_parse.js"
226 "json_parse_state.js"
227 "cycle.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.
232
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.
239
240 @code{json_parse.js}: This file contains an alternative JSON @code{parse}
241 function that uses recursive descent instead of @code{eval}.
242
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}.
245
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))))
251
252 (define-public js-strftime
253 (package
254 (name "js-strftime")
255 (version "0.10.0")
256 (source (origin
257 (method url-fetch)
258 (uri (string-append "https://github.com/samsonjs/strftime/"
259 "archive/v" version ".tar.gz"))
260 (file-name (string-append name "-" version ".tar.gz"))
261 (sha256
262 (base32
263 "1iya43w7y26y2dp9l4d40bhjc4scb5a9mng5ng5c8hsqr82f1375"))))
264 (build-system minify-build-system)
265 (arguments
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)))
274
275 (define-public js-highlight
276 (package
277 (name "js-highlight")
278 (version "9.12.0")
279 (source (origin
280 (method url-fetch)
281 (uri (string-append "https://github.com/isagalaev/highlight.js/"
282 "archive/" version ".tar.gz"))
283 (file-name (string-append name "-" version ".tar.gz"))
284 (sha256
285 (base32
286 "1jjn9mj7fwq4zpr6is438bscf03b3q8jkj0k5c3fc6pkmjnhw939"))))
287 (build-system minify-build-system)
288 (arguments
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
295 detection.")
296 (license license:bsd-3)))
297
298 (define-public js-datatables
299 (package
300 (name "js-datatables")
301 (version "1.10.15")
302 (source (origin
303 (method url-fetch)
304 (uri (string-append "https://datatables.net/releases/DataTables-"
305 version ".zip"))
306 (sha256
307 (base32
308 "1y9xqyqyz7x1ls3ska71pshl2hpiy3qnw1f7wygyslbhy4ssgf57"))))
309 (build-system minify-build-system)
310 (arguments
311 `(#:javascript-files '("media/js/dataTables.bootstrap.js"
312 "media/js/jquery.dataTables.js")))
313 (native-inputs
314 `(("unzip" ,unzip)))
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)))
321
322 (define-public js-selectize
323 (package
324 (name "js-selectize")
325 (version "0.12.4")
326 (source (origin
327 (method url-fetch)
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"))
331 (sha256
332 (base32
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)))
342
343 (define-public js-es5-shim
344 (package
345 (name "js-es5-shim")
346 (version "4.5.9")
347 (source (origin
348 (method url-fetch)
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"))
352 (sha256
353 (base32
354 "0yfndyijz0ykddzprpvfjb2453gzpn528klmwycwbqc1bqd3m1hl"))))
355 (build-system minify-build-system)
356 (arguments `(#:javascript-files
357 '("es5-sham.js"
358 "es5-shim.js")))
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)))