# HG changeset patch # User Yaroslav Zhuravlev # Date 1480612164 -10800 # Node ID bfac366fa1e42182c6ff84dc718a1000c845c1ab # Parent c0f9510ea9c6072e4bf112a786eaa8faa22a1ace Added article about nginScript. diff --git a/xml/en/GNUmakefile b/xml/en/GNUmakefile --- a/xml/en/GNUmakefile +++ b/xml/en/GNUmakefile @@ -24,6 +24,7 @@ DOCS = \ contributing_changes \ beginners_guide \ configure \ + njs_about \ FAQ = \ welcome_nginx_facebook \ diff --git a/xml/en/docs/http/ngx_http_js_module.xml b/xml/en/docs/http/ngx_http_js_module.xml --- a/xml/en/docs/http/ngx_http_js_module.xml +++ b/xml/en/docs/http/ngx_http_js_module.xml @@ -9,14 +9,14 @@ + rev="3">
The ngx_http_js_module module is used to implement location and variable handlers -in nginScript — +in nginScript — a subset of the JavaScript language. diff --git a/xml/en/docs/index.xml b/xml/en/docs/index.xml --- a/xml/en/docs/index.xml +++ b/xml/en/docs/index.xml @@ -8,7 +8,7 @@
@@ -94,6 +94,14 @@ + + + + + + + + Chapter “nginx” in “The Architecture of Open Source Applications” diff --git a/xml/en/docs/njs_about.xml b/xml/en/docs/njs_about.xml new file mode 100644 --- /dev/null +++ b/xml/en/docs/njs_about.xml @@ -0,0 +1,293 @@ + + + + + + +
+ +
+ + +nginScript is a subset of the JavaScript language that allows +implementing location and variable handlers in +http and +stream. +nignScript is created in compliance with +ECMAScript 5.1 +with some +ECMAScript 6 +extensions. +The compliance is still evolving. + + +
+ + +
+ + + + + +boolean values, numbers, strings, objects, arrays, +functions, and regular expressions + + + +ES5.1 operators + + + +ES5.1 statements: var, if, +else, switch, for, +for in, while, +do while, break, +continue, return, try, +catch, throw, finally + + + +ES6 Number and +Math properties and methods + + + +String methods: + + + +ES5.1: +fromCharCode, concat, +slice, substring, +substr, charAt, +charCodeAt, indexOf, +lastIndexOf, toLowerCase, +toUpperCase, trim, +search, match, split, +replace + + + +ES6: +fromCodePoint, codePointAt, +includes, startsWith, +endsWith, repeat + + + +non-standard: +fromUTF8, toUTF8, +fromBytes, toBytes + + + + + + +Object: +rudimentary Object.create() support without properties list + + + +Array methods: + + +ES5.1: +isArray, slice, splice, +push, pop,unshift, +shift, reverse, sort, +join, concat, indexOf, +lastIndexOf, forEach, +some, every, filter, +map, reducde, +reduceRight + + + +ES6: includes + + + + + + +ES5.1 Function methods: +call, apply, bind + + + +ES5.1 RegExp methods: +test, exec + + + +ES5.1 Date methods + + + +ES5.1 global functions: +isFinite, isNaN, +parseFloat, parseInt, +decodeURI, decodeURIComponent, +encodeURI, encodeURIComponent + + + + + +
+ + +
+ + + + + +broken scopes support + + + +ES6 let and const declarations + + + +cycle for with var in declaration +(for (var...) + + + +nested functions + + + +closures + + + +labels + + + +arguments array + + + +eval function + + + +JSON object + + + +Error object + + + +setTimeout, setInterval, +setImmediate functions + + + +functions hoisting + + + +non-integer fractions (.235), +exponential (3.35e10), +binary (0b0101), +octal (0o77), +hexadecimal (0x1123) literals + + + + + +
+ + +
+ + +nginScript is available in two modules: + + + +ngx_http_js_module + + + +ngx_stream_js_module + + + +Both modules are not built by default, +they should be either compiled from the sources +or installed as a Linux package. + + + +
+ +For Linux, nginScript modules +packages can be used: + + + +nginx-module-njs — nginScript +dynamic modules + + + +nginx-module-njs-dbg — debug symbols for the +nginx-module-njs package + + + + + +
+ + +
+ + +The repository +with nginScript sources can be cloned with the following command: +(requires Mercurial client): + +hg clone http://hg.nginx.org/njs + +Then the modules should be compiled using the +--add_module configuration parameter: + +./configure --add-module=path-to-njs/nginx + +The modules can also be built as +dynamic: + +./configure --add-dynamic_module=path-to-njs/nginx + + + +
+ +
+ + +
+ + +Both modules are experimental, caveat emptor applies. + + +
+ +
diff --git a/xml/en/docs/stream/ngx_stream_js_module.xml b/xml/en/docs/stream/ngx_stream_js_module.xml --- a/xml/en/docs/stream/ngx_stream_js_module.xml +++ b/xml/en/docs/stream/ngx_stream_js_module.xml @@ -9,13 +9,13 @@ + rev="3">
The ngx_stream_js_module module is used to implement -handlers in nginScript — +handlers in nginScript — a subset of the JavaScript language. diff --git a/xml/ru/GNUmakefile b/xml/ru/GNUmakefile --- a/xml/ru/GNUmakefile +++ b/xml/ru/GNUmakefile @@ -19,6 +19,7 @@ DOCS = \ contributing_changes \ beginners_guide \ configure \ + njs_about \ FAQ = \ sys_errlist \ diff --git a/xml/ru/docs/http/ngx_http_js_module.xml b/xml/ru/docs/http/ngx_http_js_module.xml --- a/xml/ru/docs/http/ngx_http_js_module.xml +++ b/xml/ru/docs/http/ngx_http_js_module.xml @@ -9,14 +9,14 @@ + rev="3">
Модуль ngx_http_js_module позволяет задавать обработчики location и переменных -на nginScript — +на nginScript — подмножестве языка JavaScript. diff --git a/xml/ru/docs/index.xml b/xml/ru/docs/index.xml --- a/xml/ru/docs/index.xml +++ b/xml/ru/docs/index.xml @@ -8,7 +8,7 @@
@@ -95,6 +95,14 @@ + + + + + + + + Глава “nginx” из книги “The Architecture of Open Source Applications” [en] diff --git a/xml/ru/docs/njs_about.xml b/xml/ru/docs/njs_about.xml new file mode 100644 --- /dev/null +++ b/xml/ru/docs/njs_about.xml @@ -0,0 +1,293 @@ + + + + + + +
+ +
+ + +nginScript - это подмножество языка JavaScript, который позволяет +задавать обработчики location и переменных в +http и +stream. +nignScript совместим с +ECMAScript 5.1 +c некоторыми расширениями +ECMAScript 6. +Совместимость находится в стадии развития. + + +
+ + +
+ + + + + +логические значения, числа, строки, объекты, массивы, +функции и регулярные выражения + + + +ES5.1 операторы + + + +ES5.1 инструкции: var, if, +else, switch, for, +for in, while, +do while, break, +continue, return, try, +catch, throw, finally + + + +ES6 методы и свойства Number и +Math + + + +Методы String: + + + +ES5.1: +fromCharCode, concat, +slice, substring, +substr, charAt, +charCodeAt, indexOf, +lastIndexOf, toLowerCase, +toUpperCase, trim, +search, match, split, +replace + + + +ES6: +fromCodePoint, codePointAt, +includes, startsWith, +endsWith, repeat + + + +нестандартные: +fromUTF8, toUTF8, +fromBytes, toBytes + + + + + + +Object: +рудиментарная поддержка Object.create() без списка свойств + + + +Методы Array: + + +ES5.1: +isArray, slice, splice, +push, pop,unshift, +shift, reverse, sort, +join, concat, indexOf, +lastIndexOf, forEach, +some, every, filter, +map, reducde, +reduceRight + + + +ES6: includes + + + + + + +ES5.1 методы Function: +call, apply, bind + + + +ES5.1 методы RegExp: +test, exec + + + +ES5.1 методы Date + + + +ES5.1 глобальные функции: +isFinite, isNaN, +parseFloat, parseInt, +decodeURI, decodeURIComponent, +encodeURI, encodeURIComponent + + + + + +
+ + +
+ + + + + +поддержка broken scopes + + + +ES6 объявления let и const + + + +цикл for с var в объявлении +(for (var...) + + + +вложенные функции + + + +замыкания + + + +labels + + + +массив arguments + + + +функция eval + + + +объект JSON + + + +объект Error + + + +функции setTimeout, setInterval, +setImmediate + + + +поднятие функций + + + +дроби без целой части (.235), +экспоненциальные записи (3.35e10), +двоичные (0b0101), +восьмеричные (0o77), +шестнадцатеричные (0x1123) литералы + + + + + +
+ + +
+ + +nginScript доступен в двух модулях: + + + +ngx_http_js_module + + + +ngx_stream_js_module + + + +По умолчанию модули не собираются +их необходимо собрать из исходного кода +или установить из отдельного пакета Linux. + + + +
+ +Для установки модулей nginScript на Linux могут быть использованы +пакеты: + + + +nginx-module-njs — +динамические модули +nginScript + + + +nginx-module-njs-dbg — debug-символы для +пакета nginx-module-njs + + + + + +
+ + +
+ + +Репозиторий +с исходным кодом nginScript можно клонировать следующей командой: +(необходим клиент Mercurial): + +hg clone http://hg.nginx.org/njs + +Затем модули необходимо собрать с помощью +конфигурационного параметра --add_module: + +./configure --add-module=path-to-njs/nginx + +Модули также можно собрать как +динамические: + +./configure --add-dynamic_module=path-to-njs/nginx + + + +
+ +
+ + +
+ + +Модуль экспериментальный, поэтому возможно всё. + + +
+ +
diff --git a/xml/ru/docs/stream/ngx_stream_js_module.xml b/xml/ru/docs/stream/ngx_stream_js_module.xml --- a/xml/ru/docs/stream/ngx_stream_js_module.xml +++ b/xml/ru/docs/stream/ngx_stream_js_module.xml @@ -9,13 +9,13 @@ + rev="3">
Модуль ngx_stream_js_module позволяет задавать -обработчики на nginScript — +обработчики на nginScript — подмножестве языка JavaScript.