mode-nginx.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. ace.define("ace/mode/nginx_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function (require, exports, module) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var NginxHighlightRules = function () {
  6. var keywords = "include|index|absolute_redirect|aio|output_buffers|directio|sendfile|aio_write|alias|root|chunked_transfer_encoding|client_body_buffer_size|client_body_in_file_only|client_body_in_single_buffer|client_body_temp_path|client_body_timeout|client_header_buffer_size|client_header_timeout|client_max_body_size|connection_pool_size|default_type|disable_symlinks|directio_alignment|error_page|etag|if_modified_since|ignore_invalid_headers|internal|keepalive_requests|keepalive_disable|keepalive_timeout|limit_except|large_client_header_buffers|limit_rate|limit_rate_after|lingering_close|lingering_time|lingering_timeout|listen|log_not_found|log_subrequest|max_ranges|merge_slashes|msie_padding|msie_refresh|open_file_cache|open_file_cache_errors|open_file_cache_min_uses|open_file_cache_valid|output_buffers|port_in_redirect|postpone_output|read_ahead|recursive_error_pages|request_pool_size|reset_timedout_connection|resolver|resolver_timeout|satisfy|send_lowat|send_timeout|sendfile|sendfile_max_chunk|server_name|server_name_in_redirect|server_names_hash_bucket_size|server_names_hash_max_size|server_tokens|subrequest_output_buffer_size|tcp_nodelay|tcp_nopush|try_files|types|types_hash_bucket_size|types_hash_max_size|underscores_in_headers|variables_hash_bucket_size|variables_hash_max_size|accept_mutex|accept_mutex_delay|debug_connection|error_log|daemon|debug_points|env|load_module|lock_file|master_process|multi_accept|pcre_jit|pid|ssl_engine|thread_pool|timer_resolution|use|user|worker_aio_requests|worker_connections|worker_cpu_affinity|worker_priority|worker_processes|worker_rlimit_core|worker_rlimit_nofile|worker_shutdown_timeout|working_directory|allow|deny|add_before_body|add_after_body|addition_types|api|status_zone|auth_basic|auth_basic_user_file|auth_jwt|auth_jwt|auth_jwt_claim_set|auth_jwt_header_set|auth_jwt_key_file|auth_jwt_key_request|auth_jwt_leeway|auth_request|auth_request_set|autoindex|autoindex_exact_size|autoindex_format|autoindex_localtime|ancient_browser|ancient_browser_value|modern_browser|modern_browser_value|charset|charset_map|charset_types|override_charset|source_charset|create_full_put_path|dav_access|dav_methods|min_delete_depth|empty_gif|f4f|f4f_buffer_size|fastcgi_bind|fastcgi_buffer_size|fastcgi_buffering|fastcgi_buffers|fastcgi_busy_buffers_size|fastcgi_cache|fastcgi_cache_background_update|fastcgi_cache_bypass|fastcgi_cache_key|fastcgi_cache_lock|fastcgi_cache_lock_age|fastcgi_cache_lock_timeout|fastcgi_cache_max_range_offset|fastcgi_cache_methods|fastcgi_cache_min_uses|fastcgi_cache_min_uses|fastcgi_cache_path|fastcgi_cache_purge|fastcgi_cache_revalidate|fastcgi_cache_use_stale|fastcgi_cache_valid|fastcgi_catch_stderr|fastcgi_connect_timeout|fastcgi_force_ranges|fastcgi_hide_header|fastcgi_ignore_client_abort|fastcgi_ignore_headers|fastcgi_index|fastcgi_intercept_errors|fastcgi_keep_conn|fastcgi_limit_rate|fastcgi_max_temp_file_size|fastcgi_next_upstream|fastcgi_next_upstream_timeout|fastcgi_next_upstream_tries|fastcgi_no_cache|fastcgi_param|fastcgi_pass|fastcgi_pass_header|fastcgi_pass_request_body|fastcgi_pass_request_headers|fastcgi_read_timeout|fastcgi_request_buffering|fastcgi_send_lowat|fastcgi_send_timeout|fastcgi_socket_keepalive|fastcgi_split_path_info|fastcgi_store|fastcgi_store_access|fastcgi_temp_file_write_size|fastcgi_temp_path|flv|geoip_country|geoip_city|geoip_org|geoip_proxy|geoip_proxy_recursive|grpc_bind|grpc_buffer_size|grpc_connect_timeout|grpc_hide_header|grpc_ignore_headers|grpc_intercept_errors|grpc_next_upstream|grpc_next_upstream_timeout|grpc_next_upstream_tries|grpc_pass|grpc_pass_header|grpc_read_timeout|grpc_send_timeout|grpc_set_header|grpc_socket_keepalive|grpc_ssl_certificate|grpc_ssl_certificate_key|grpc_ssl_ciphers|grpc_ssl_crl|grpc_ssl_name|grpc_ssl_password_file|grpc_ssl_protocols|grpc_ssl_server_name|grpc_ssl_session_reuse|grpc_ssl_trusted_certificate|grpc_ssl_verify|grpc_ssl_verify_depth|gunzip|gunzip_buffers|gzip|gzip_buffers|gzip_comp_level|gzip_disable|gzip_http_version|gzip_min_length|gzip_proxied|gzip_types|gzip_vary|gzip_static|add_header|add_trailer|expires|hlshls_buffers|hls_forward_args|hls_fragment|hls_mp4_buffer_size|hls_mp4_max_buffer_size|image_filter|image_filter_buffer|image_filter_interlace|image_filter_jpeg_quality|image_filter_sharpen|image_filter_transparency|image_filter_webp_quality|js_content|js_include|js_set|keyval|keyval_zone|limit_conn|limit_conn_log_level|limit_conn_status|limit_conn_zone|limit_zone|limit_req|limit_req_log_level|limit_req_status|limit_req_zone|access_log|log_format|open_log_file_cache|map_hash_bucket_size|map_hash_max_size|memcached_bind|memcached_buffer_size|memcached_connect_timeout|memcached_force_ranges|memcached_gzip_flag|memcached_next_upstream|memcached_next_upstream_timeout|memcached_next_upstream_tries|memcached_pass|memcached_read_timeout|memcached_send_timeout|memcached_socket_keepalive|mirror|mirror_request_body|mp4|mp4_buffer_size|mp4_max_buffer_size|mp4_limit_rate|mp4_limit_rate_after|perl_modules|perl_require|perl_set|proxy_bind|proxy_buffer_size|proxy_buffering|proxy_buffers|proxy_busy_buffers_size|proxy_cache|proxy_cache_background_update|proxy_cache_bypass|proxy_cache_convert_head|proxy_cache_key|proxy_cache_lock|proxy_cache_lock_age|proxy_cache_lock_timeout|proxy_cache_max_range_offset|proxy_cache_methods|proxy_cache_min_uses|proxy_cache_path|proxy_cache_purge|proxy_cache_revalidate|proxy_cache_use_stale|proxy_cache_valid|proxy_connect_timeout|proxy_cookie_domain|proxy_cookie_path|proxy_force_ranges|proxy_headers_hash_bucket_size|proxy_headers_hash_max_size|proxy_hide_header|proxy_http_version|proxy_ignore_client_abort|proxy_ignore_headers|proxy_intercept_errors|proxy_limit_rate|proxy_max_temp_file_size|proxy_method|proxy_next_upstream|proxy_next_upstream_timeout|proxy_next_upstream_tries|proxy_no_cache|proxy_pass|proxy_pass_header|proxy_pass_request_body|proxy_pass_request_headers|proxy_read_timeout|proxy_redirect|proxy_send_lowat|proxy_send_timeout|proxy_set_body|proxy_set_header|proxy_socket_keepalive|proxy_ssl_certificate|proxy_ssl_certificate_key|proxy_ssl_ciphers|proxy_ssl_crl|proxy_ssl_name|proxy_ssl_password_file|proxy_ssl_protocols|proxy_ssl_server_name|proxy_ssl_session_reuse|proxy_ssl_trusted_certificate|proxy_ssl_verify|proxy_ssl_verify_depth|proxy_store|proxy_store_access|proxy_temp_file_write_size|proxy_temp_path|random_index|set_real_ip_from|real_ip_header|real_ip_recursive|referer_hash_bucket_size|referer_hash_max_size|valid_referers|break|return|rewrite_log|set|uninitialized_variable_warn|scgi_bind|scgi_buffer_size|scgi_buffering|scgi_buffers|scgi_busy_buffers_size|scgi_cache|scgi_cache_background_update|scgi_cache_key|scgi_cache_lock|scgi_cache_lock_age|scgi_cache_lock_timeout|scgi_cache_max_range_offset|scgi_cache_methods|scgi_cache_min_uses|scgi_cache_path|scgi_cache_purge|scgi_cache_revalidate|scgi_cache_use_stale|scgi_cache_valid|scgi_connect_timeout|scgi_force_ranges|scgi_hide_header|scgi_ignore_client_abort|scgi_ignore_headers|scgi_intercept_errors|scgi_limit_rate|scgi_max_temp_file_size|scgi_next_upstream|scgi_next_upstream_timeout|scgi_next_upstream_tries|scgi_no_cache|scgi_param|scgi_pass|scgi_pass_header|scgi_pass_request_body|scgi_pass_request_headers|scgi_read_timeout|scgi_request_buffering|scgi_send_timeout|scgi_socket_keepalive|scgi_store|scgi_store_access|scgi_temp_file_write_size|scgi_temp_path|secure_link|secure_link_md5|secure_link_secret|session_log|session_log_format|session_log_zone|slice|spdy_chunk_size|spdy_headers_comp|ssi|ssi_last_modified|ssi_min_file_chunk|ssi_silent_errors|ssi_types|ssi_value_length|ssl|ssl_buffer_size|ssl_certificate|ssl_certificate_key|ssl_ciphers|ssl_client_certificate|ssl_crl|ssl_dhparam|ssl_early_data|ssl_ecdh_curve|ssl_password_file|ssl_prefer_server_ciphers|ssl_protocols|ssl_session_cache|ssl_session_ticket_key|ssl_session_tickets|ssl_session_timeout|ssl_stapling|ssl_stapling_file|ssl_stapling_responder|ssl_stapling_verify|ssl_trusted_certificate|ssl_verify_client|ssl_verify_depth|status|status_format|status_zone|stub_status|sub_filter|sub_filter_last_modified|sub_filter_once|sub_filter_types|server|zone|state|hash|ip_hash|keepalive|keepalive_requests|keepalive_timeout|ntlm|least_conn|least_time|queue|random|sticky|sticky_cookie_insert|upstream_conf|health_check|userid|userid_domain|userid_expires|userid_mark|userid_name|userid_p3p|userid_path|userid_service|uwsgi_bind|uwsgi_buffer_size|uwsgi_buffering|uwsgi_buffers|uwsgi_busy_buffers_size|uwsgi_cache|uwsgi_cache_background_update|uwsgi_cache_bypass|uwsgi_cache_key|uwsgi_cache_lock|uwsgi_cache_lock_age|uwsgi_cache_lock_timeout|uwsgi_cache_max_range_offset|uwsgi_cache_methods|uwsgi_cache_min_uses|uwsgi_cache_path|uwsgi_cache_purge|uwsgi_cache_revalidate|uwsgi_cache_use_stale|uwsgi_cache_valid|uwsgi_connect_timeout|uwsgi_force_ranges|uwsgi_hide_header|uwsgi_ignore_client_abort|uwsgi_ignore_headers|uwsgi_intercept_errors|uwsgi_limit_rate|uwsgi_max_temp_file_size|uwsgi_modifier1|uwsgi_modifier2|uwsgi_next_upstream|uwsgi_next_upstream_timeout|uwsgi_next_upstream_tries|uwsgi_no_cache|uwsgi_param|uwsgi_pass|uwsgi_pass_header|uwsgi_pass_request_body|uwsgi_pass_request_headers|uwsgi_read_timeout|uwsgi_request_buffering|uwsgi_send_timeout|uwsgi_socket_keepalive|uwsgi_ssl_certificate|uwsgi_ssl_certificate_key|uwsgi_ssl_ciphers|uwsgi_ssl_crl|uwsgi_ssl_name|uwsgi_ssl_password_file|uwsgi_ssl_protocols|uwsgi_ssl_server_name|uwsgi_ssl_session_reuse|uwsgi_ssl_trusted_certificate|uwsgi_ssl_verify|uwsgi_ssl_verify_depth|uwsgi_store|uwsgi_store_access|uwsgi_temp_file_write_size|uwsgi_temp_path|http2_body_preread_size|http2_chunk_size|http2_idle_timeout|http2_max_concurrent_pushes|http2_max_concurrent_streams|http2_max_field_size|http2_max_header_size|http2_max_requests|http2_push|http2_push_preload|http2_recv_buffer_size|http2_recv_timeout|xml_entities|xslt_last_modified|xslt_param|xslt_string_param|xslt_stylesheet|xslt_types|listen|protocol|resolver|resolver_timeout|timeout|auth_http|auth_http_header|auth_http_pass_client_cert|auth_http_timeout|proxy_buffer|proxy_pass_error_message|proxy_timeout|xclient|starttls|imap_auth|imap_capabilities|imap_client_buffer|pop3_auth|pop3_capabilities|smtp_auth|smtp_capabilities|smtp_client_buffer|smtp_greeting_delay|preread_buffer_size|preread_timeout|proxy_protocol_timeout|js_access|js_filter|js_preread|proxy_download_rate|proxy_requests|proxy_responses|proxy_upload_rate|ssl_handshake_timeout|ssl_preread|health_check_timeout|zone_sync|zone_sync_buffers|zone_sync_connect_retry_interval|zone_sync_connect_timeout|zone_sync_interval|zone_sync_recv_buffer_size|zone_sync_server|zone_sync_ssl|zone_sync_ssl_certificate|zone_sync_ssl_certificate_key|zone_sync_ssl_ciphers|zone_sync_ssl_crl|zone_sync_ssl_name|zone_sync_ssl_password_file|zone_sync_ssl_protocols|zone_sync_ssl_server_name|zone_sync_ssl_trusted_certificate|zone_sync_ssl_verify_depth|zone_sync_timeout|google_perftools_profiles|proxy|perl";
  7. this.$rules = {
  8. "start": [{
  9. token: ["storage.type", "text", "string.regexp", "paren.lparen"],
  10. regex: "\\b(location)(\\s+)([\\^]?~[\\*]?\\s+.*?)({)"
  11. }, {
  12. token: ["storage.type", "text", "text", "paren.lparen"],
  13. regex: "\\b(location|match|upstream)(\\s+)(.*?)({)"
  14. }, {
  15. token: ["storage.type", "text", "string", "text", "variable", "text", "paren.lparen"],
  16. regex: '\\b(split_clients|map)(\\s+)(\\".*\\")(\\s+)(\\$[\\w_]+)(\\s*)({)'
  17. }, {
  18. token: ["storage.type", "text", "paren.lparen"],
  19. regex: "\\b(http|events|server|mail|stream)(\\s*)({)"
  20. }, {
  21. token: ["storage.type", "text", "variable", "text", "variable", "text", "paren.lparen"],
  22. regex: '\\b(geo|map)(\\s+)(\\$[\\w_]+)?(\\s*)(\\$[\\w_]+)(\\s*)({)'
  23. }, {
  24. token: "paren.rparen",
  25. regex: "(})"
  26. }, {
  27. token: "paren.lparen",
  28. regex: "({)"
  29. }, {
  30. token: ["storage.type", "text", "paren.lparen"],
  31. regex: "\\b(if)(\\s+)(\\()",
  32. push: [{
  33. token: "paren.rparen",
  34. regex: "\\)|$",
  35. next: "pop"
  36. }, {
  37. include: "lexical"
  38. }]
  39. }, {
  40. token: "keyword",
  41. regex: "\\b(" + keywords + ")\\b",
  42. push: [{
  43. token: "punctuation",
  44. regex: ";",
  45. next: "pop"
  46. }, {
  47. include: "lexical"
  48. }]
  49. }, {
  50. token: ["keyword", "text", "string.regexp", "text", "punctuation"],
  51. regex: "\\b(rewrite)(\\s)(\\S*)(\\s.*)(;)"
  52. }, {
  53. include: "lexical"
  54. }, {
  55. include: "comments"
  56. }],
  57. comments: [{
  58. token: "comment",
  59. regex: '#.*$'
  60. }],
  61. lexical: [{
  62. token: "string",
  63. regex: "'",
  64. push: [{
  65. token: "string",
  66. regex: "'",
  67. next: "pop"
  68. }, {
  69. include: "variables"
  70. }, {
  71. defaultToken: "string"
  72. }]
  73. }, {
  74. token: "string",
  75. regex: '"',
  76. push: [{
  77. token: "string",
  78. regex: '"',
  79. next: "pop"
  80. }, {
  81. include: "variables"
  82. }, {
  83. defaultToken: "string"
  84. }]
  85. }, {
  86. token: "string.regexp",
  87. regex: /[!]?[~][*]?\s+.*(?=\))/
  88. }, {
  89. token: "string.regexp",
  90. regex: /[\^]\S*(?=;$)/
  91. }, {
  92. token: "string.regexp",
  93. regex: /[\^]\S*(?=;|\s|$)/
  94. }, {
  95. token: "keyword.operator",
  96. regex: "\\B(\\+|\\-|\\*|\\=|!=)\\B"
  97. }, {
  98. token: "constant.language",
  99. regex: "\\b(true|false|on|off|all|any|main|always)\\b"
  100. }, {
  101. token: "text",
  102. regex: "\\s+"
  103. }, {
  104. include: "variables"
  105. }
  106. ],
  107. variables: [{
  108. token: "variable",
  109. regex: "\\$[\\w_]+"
  110. }, {
  111. token: "variable.language",
  112. regex: "\\b(GET|POST|HEAD)\\b"
  113. }]
  114. };
  115. this.normalizeRules();
  116. };
  117. oop.inherits(NginxHighlightRules, TextHighlightRules);
  118. exports.NginxHighlightRules = NginxHighlightRules;
  119. });
  120. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
  121. "use strict";
  122. var oop = require("../../lib/oop");
  123. var Range = require("../../range").Range;
  124. var BaseFoldMode = require("./fold_mode").FoldMode;
  125. var FoldMode = exports.FoldMode = function(commentRegex) {
  126. if (commentRegex) {
  127. this.foldingStartMarker = new RegExp(
  128. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  129. );
  130. this.foldingStopMarker = new RegExp(
  131. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  132. );
  133. }
  134. };
  135. oop.inherits(FoldMode, BaseFoldMode);
  136. (function() {
  137. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  138. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  139. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  140. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  141. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  142. this._getFoldWidgetBase = this.getFoldWidget;
  143. this.getFoldWidget = function(session, foldStyle, row) {
  144. var line = session.getLine(row);
  145. if (this.singleLineBlockCommentRe.test(line)) {
  146. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  147. return "";
  148. }
  149. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  150. if (!fw && this.startRegionRe.test(line))
  151. return "start"; // lineCommentRegionStart
  152. return fw;
  153. };
  154. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  155. var line = session.getLine(row);
  156. if (this.startRegionRe.test(line))
  157. return this.getCommentRegionBlock(session, line, row);
  158. var match = line.match(this.foldingStartMarker);
  159. if (match) {
  160. var i = match.index;
  161. if (match[1])
  162. return this.openingBracketBlock(session, match[1], row, i);
  163. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  164. if (range && !range.isMultiLine()) {
  165. if (forceMultiline) {
  166. range = this.getSectionRange(session, row);
  167. } else if (foldStyle != "all")
  168. range = null;
  169. }
  170. return range;
  171. }
  172. if (foldStyle === "markbegin")
  173. return;
  174. var match = line.match(this.foldingStopMarker);
  175. if (match) {
  176. var i = match.index + match[0].length;
  177. if (match[1])
  178. return this.closingBracketBlock(session, match[1], row, i);
  179. return session.getCommentFoldRange(row, i, -1);
  180. }
  181. };
  182. this.getSectionRange = function(session, row) {
  183. var line = session.getLine(row);
  184. var startIndent = line.search(/\S/);
  185. var startRow = row;
  186. var startColumn = line.length;
  187. row = row + 1;
  188. var endRow = row;
  189. var maxRow = session.getLength();
  190. while (++row < maxRow) {
  191. line = session.getLine(row);
  192. var indent = line.search(/\S/);
  193. if (indent === -1)
  194. continue;
  195. if (startIndent > indent)
  196. break;
  197. var subRange = this.getFoldWidgetRange(session, "all", row);
  198. if (subRange) {
  199. if (subRange.start.row <= startRow) {
  200. break;
  201. } else if (subRange.isMultiLine()) {
  202. row = subRange.end.row;
  203. } else if (startIndent == indent) {
  204. break;
  205. }
  206. }
  207. endRow = row;
  208. }
  209. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  210. };
  211. this.getCommentRegionBlock = function(session, line, row) {
  212. var startColumn = line.search(/\s*$/);
  213. var maxRow = session.getLength();
  214. var startRow = row;
  215. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  216. var depth = 1;
  217. while (++row < maxRow) {
  218. line = session.getLine(row);
  219. var m = re.exec(line);
  220. if (!m) continue;
  221. if (m[1]) depth--;
  222. else depth++;
  223. if (!depth) break;
  224. }
  225. var endRow = row;
  226. if (endRow > startRow) {
  227. return new Range(startRow, startColumn, endRow, line.length);
  228. }
  229. };
  230. }).call(FoldMode.prototype);
  231. });
  232. ace.define("ace/mode/nginx",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/nginx_highlight_rules","ace/mode/folding/cstyle"], function (require, exports, module) {
  233. "use strict";
  234. var oop = require("../lib/oop");
  235. var TextMode = require("./text").Mode;
  236. var NginxHighlightRules = require("./nginx_highlight_rules").NginxHighlightRules;
  237. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  238. var Mode = function () {
  239. TextMode.call(this);
  240. this.HighlightRules = NginxHighlightRules;
  241. this.foldingRules = new CStyleFoldMode();
  242. this.$behaviour = this.$defaultBehaviour;
  243. };
  244. oop.inherits(Mode, TextMode);
  245. (function () {
  246. this.lineCommentStart = "#";
  247. this.$id = "ace/mode/nginx";
  248. }).call(Mode.prototype);
  249. exports.Mode = Mode;
  250. }); (function() {
  251. ace.require(["ace/mode/nginx"], function(m) {
  252. if (typeof module == "object" && typeof exports == "object" && module) {
  253. module.exports = m;
  254. }
  255. });
  256. })();