Patch Realtime into CodeMirror in CryptPad
This commit is contained in:
1 parent
05ce2695b2
commit
32f44161a7
721 files changed
+148708
-1
No files matched your search
@@ -0,0 +1,181 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: NGINX mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="nginx.js"></script>
|
||||
<style>.CodeMirror {background: #f8f8f8;}</style>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
</head>
|
||||
|
||||
<style>
|
||||
body {
|
||||
margin: 0em auto;
|
||||
}
|
||||
|
||||
.CodeMirror, .CodeMirror-scroll {
|
||||
height: 600px;
|
||||
}
|
||||
</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">NGINX</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>NGINX mode</h2>
|
||||
<form><textarea id="code" name="code" style="height: 800px;">
|
||||
server {
|
||||
listen 173.255.219.235:80;
|
||||
server_name website.com.au;
|
||||
rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www
|
||||
}
|
||||
|
||||
server {
|
||||
listen 173.255.219.235:443;
|
||||
server_name website.com.au;
|
||||
rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www
|
||||
}
|
||||
|
||||
server {
|
||||
|
||||
listen 173.255.219.235:80;
|
||||
server_name www.website.com.au;
|
||||
|
||||
|
||||
|
||||
root /data/www;
|
||||
index index.html index.php;
|
||||
|
||||
location / {
|
||||
index index.html index.php; ## Allow a static html file to be shown first
|
||||
try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
|
||||
expires 30d; ## Assume all files are cachable
|
||||
}
|
||||
|
||||
## These locations would be hidden by .htaccess normally
|
||||
location /app/ { deny all; }
|
||||
location /includes/ { deny all; }
|
||||
location /lib/ { deny all; }
|
||||
location /media/downloadable/ { deny all; }
|
||||
location /pkginfo/ { deny all; }
|
||||
location /report/config.xml { deny all; }
|
||||
location /var/ { deny all; }
|
||||
|
||||
location /var/export/ { ## Allow admins only to view export folder
|
||||
auth_basic "Restricted"; ## Message shown in login window
|
||||
auth_basic_user_file /rs/passwords/testfile; ## See /etc/nginx/htpassword
|
||||
autoindex on;
|
||||
}
|
||||
|
||||
location /. { ## Disable .htaccess and other hidden files
|
||||
return 404;
|
||||
}
|
||||
|
||||
location @handler { ## Magento uses a common front handler
|
||||
rewrite / /index.php;
|
||||
}
|
||||
|
||||
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
|
||||
rewrite ^/(.*.php)/ /$1 last;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
|
||||
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param PATH_INFO $fastcgi_script_name;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include /rs/confs/nginx/fastcgi_params;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
server {
|
||||
|
||||
listen 173.255.219.235:443;
|
||||
server_name website.com.au www.website.com.au;
|
||||
|
||||
root /data/www;
|
||||
index index.html index.php;
|
||||
|
||||
ssl on;
|
||||
ssl_certificate /rs/ssl/ssl.crt;
|
||||
ssl_certificate_key /rs/ssl/ssl.key;
|
||||
|
||||
ssl_session_timeout 5m;
|
||||
|
||||
ssl_protocols SSLv2 SSLv3 TLSv1;
|
||||
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
|
||||
|
||||
location / {
|
||||
index index.html index.php; ## Allow a static html file to be shown first
|
||||
try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
|
||||
expires 30d; ## Assume all files are cachable
|
||||
}
|
||||
|
||||
## These locations would be hidden by .htaccess normally
|
||||
location /app/ { deny all; }
|
||||
location /includes/ { deny all; }
|
||||
location /lib/ { deny all; }
|
||||
location /media/downloadable/ { deny all; }
|
||||
location /pkginfo/ { deny all; }
|
||||
location /report/config.xml { deny all; }
|
||||
location /var/ { deny all; }
|
||||
|
||||
location /var/export/ { ## Allow admins only to view export folder
|
||||
auth_basic "Restricted"; ## Message shown in login window
|
||||
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
|
||||
autoindex on;
|
||||
}
|
||||
|
||||
location /. { ## Disable .htaccess and other hidden files
|
||||
return 404;
|
||||
}
|
||||
|
||||
location @handler { ## Magento uses a common front handler
|
||||
rewrite / /index.php;
|
||||
}
|
||||
|
||||
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
|
||||
rewrite ^/(.*.php)/ /$1 last;
|
||||
}
|
||||
|
||||
location ~ .php$ { ## Execute PHP scripts
|
||||
if (!-e $request_filename) { rewrite /index.php last; } ## Catch 404s that try_files miss
|
||||
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param PATH_INFO $fastcgi_script_name;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include /rs/confs/nginx/fastcgi_params;
|
||||
|
||||
fastcgi_param HTTPS on;
|
||||
}
|
||||
|
||||
}
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/nginx</code>.</p>
|
||||
|
||||
</article>
|
||||
@@ -0,0 +1,178 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("nginx", function(config) {
|
||||
|
||||
function words(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
var keywords = words(
|
||||
/* ngxDirectiveControl */ "break return rewrite set" +
|
||||
/* 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_Line truncated
|
||||
);
|
||||
|
||||
var keywords_block = words(
|
||||
/* ngxDirectiveBlock */ "http mail events server types location upstream charset_map limit_except if geo map"
|
||||
);
|
||||
|
||||
var keywords_important = words(
|
||||
/* ngxDirectiveImportant */ "include root server server_name listen internal proxy_pass memcached_pass fastcgi_pass try_files"
|
||||
);
|
||||
|
||||
var indentUnit = config.indentUnit, type;
|
||||
function ret(style, tp) {type = tp; return style;}
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
|
||||
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
|
||||
var cur = stream.current();
|
||||
|
||||
|
||||
if (keywords.propertyIsEnumerable(cur)) {
|
||||
return "keyword";
|
||||
}
|
||||
else if (keywords_block.propertyIsEnumerable(cur)) {
|
||||
return "variable-2";
|
||||
}
|
||||
else if (keywords_important.propertyIsEnumerable(cur)) {
|
||||
return "string-2";
|
||||
}
|
||||
/**/
|
||||
|
||||
var ch = stream.next();
|
||||
if (ch == "@") {stream.eatWhile(/[\w\\\-]/); return ret("meta", stream.current());}
|
||||
else if (ch == "/" && stream.eat("*")) {
|
||||
state.tokenize = tokenCComment;
|
||||
return tokenCComment(stream, state);
|
||||
}
|
||||
else if (ch == "<" && stream.eat("!")) {
|
||||
state.tokenize = tokenSGMLComment;
|
||||
return tokenSGMLComment(stream, state);
|
||||
}
|
||||
else if (ch == "=") ret(null, "compare");
|
||||
else if ((ch == "~" || ch == "|") && stream.eat("=")) return ret(null, "compare");
|
||||
else if (ch == "\"" || ch == "'") {
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
else if (ch == "#") {
|
||||
stream.skipToEnd();
|
||||
return ret("comment", "comment");
|
||||
}
|
||||
else if (ch == "!") {
|
||||
stream.match(/^\s*\w*/);
|
||||
return ret("keyword", "important");
|
||||
}
|
||||
else if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/[\w.%]/);
|
||||
return ret("number", "unit");
|
||||
}
|
||||
else if (/[,.+>*\/]/.test(ch)) {
|
||||
return ret(null, "select-op");
|
||||
}
|
||||
else if (/[;{}:\[\]]/.test(ch)) {
|
||||
return ret(null, ch);
|
||||
}
|
||||
else {
|
||||
stream.eatWhile(/[\w\\\-]/);
|
||||
return ret("variable", "variable");
|
||||
}
|
||||
}
|
||||
|
||||
function tokenCComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (maybeEnd && ch == "/") {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return ret("comment", "comment");
|
||||
}
|
||||
|
||||
function tokenSGMLComment(stream, state) {
|
||||
var dashes = 0, ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (dashes >= 2 && ch == ">") {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
dashes = (ch == "-") ? dashes + 1 : 0;
|
||||
}
|
||||
return ret("comment", "comment");
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (ch == quote && !escaped)
|
||||
break;
|
||||
escaped = !escaped && ch == "\\";
|
||||
}
|
||||
if (!escaped) state.tokenize = tokenBase;
|
||||
return ret("string", "string");
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function(base) {
|
||||
return {tokenize: tokenBase,
|
||||
baseIndent: base || 0,
|
||||
stack: []};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (stream.eatSpace()) return null;
|
||||
type = null;
|
||||
var style = state.tokenize(stream, state);
|
||||
|
||||
var context = state.stack[state.stack.length-1];
|
||||
if (type == "hash" && context == "rule") style = "atom";
|
||||
else if (style == "variable") {
|
||||
if (context == "rule") style = "number";
|
||||
else if (!context || context == "@media{") style = "tag";
|
||||
}
|
||||
|
||||
if (context == "rule" && /^[\{\};]$/.test(type))
|
||||
state.stack.pop();
|
||||
if (type == "{") {
|
||||
if (context == "@media") state.stack[state.stack.length-1] = "@media{";
|
||||
else state.stack.push("{");
|
||||
}
|
||||
else if (type == "}") state.stack.pop();
|
||||
else if (type == "@media") state.stack.push("@media");
|
||||
else if (context == "{" && type != "comment") state.stack.push("rule");
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
var n = state.stack.length;
|
||||
if (/^\}/.test(textAfter))
|
||||
n -= state.stack[state.stack.length-1] == "rule" ? 2 : 1;
|
||||
return state.baseIndent + n * indentUnit;
|
||||
},
|
||||
|
||||
electricChars: "}"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/nginx", "text/x-nginx-conf");
|
||||
|
||||
});
|
||||
Reference in new issue
Block a user