Edit File by line
/home/barbar84/www/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/nginx
File: nginx.js
// CodeMirror, copyright (c) by Marijn Haverbeke and others
[0] Fix | Delete
// Distributed under an MIT license: http://codemirror.net/LICENSE
[1] Fix | Delete
[2] Fix | Delete
(function(mod) {
[3] Fix | Delete
if (typeof exports == "object" && typeof module == "object") // CommonJS
[4] Fix | Delete
mod(require("../../lib/codemirror"));
[5] Fix | Delete
else if (typeof define == "function" && define.amd) // AMD
[6] Fix | Delete
define(["../../lib/codemirror"], mod);
[7] Fix | Delete
else // Plain browser env
[8] Fix | Delete
mod(CodeMirror);
[9] Fix | Delete
})(function(CodeMirror) {
[10] Fix | Delete
"use strict";
[11] Fix | Delete
[12] Fix | Delete
CodeMirror.defineMode("nginx", function(config) {
[13] Fix | Delete
[14] Fix | Delete
function words(str) {
[15] Fix | Delete
var obj = {}, words = str.split(" ");
[16] Fix | Delete
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
[17] Fix | Delete
return obj;
[18] Fix | Delete
}
[19] Fix | Delete
[20] Fix | Delete
var keywords = words(
[21] Fix | Delete
/* ngxDirectiveControl */ "break return rewrite set" +
[22] Fix | Delete
/* ngxDirective */ " accept_mutex accept_mutex_delay access_log add_after_body add_before_body add_header addition_types aio alias allow ancient_browser ancient_browser_value auth_basic auth_basic_user_file auth_http auth_http_header auth_http_timeout autoindex autoindex_exact_size autoindex_localtime charset charset_types 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 create_full_put_path daemon dav_access dav_methods debug_connection debug_points default_type degradation degrade deny devpoll_changes devpoll_events directio directio_alignment empty_gif env epoll_events error_log eventport_events expires fastcgi_bind fastcgi_buffer_size fastcgi_buffers fastcgi_busy_buffers_size fastcgi_cache fastcgi_cache_key fastcgi_cache_methods fastcgi_cache_min_uses fastcgi_cache_path fastcgi_cache_use_stale fastcgi_cache_valid fastcgi_catch_stderr fastcgi_connect_timeout fastcgi_hide_header fastcgi_ignore_client_abort fastcgi_ignore_headers fastcgi_index fastcgi_intercept_errors fastcgi_max_temp_file_size fastcgi_next_upstream fastcgi_param fastcgi_pass_header fastcgi_pass_request_body fastcgi_pass_request_headers fastcgi_read_timeout fastcgi_send_lowat fastcgi_send_timeout fastcgi_split_path_info fastcgi_store fastcgi_store_access fastcgi_temp_file_write_size fastcgi_temp_path fastcgi_upstream_fail_timeout fastcgi_upstream_max_fails flv geoip_city geoip_country google_perftools_profiles gzip gzip_buffers gzip_comp_level gzip_disable gzip_hash gzip_http_version gzip_min_length gzip_no_buffer gzip_proxied gzip_static gzip_types gzip_vary gzip_window if_modified_since ignore_invalid_headers image_filter image_filter_buffer image_filter_jpeg_quality image_filter_transparency imap_auth imap_capabilities imap_client_buffer index ip_hash keepalive_requests keepalive_timeout kqueue_changes kqueue_events large_client_header_buffers limit_conn limit_conn_log_level limit_rate limit_rate_after limit_req limit_req_log_level limit_req_zone limit_zone lingering_time lingering_timeout lock_file log_format log_not_found log_subrequest map_hash_bucket_size map_hash_max_size master_process memcached_bind memcached_buffer_size memcached_connect_timeout memcached_next_upstream memcached_read_timeout memcached_send_timeout memcached_upstream_fail_timeout memcached_upstream_max_fails merge_slashes min_delete_depth modern_browser modern_browser_value msie_padding msie_refresh multi_accept open_file_cache open_file_cache_errors open_file_cache_events open_file_cache_min_uses open_file_cache_valid open_log_file_cache output_buffers override_charset perl perl_modules perl_require perl_set pid pop3_auth pop3_capabilities port_in_redirect postpone_gzipping postpone_output protocol proxy proxy_bind proxy_buffer proxy_buffer_size proxy_buffering proxy_buffers proxy_busy_buffers_size proxy_cache proxy_cache_key proxy_cache_methods proxy_cache_min_uses proxy_cache_path proxy_cache_use_stale proxy_cache_valid proxy_connect_timeout proxy_headers_hash_bucket_size proxy_headers_hash_max_size proxy_hide_header proxy_ignore_client_abort proxy_ignore_headers proxy_intercept_errors proxy_max_temp_file_size proxy_method proxy_next_upstream proxy_pass_error_message 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_ssl_session_reuse proxy_store proxy_store_access proxy_temp_file_write_size proxy_temp_path proxy_timeout proxy_upstream_fail_timeout proxy_upstream_max_fails random_index read_ahead real_ip_header recursive_error_pages request_pool_size reset_timedout_connection resolver resolver_timeout rewrite_log rtsig_overflow_events rtsig_overflow_test rtsig_overflow_threshold rtsig_signo satisfy secure_link_secret send_lowat send_timeout sendfile sendfile_max_chunk server_name_in_redirect server_names_hash_bucket_size server_names_hash_max_size server_tokens set_real_ip_from smtp_auth smtp_capabilities smtp_client_buffer smtp_greeting_delay so_keepalive source_charset ssi ssi_ignore_recycled_buffers ssi_min_file_chunk ssi_silent_errors ssi_types ssi_value_length ssl ssl_certificate ssl_certificate_key ssl_ciphers ssl_client_certificate ssl_crl ssl_dhparam ssl_engine ssl_prefer_server_ciphers ssl_protocols ssl_session_cache ssl_session_timeout ssl_verify_client ssl_verify_depth starttls stub_status sub_filter sub_filter_once sub_filter_types tcp_nodelay tcp_nopush thread_stack_size timeout timer_resolution types_hash_bucket_size types_hash_max_size underscores_in_headers uninitialized_variable_warn use user userid userid_domain userid_expires userid_mark userid_name userid_p3p userid_path userid_service valid_referers variables_hash_bucket_size variables_hash_max_size worker_connections worker_cpu_affinity worker_priority worker_processes worker_rlimit_core worker_rlimit_nofile worker_rlimit_sigpending worker_threads working_directory xclient xml_entities xslt_stylesheet xslt_typesdrew@li229-23"
[23] Fix | Delete
);
[24] Fix | Delete
[25] Fix | Delete
var keywords_block = words(
[26] Fix | Delete
/* ngxDirectiveBlock */ "http mail events server types location upstream charset_map limit_except if geo map"
[27] Fix | Delete
);
[28] Fix | Delete
[29] Fix | Delete
var keywords_important = words(
[30] Fix | Delete
/* ngxDirectiveImportant */ "include root server server_name listen internal proxy_pass memcached_pass fastcgi_pass try_files"
[31] Fix | Delete
);
[32] Fix | Delete
[33] Fix | Delete
var indentUnit = config.indentUnit, type;
[34] Fix | Delete
function ret(style, tp) {type = tp; return style;}
[35] Fix | Delete
[36] Fix | Delete
function tokenBase(stream, state) {
[37] Fix | Delete
[38] Fix | Delete
[39] Fix | Delete
stream.eatWhile(/[\w\$_]/);
[40] Fix | Delete
[41] Fix | Delete
var cur = stream.current();
[42] Fix | Delete
[43] Fix | Delete
[44] Fix | Delete
if (keywords.propertyIsEnumerable(cur)) {
[45] Fix | Delete
return "keyword";
[46] Fix | Delete
}
[47] Fix | Delete
else if (keywords_block.propertyIsEnumerable(cur)) {
[48] Fix | Delete
return "variable-2";
[49] Fix | Delete
}
[50] Fix | Delete
else if (keywords_important.propertyIsEnumerable(cur)) {
[51] Fix | Delete
return "string-2";
[52] Fix | Delete
}
[53] Fix | Delete
/**/
[54] Fix | Delete
[55] Fix | Delete
var ch = stream.next();
[56] Fix | Delete
if (ch == "@") {stream.eatWhile(/[\w\\\-]/); return ret("meta", stream.current());}
[57] Fix | Delete
else if (ch == "/" && stream.eat("*")) {
[58] Fix | Delete
state.tokenize = tokenCComment;
[59] Fix | Delete
return tokenCComment(stream, state);
[60] Fix | Delete
}
[61] Fix | Delete
else if (ch == "<" && stream.eat("!")) {
[62] Fix | Delete
state.tokenize = tokenSGMLComment;
[63] Fix | Delete
return tokenSGMLComment(stream, state);
[64] Fix | Delete
}
[65] Fix | Delete
else if (ch == "=") ret(null, "compare");
[66] Fix | Delete
else if ((ch == "~" || ch == "|") && stream.eat("=")) return ret(null, "compare");
[67] Fix | Delete
else if (ch == "\"" || ch == "'") {
[68] Fix | Delete
state.tokenize = tokenString(ch);
[69] Fix | Delete
return state.tokenize(stream, state);
[70] Fix | Delete
}
[71] Fix | Delete
else if (ch == "#") {
[72] Fix | Delete
stream.skipToEnd();
[73] Fix | Delete
return ret("comment", "comment");
[74] Fix | Delete
}
[75] Fix | Delete
else if (ch == "!") {
[76] Fix | Delete
stream.match(/^\s*\w*/);
[77] Fix | Delete
return ret("keyword", "important");
[78] Fix | Delete
}
[79] Fix | Delete
else if (/\d/.test(ch)) {
[80] Fix | Delete
stream.eatWhile(/[\w.%]/);
[81] Fix | Delete
return ret("number", "unit");
[82] Fix | Delete
}
[83] Fix | Delete
else if (/[,.+>*\/]/.test(ch)) {
[84] Fix | Delete
return ret(null, "select-op");
[85] Fix | Delete
}
[86] Fix | Delete
else if (/[;{}:\[\]]/.test(ch)) {
[87] Fix | Delete
return ret(null, ch);
[88] Fix | Delete
}
[89] Fix | Delete
else {
[90] Fix | Delete
stream.eatWhile(/[\w\\\-]/);
[91] Fix | Delete
return ret("variable", "variable");
[92] Fix | Delete
}
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
function tokenCComment(stream, state) {
[96] Fix | Delete
var maybeEnd = false, ch;
[97] Fix | Delete
while ((ch = stream.next()) != null) {
[98] Fix | Delete
if (maybeEnd && ch == "/") {
[99] Fix | Delete
state.tokenize = tokenBase;
[100] Fix | Delete
break;
[101] Fix | Delete
}
[102] Fix | Delete
maybeEnd = (ch == "*");
[103] Fix | Delete
}
[104] Fix | Delete
return ret("comment", "comment");
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
function tokenSGMLComment(stream, state) {
[108] Fix | Delete
var dashes = 0, ch;
[109] Fix | Delete
while ((ch = stream.next()) != null) {
[110] Fix | Delete
if (dashes >= 2 && ch == ">") {
[111] Fix | Delete
state.tokenize = tokenBase;
[112] Fix | Delete
break;
[113] Fix | Delete
}
[114] Fix | Delete
dashes = (ch == "-") ? dashes + 1 : 0;
[115] Fix | Delete
}
[116] Fix | Delete
return ret("comment", "comment");
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
function tokenString(quote) {
[120] Fix | Delete
return function(stream, state) {
[121] Fix | Delete
var escaped = false, ch;
[122] Fix | Delete
while ((ch = stream.next()) != null) {
[123] Fix | Delete
if (ch == quote && !escaped)
[124] Fix | Delete
break;
[125] Fix | Delete
escaped = !escaped && ch == "\\";
[126] Fix | Delete
}
[127] Fix | Delete
if (!escaped) state.tokenize = tokenBase;
[128] Fix | Delete
return ret("string", "string");
[129] Fix | Delete
};
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
return {
[133] Fix | Delete
startState: function(base) {
[134] Fix | Delete
return {tokenize: tokenBase,
[135] Fix | Delete
baseIndent: base || 0,
[136] Fix | Delete
stack: []};
[137] Fix | Delete
},
[138] Fix | Delete
[139] Fix | Delete
token: function(stream, state) {
[140] Fix | Delete
if (stream.eatSpace()) return null;
[141] Fix | Delete
type = null;
[142] Fix | Delete
var style = state.tokenize(stream, state);
[143] Fix | Delete
[144] Fix | Delete
var context = state.stack[state.stack.length-1];
[145] Fix | Delete
if (type == "hash" && context == "rule") style = "atom";
[146] Fix | Delete
else if (style == "variable") {
[147] Fix | Delete
if (context == "rule") style = "number";
[148] Fix | Delete
else if (!context || context == "@media{") style = "tag";
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
if (context == "rule" && /^[\{\};]$/.test(type))
[152] Fix | Delete
state.stack.pop();
[153] Fix | Delete
if (type == "{") {
[154] Fix | Delete
if (context == "@media") state.stack[state.stack.length-1] = "@media{";
[155] Fix | Delete
else state.stack.push("{");
[156] Fix | Delete
}
[157] Fix | Delete
else if (type == "}") state.stack.pop();
[158] Fix | Delete
else if (type == "@media") state.stack.push("@media");
[159] Fix | Delete
else if (context == "{" && type != "comment") state.stack.push("rule");
[160] Fix | Delete
return style;
[161] Fix | Delete
},
[162] Fix | Delete
[163] Fix | Delete
indent: function(state, textAfter) {
[164] Fix | Delete
var n = state.stack.length;
[165] Fix | Delete
if (/^\}/.test(textAfter))
[166] Fix | Delete
n -= state.stack[state.stack.length-1] == "rule" ? 2 : 1;
[167] Fix | Delete
return state.baseIndent + n * indentUnit;
[168] Fix | Delete
},
[169] Fix | Delete
[170] Fix | Delete
electricChars: "}"
[171] Fix | Delete
};
[172] Fix | Delete
});
[173] Fix | Delete
[174] Fix | Delete
CodeMirror.defineMIME("text/x-nginx-conf", "nginx");
[175] Fix | Delete
[176] Fix | Delete
});
[177] Fix | Delete
[178] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function