mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-06 18:00:57 +00:00
Command (#2134)
* [Update] 任务区分org * [Update] 修改翻译 * [Update] 使用id而不是hostname * [Update] 执行命令 * [Update] 修改一些东西 * [Update] 暂存 * [Update] 用户执行命令 * [Update] 添加资产授权模块-tree * [Update] 暂时这样 * [Update] 批量命令执行 * [Update] 修改表结构 * [Update] 更新翻译 * [Update] 删除cloud模块无效中文翻译
This commit is contained in:
125
apps/static/js/plugins/codemirror/mode/index.html
vendored
Executable file
125
apps/static/js/plugins/codemirror/mode/index.html
vendored
Executable file
@@ -0,0 +1,125 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Language Modes</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../doc/docs.css">
|
||||
|
||||
<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 class=active href="#">Language modes</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
|
||||
<h2>Language modes</h2>
|
||||
|
||||
<p>This is a list of every mode in the distribution. Each mode lives
|
||||
in a subdirectory of the <code>mode/</code> directory, and typically
|
||||
defines a single JavaScript file that implements the mode. Loading
|
||||
such file will make the language available to CodeMirror, through
|
||||
the <a href="manual.html#option_mode"><code>mode</code></a>
|
||||
option.</p>
|
||||
|
||||
<div style="-webkit-columns: 100px 2; -moz-columns: 100px 2; columns: 100px 2;">
|
||||
<ul style="margin-top: 0">
|
||||
<li><a href="apl/index.html">APL</a></li>
|
||||
<li><a href="asterisk/index.html">Asterisk dialplan</a></li>
|
||||
<li><a href="clike/index.html">C, C++, C#</a></li>
|
||||
<li><a href="clojure/index.html">Clojure</a></li>
|
||||
<li><a href="cobol/index.html">COBOL</a></li>
|
||||
<li><a href="coffeescript/index.html">CoffeeScript</a></li>
|
||||
<li><a href="commonlisp/index.html">Common Lisp</a></li>
|
||||
<li><a href="css/index.html">CSS</a></li>
|
||||
<li><a href="cypher/index.html">Cypher</a></li>
|
||||
<li><a href="python/index.html">Cython</a></li>
|
||||
<li><a href="d/index.html">D</a></li>
|
||||
<li><a href="django/index.html">Django</a> (templating language)</li>
|
||||
<li><a href="diff/index.html">diff</a></li>
|
||||
<li><a href="dtd/index.html">DTD</a></li>
|
||||
<li><a href="dylan/index.html">Dylan</a></li>
|
||||
<li><a href="ecl/index.html">ECL</a></li>
|
||||
<li><a href="eiffel/index.html">Eiffel</a></li>
|
||||
<li><a href="erlang/index.html">Erlang</a></li>
|
||||
<li><a href="fortran/index.html">Fortran</a></li>
|
||||
<li><a href="mllike/index.html">F#</a></li>
|
||||
<li><a href="gas/index.html">Gas</a> (AT&T-style assembly)</li>
|
||||
<li><a href="gherkin/index.html">Gherkin</a></li>
|
||||
<li><a href="go/index.html">Go</a></li>
|
||||
<li><a href="groovy/index.html">Groovy</a></li>
|
||||
<li><a href="haml/index.html">HAML</a></li>
|
||||
<li><a href="haskell/index.html">Haskell</a></li>
|
||||
<li><a href="haxe/index.html">Haxe</a></li>
|
||||
<li><a href="htmlembedded/index.html">HTML embedded scripts</a></li>
|
||||
<li><a href="htmlmixed/index.html">HTML mixed-mode</a></li>
|
||||
<li><a href="http/index.html">HTTP</a></li>
|
||||
<li><a href="clike/index.html">Java</a></li>
|
||||
<li><a href="jade/index.html">Jade</a></li>
|
||||
<li><a href="javascript/index.html">JavaScript</a></li>
|
||||
<li><a href="jinja2/index.html">Jinja2</a></li>
|
||||
<li><a href="julia/index.html">Julia</a></li>
|
||||
<li><a href="kotlin/index.html">Kotlin</a></li>
|
||||
<li><a href="css/less.html">LESS</a></li>
|
||||
<li><a href="livescript/index.html">LiveScript</a></li>
|
||||
<li><a href="lua/index.html">Lua</a></li>
|
||||
<li><a href="markdown/index.html">Markdown</a> (<a href="gfm/index.html">GitHub-flavour</a>)</li>
|
||||
<li><a href="mirc/index.html">mIRC</a></li>
|
||||
<li><a href="modelica/index.html">Modelica</a></li>
|
||||
<li><a href="nginx/index.html">Nginx</a></li>
|
||||
<li><a href="ntriples/index.html">NTriples</a></li>
|
||||
<li><a href="mllike/index.html">OCaml</a></li>
|
||||
<li><a href="octave/index.html">Octave</a> (MATLAB)</li>
|
||||
<li><a href="pascal/index.html">Pascal</a></li>
|
||||
<li><a href="pegjs/index.html">PEG.js</a></li>
|
||||
<li><a href="perl/index.html">Perl</a></li>
|
||||
<li><a href="php/index.html">PHP</a></li>
|
||||
<li><a href="pig/index.html">Pig Latin</a></li>
|
||||
<li><a href="properties/index.html">Properties files</a></li>
|
||||
<li><a href="puppet/index.html">Puppet</a></li>
|
||||
<li><a href="python/index.html">Python</a></li>
|
||||
<li><a href="q/index.html">Q</a></li>
|
||||
<li><a href="r/index.html">R</a></li>
|
||||
<li><a href="rpm/index.html">RPM</a></li>
|
||||
<li><a href="rst/index.html">reStructuredText</a></li>
|
||||
<li><a href="ruby/index.html">Ruby</a></li>
|
||||
<li><a href="rust/index.html">Rust</a></li>
|
||||
<li><a href="sass/index.html">Sass</a></li>
|
||||
<li><a href="clike/scala.html">Scala</a></li>
|
||||
<li><a href="scheme/index.html">Scheme</a></li>
|
||||
<li><a href="css/scss.html">SCSS</a></li>
|
||||
<li><a href="shell/index.html">Shell</a></li>
|
||||
<li><a href="sieve/index.html">Sieve</a></li>
|
||||
<li><a href="slim/index.html">Slim</a></li>
|
||||
<li><a href="smalltalk/index.html">Smalltalk</a></li>
|
||||
<li><a href="smarty/index.html">Smarty</a></li>
|
||||
<li><a href="smartymixed/index.html">Smarty/HTML mixed</a></li>
|
||||
<li><a href="solr/index.html">Solr</a></li>
|
||||
<li><a href="sql/index.html">SQL</a> (several dialects)</li>
|
||||
<li><a href="sparql/index.html">SPARQL</a></li>
|
||||
<li><a href="stex/index.html">sTeX, LaTeX</a></li>
|
||||
<li><a href="tcl/index.html">Tcl</a></li>
|
||||
<li><a href="textile/index.html">Textile</a></li>
|
||||
<li><a href="tiddlywiki/index.html">Tiddlywiki</a></li>
|
||||
<li><a href="tiki/index.html">Tiki wiki</a></li>
|
||||
<li><a href="toml/index.html">TOML</a></li>
|
||||
<li><a href="tornado/index.html">Tornado</a> (templating language)</li>
|
||||
<li><a href="turtle/index.html">Turtle</a></li>
|
||||
<li><a href="vb/index.html">VB.NET</a></li>
|
||||
<li><a href="vbscript/index.html">VBScript</a></li>
|
||||
<li><a href="velocity/index.html">Velocity</a></li>
|
||||
<li><a href="verilog/index.html">Verilog/SystemVerilog</a></li>
|
||||
<li><a href="xml/index.html">XML/HTML</a></li>
|
||||
<li><a href="xquery/index.html">XQuery</a></li>
|
||||
<li><a href="yaml/index.html">YAML</a></li>
|
||||
<li><a href="z80/index.html">Z80</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</article>
|
144
apps/static/js/plugins/codemirror/mode/meta.js
vendored
Executable file
144
apps/static/js/plugins/codemirror/mode/meta.js
vendored
Executable file
@@ -0,0 +1,144 @@
|
||||
// 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.modeInfo = [
|
||||
{name: "APL", mime: "text/apl", mode: "apl", ext: ["dyalog", "apl"]},
|
||||
{name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk"},
|
||||
{name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h"]},
|
||||
{name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "hpp", "h++"]},
|
||||
{name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]},
|
||||
{name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"]},
|
||||
{name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj"]},
|
||||
{name: "CoffeeScript", mime: "text/x-coffeescript", mode: "coffeescript", ext: ["coffee"]},
|
||||
{name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"]},
|
||||
{name: "Cypher", mime: "application/x-cypher-query", mode: "cypher"},
|
||||
{name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]},
|
||||
{name: "CSS", mime: "text/css", mode: "css", ext: ["css"]},
|
||||
{name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"]},
|
||||
{name: "D", mime: "text/x-d", mode: "d", ext: ["d"]},
|
||||
{name: "diff", mime: "text/x-diff", mode: "diff", ext: ["diff", "patch"]},
|
||||
{name: "DTD", mime: "application/xml-dtd", mode: "dtd", ext: ["dtd"]},
|
||||
{name: "Dylan", mime: "text/x-dylan", mode: "dylan", ext: ["dylan", "dyl", "intr"]},
|
||||
{name: "ECL", mime: "text/x-ecl", mode: "ecl", ext: ["ecl"]},
|
||||
{name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel", ext: ["e"]},
|
||||
{name: "Embedded Javascript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]},
|
||||
{name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]},
|
||||
{name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90"]},
|
||||
{name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"]},
|
||||
{name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]},
|
||||
{name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
|
||||
{name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm"},
|
||||
{name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]},
|
||||
{name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy"]},
|
||||
{name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
|
||||
{name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]},
|
||||
{name: "Haxe", mime: "text/x-haxe", mode: "haxe", ext: ["hx"]},
|
||||
{name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"]},
|
||||
{name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"]},
|
||||
{name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm"]},
|
||||
{name: "HTTP", mime: "message/http", mode: "http"},
|
||||
{name: "Jade", mime: "text/x-jade", mode: "jade", ext: ["jade"]},
|
||||
{name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]},
|
||||
{name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"]},
|
||||
{name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"],
|
||||
mode: "javascript", ext: ["js"]},
|
||||
{name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"]},
|
||||
{name: "JSON-LD", mime: "application/ld+json", mode: "javascript"},
|
||||
{name: "Jinja2", mime: "null", mode: "jinja2"},
|
||||
{name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]},
|
||||
{name: "Kotlin", mime: "text/x-kotlin", mode: "kotlin", ext: ["kt"]},
|
||||
{name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"]},
|
||||
{name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"]},
|
||||
{name: "Lua", mime: "text/x-lua", mode: "lua", ext: ["lua"]},
|
||||
{name: "Markdown (GitHub-flavour)", mime: "text/x-markdown", mode: "markdown", ext: ["markdown", "md", "mkd"]},
|
||||
{name: "mIRC", mime: "text/mirc", mode: "mirc"},
|
||||
{name: "MariaDB SQL", mime: "text/x-mariadb", mode: "sql"},
|
||||
{name: "Modelica", mime: "text/x-modelica", mode: "modelica", ext: ["mo"]},
|
||||
{name: "MS SQL", mime: "text/x-mssql", mode: "sql"},
|
||||
{name: "MySQL", mime: "text/x-mysql", mode: "sql"},
|
||||
{name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx"},
|
||||
{name: "NTriples", mime: "text/n-triples", mode: "ntriples", ext: ["nt"]},
|
||||
{name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"]},
|
||||
{name: "Octave", mime: "text/x-octave", mode: "octave", ext: ["m"]},
|
||||
{name: "Pascal", mime: "text/x-pascal", mode: "pascal", ext: ["p", "pas"]},
|
||||
{name: "PEG.js", mime: "null", mode: "pegjs"},
|
||||
{name: "Perl", mime: "text/x-perl", mode: "perl", ext: ["pl", "pm"]},
|
||||
{name: "PHP", mime: "application/x-httpd-php", mode: "php", ext: ["php", "php3", "php4", "php5", "phtml"]},
|
||||
{name: "Pig", mime: "text/x-pig", mode: "pig"},
|
||||
{name: "Plain Text", mime: "text/plain", mode: "null", ext: ["txt", "text", "conf", "def", "list", "log"]},
|
||||
{name: "PLSQL", mime: "text/x-plsql", mode: "sql"},
|
||||
{name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"]},
|
||||
{name: "Python", mime: "text/x-python", mode: "python", ext: ["py", "pyw"]},
|
||||
{name: "Puppet", mime: "text/x-puppet", mode: "puppet", ext: ["pp"]},
|
||||
{name: "Q", mime: "text/x-q", mode: "q", ext: ["q"]},
|
||||
{name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r"]},
|
||||
{name: "reStructuredText", mime: "text/x-rst", mode: "rst", ext: ["rst"]},
|
||||
{name: "Ruby", mime: "text/x-ruby", mode: "ruby", ext: ["rb"]},
|
||||
{name: "Rust", mime: "text/x-rustsrc", mode: "rust", ext: ["rs"]},
|
||||
{name: "Sass", mime: "text/x-sass", mode: "sass", ext: ["sass"]},
|
||||
{name: "Scala", mime: "text/x-scala", mode: "clike", ext: ["scala"]},
|
||||
{name: "Scheme", mime: "text/x-scheme", mode: "scheme", ext: ["scm", "ss"]},
|
||||
{name: "SCSS", mime: "text/x-scss", mode: "css", ext: ["scss"]},
|
||||
{name: "Shell", mime: "text/x-sh", mode: "shell", ext: ["sh", "ksh", "bash"]},
|
||||
{name: "Sieve", mime: "application/sieve", mode: "sieve"},
|
||||
{name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim"},
|
||||
{name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk", ext: ["st"]},
|
||||
{name: "Smarty", mime: "text/x-smarty", mode: "smarty", ext: ["tpl"]},
|
||||
{name: "SmartyMixed", mime: "text/x-smarty", mode: "smartymixed"},
|
||||
{name: "Solr", mime: "text/x-solr", mode: "solr"},
|
||||
{name: "SPARQL", mime: "application/x-sparql-query", mode: "sparql", ext: ["sparql"]},
|
||||
{name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]},
|
||||
{name: "MariaDB", mime: "text/x-mariadb", mode: "sql"},
|
||||
{name: "sTeX", mime: "text/x-stex", mode: "stex"},
|
||||
{name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx"]},
|
||||
{name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v"]},
|
||||
{name: "Tcl", mime: "text/x-tcl", mode: "tcl", ext: ["tcl"]},
|
||||
{name: "Textile", mime: "text/x-textile", mode: "textile"},
|
||||
{name: "TiddlyWiki ", mime: "text/x-tiddlywiki", mode: "tiddlywiki"},
|
||||
{name: "Tiki wiki", mime: "text/tiki", mode: "tiki"},
|
||||
{name: "TOML", mime: "text/x-toml", mode: "toml"},
|
||||
{name: "Tornado", mime: "text/x-tornado", mode: "tornado"},
|
||||
{name: "Turtle", mime: "text/turtle", mode: "turtle", ext: ["ttl"]},
|
||||
{name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"]},
|
||||
{name: "VB.NET", mime: "text/x-vb", mode: "vb", ext: ["vb"]},
|
||||
{name: "VBScript", mime: "text/vbscript", mode: "vbscript"},
|
||||
{name: "Velocity", mime: "text/velocity", mode: "velocity", ext: ["vtl"]},
|
||||
{name: "Verilog", mime: "text/x-verilog", mode: "verilog", ext: ["v"]},
|
||||
{name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd"]},
|
||||
{name: "XQuery", mime: "application/xquery", mode: "xquery", ext: ["xy", "xquery"]},
|
||||
{name: "YAML", mime: "text/x-yaml", mode: "yaml", ext: ["yaml"]},
|
||||
{name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]}
|
||||
];
|
||||
// Ensure all modes have a mime property for backwards compatibility
|
||||
for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
|
||||
var info = CodeMirror.modeInfo[i];
|
||||
if (info.mimes) info.mime = info.mimes[0];
|
||||
}
|
||||
|
||||
CodeMirror.findModeByMIME = function(mime) {
|
||||
for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
|
||||
var info = CodeMirror.modeInfo[i];
|
||||
if (info.mime == mime) return info;
|
||||
if (info.mimes) for (var j = 0; j < info.mimes.length; j++)
|
||||
if (info.mimes[j] == mime) return info;
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.findModeByExtension = function(ext) {
|
||||
for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
|
||||
var info = CodeMirror.modeInfo[i];
|
||||
if (info.ext) for (var j = 0; j < info.ext.length; j++)
|
||||
if (info.ext[j] == ext) return info;
|
||||
}
|
||||
};
|
||||
});
|
66
apps/static/js/plugins/codemirror/mode/shell/index.html
vendored
Executable file
66
apps/static/js/plugins/codemirror/mode/shell/index.html
vendored
Executable file
@@ -0,0 +1,66 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Shell 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="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src=shell.js></script>
|
||||
<style type=text/css>
|
||||
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
|
||||
</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="#">Shell</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Shell mode</h2>
|
||||
|
||||
|
||||
<textarea id=code>
|
||||
#!/bin/bash
|
||||
|
||||
# clone the repository
|
||||
git clone http://github.com/garden/tree
|
||||
|
||||
# generate HTTPS credentials
|
||||
cd tree
|
||||
openssl genrsa -aes256 -out https.key 1024
|
||||
openssl req -new -nodes -key https.key -out https.csr
|
||||
openssl x509 -req -days 365 -in https.csr -signkey https.key -out https.crt
|
||||
cp https.key{,.orig}
|
||||
openssl rsa -in https.key.orig -out https.key
|
||||
|
||||
# start the server in HTTPS mode
|
||||
cd web
|
||||
sudo node ../server.js 443 'yes' >> ../node.log &
|
||||
|
||||
# here is how to stop the server
|
||||
for pid in `ps aux | grep 'node ../server.js' | awk '{print $2}'` ; do
|
||||
sudo kill -9 $pid 2> /dev/null
|
||||
done
|
||||
|
||||
exit 0</textarea>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById('code'), {
|
||||
mode: 'shell',
|
||||
lineNumbers: true,
|
||||
matchBrackets: true
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-sh</code>.</p>
|
||||
</article>
|
138
apps/static/js/plugins/codemirror/mode/shell/shell.js
vendored
Executable file
138
apps/static/js/plugins/codemirror/mode/shell/shell.js
vendored
Executable file
@@ -0,0 +1,138 @@
|
||||
// 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('shell', function() {
|
||||
|
||||
var words = {};
|
||||
function define(style, string) {
|
||||
var split = string.split(' ');
|
||||
for(var i = 0; i < split.length; i++) {
|
||||
words[split[i]] = style;
|
||||
}
|
||||
};
|
||||
|
||||
// Atoms
|
||||
define('atom', 'true false');
|
||||
|
||||
// Keywords
|
||||
define('keyword', 'if then do else elif while until for in esac fi fin ' +
|
||||
'fil done exit set unset export function');
|
||||
|
||||
// Commands
|
||||
define('builtin', 'ab awk bash beep cat cc cd chown chmod chroot clear cp ' +
|
||||
'curl cut diff echo find gawk gcc get git grep kill killall ln ls make ' +
|
||||
'mkdir openssl mv nc node npm ping ps restart rm rmdir sed service sh ' +
|
||||
'shopt shred source sort sleep ssh start stop su sudo tee telnet top ' +
|
||||
'touch vi vim wall wc wget who write yes zsh');
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
if (stream.eatSpace()) return null;
|
||||
|
||||
var sol = stream.sol();
|
||||
var ch = stream.next();
|
||||
|
||||
if (ch === '\\') {
|
||||
stream.next();
|
||||
return null;
|
||||
}
|
||||
if (ch === '\'' || ch === '"' || ch === '`') {
|
||||
state.tokens.unshift(tokenString(ch));
|
||||
return tokenize(stream, state);
|
||||
}
|
||||
if (ch === '#') {
|
||||
if (sol && stream.eat('!')) {
|
||||
stream.skipToEnd();
|
||||
return 'meta'; // 'comment'?
|
||||
}
|
||||
stream.skipToEnd();
|
||||
return 'comment';
|
||||
}
|
||||
if (ch === '$') {
|
||||
state.tokens.unshift(tokenDollar);
|
||||
return tokenize(stream, state);
|
||||
}
|
||||
if (ch === '+' || ch === '=') {
|
||||
return 'operator';
|
||||
}
|
||||
if (ch === '-') {
|
||||
stream.eat('-');
|
||||
stream.eatWhile(/\w/);
|
||||
return 'attribute';
|
||||
}
|
||||
if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/\d/);
|
||||
if(stream.eol() || !/\w/.test(stream.peek())) {
|
||||
return 'number';
|
||||
}
|
||||
}
|
||||
stream.eatWhile(/[\w-]/);
|
||||
var cur = stream.current();
|
||||
if (stream.peek() === '=' && /\w+/.test(cur)) return 'def';
|
||||
return words.hasOwnProperty(cur) ? words[cur] : null;
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var next, end = false, escaped = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next === quote && !escaped) {
|
||||
end = true;
|
||||
break;
|
||||
}
|
||||
if (next === '$' && !escaped && quote !== '\'') {
|
||||
escaped = true;
|
||||
stream.backUp(1);
|
||||
state.tokens.unshift(tokenDollar);
|
||||
break;
|
||||
}
|
||||
escaped = !escaped && next === '\\';
|
||||
}
|
||||
if (end || !escaped) {
|
||||
state.tokens.shift();
|
||||
}
|
||||
return (quote === '`' || quote === ')' ? 'quote' : 'string');
|
||||
};
|
||||
};
|
||||
|
||||
var tokenDollar = function(stream, state) {
|
||||
if (state.tokens.length > 1) stream.eat('$');
|
||||
var ch = stream.next(), hungry = /\w/;
|
||||
if (ch === '{') hungry = /[^}]/;
|
||||
if (ch === '(') {
|
||||
state.tokens[0] = tokenString(')');
|
||||
return tokenize(stream, state);
|
||||
}
|
||||
if (!/\d/.test(ch)) {
|
||||
stream.eatWhile(hungry);
|
||||
stream.eat('}');
|
||||
}
|
||||
state.tokens.shift();
|
||||
return 'def';
|
||||
};
|
||||
|
||||
function tokenize(stream, state) {
|
||||
return (state.tokens[0] || tokenBase) (stream, state);
|
||||
};
|
||||
|
||||
return {
|
||||
startState: function() {return {tokens:[]};},
|
||||
token: function(stream, state) {
|
||||
return tokenize(stream, state);
|
||||
},
|
||||
lineComment: '#'
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME('text/x-sh', 'shell');
|
||||
|
||||
});
|
58
apps/static/js/plugins/codemirror/mode/shell/test.js
vendored
Executable file
58
apps/static/js/plugins/codemirror/mode/shell/test.js
vendored
Executable file
@@ -0,0 +1,58 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
var mode = CodeMirror.getMode({}, "shell");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
MT("var",
|
||||
"text [def $var] text");
|
||||
MT("varBraces",
|
||||
"text[def ${var}]text");
|
||||
MT("varVar",
|
||||
"text [def $a$b] text");
|
||||
MT("varBracesVarBraces",
|
||||
"text[def ${a}${b}]text");
|
||||
|
||||
MT("singleQuotedVar",
|
||||
"[string 'text $var text']");
|
||||
MT("singleQuotedVarBraces",
|
||||
"[string 'text ${var} text']");
|
||||
|
||||
MT("doubleQuotedVar",
|
||||
'[string "text ][def $var][string text"]');
|
||||
MT("doubleQuotedVarBraces",
|
||||
'[string "text][def ${var}][string text"]');
|
||||
MT("doubleQuotedVarPunct",
|
||||
'[string "text ][def $@][string text"]');
|
||||
MT("doubleQuotedVarVar",
|
||||
'[string "][def $a$b][string "]');
|
||||
MT("doubleQuotedVarBracesVarBraces",
|
||||
'[string "][def ${a}${b}][string "]');
|
||||
|
||||
MT("notAString",
|
||||
"text\\'text");
|
||||
MT("escapes",
|
||||
"outside\\'\\\"\\`\\\\[string \"inside\\`\\'\\\"\\\\`\\$notAVar\"]outside\\$\\(notASubShell\\)");
|
||||
|
||||
MT("subshell",
|
||||
"[builtin echo] [quote $(whoami)] s log, stardate [quote `date`].");
|
||||
MT("doubleQuotedSubshell",
|
||||
"[builtin echo] [string \"][quote $(whoami)][string 's log, stardate `date`.\"]");
|
||||
|
||||
MT("hashbang",
|
||||
"[meta #!/bin/bash]");
|
||||
MT("comment",
|
||||
"text [comment # Blurb]");
|
||||
|
||||
MT("numbers",
|
||||
"[number 0] [number 1] [number 2]");
|
||||
MT("keywords",
|
||||
"[keyword while] [atom true]; [keyword do]",
|
||||
" [builtin sleep] [number 3]",
|
||||
"[keyword done]");
|
||||
MT("options",
|
||||
"[builtin ls] [attribute -l] [attribute --human-readable]");
|
||||
MT("operator",
|
||||
"[def var][operator =]value");
|
||||
})();
|
Reference in New Issue
Block a user