mirror of https://github.com/Aidaho12/haproxy-wi
parent
0079b79c95
commit
2b4c09a2ab
|
@ -1,6 +1,8 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<script src="/inc/jquery-linenumbers.js"></script>
|
<link rel="stylesheet" href="/inc/codemirror/codemirror.css">
|
||||||
|
<script src="/inc/codemirror/codemirror.js"></script>
|
||||||
|
<script src="/inc/codemirror/nginx.js"></script>
|
||||||
<center>
|
<center>
|
||||||
{% if selects|length == 0 %}
|
{% if selects|length == 0 %}
|
||||||
{% include 'include/getstarted.html' %}
|
{% include 'include/getstarted.html' %}
|
||||||
|
@ -50,11 +52,15 @@
|
||||||
{% if role <= 2 %}
|
{% if role <= 2 %}
|
||||||
<div id="config">
|
<div id="config">
|
||||||
<h4>Config from {{ serv }}</h4>
|
<h4>Config from {{ serv }}</h4>
|
||||||
|
</center>
|
||||||
<form action="{{ action }}" name="saveconfig" method="post">
|
<form action="{{ action }}" name="saveconfig" method="post">
|
||||||
<input type="hidden" value="{{ serv }}" name="serv">
|
<input type="hidden" value="{{ serv }}" name="serv">
|
||||||
<input type="hidden" value="{{ cfg }}.old" name="oldconfig">
|
<input type="hidden" value="{{ cfg }}.old" name="oldconfig">
|
||||||
<textarea name="config" class="config" rows="35" cols="100">{{ config }}</textarea>
|
<div style="margin-left: 23%;width: 60%;">
|
||||||
<p>
|
<textarea name="config" id="config_text_area" class="config" rows="35" cols="100">{{ config }}</textarea>
|
||||||
|
</div>
|
||||||
|
<p>
|
||||||
|
<center>
|
||||||
{% if service == 'haproxy' %}
|
{% if service == 'haproxy' %}
|
||||||
<button type="submit" value="test" name="save" class="btn btn-default">Just test</button>
|
<button type="submit" value="test" name="save" class="btn btn-default">Just test</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -91,6 +97,15 @@
|
||||||
if (cur_url[1].split('&')[2] == 'showConfig') {
|
if (cur_url[1].split('&')[2] == 'showConfig') {
|
||||||
showConfig();
|
showConfig();
|
||||||
}
|
}
|
||||||
$('textarea').linenumbers({col_width: '25px'});
|
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("config_text_area"), {mode: "nginx", lineNumbers: true});
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
.CodeMirror {
|
||||||
|
line-height: 1.2em;
|
||||||
|
height: 50%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
myCodeMirror.refresh();
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,6 @@
|
||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||||
// Modified for HAProxy by HAProxy-WI
|
// Modified for HAProxy by HAProxy-WI
|
||||||
|
|
||||||
(function(mod) {
|
(function(mod) {
|
||||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||||
mod(require("../../lib/codemirror"));
|
mod(require("../../lib/codemirror"));
|
||||||
|
@ -11,39 +10,27 @@
|
||||||
mod(CodeMirror);
|
mod(CodeMirror);
|
||||||
})(function(CodeMirror) {
|
})(function(CodeMirror) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
CodeMirror.defineMode("haproxy", function(config) {
|
CodeMirror.defineMode("haproxy", function(config) {
|
||||||
|
|
||||||
function words(str) {
|
function words(str) {
|
||||||
var obj = {}, words = str.split(" ");
|
var obj = {}, words = str.split(" ");
|
||||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
var keywords = words(
|
var keywords = words(
|
||||||
/* hapDirectiveControl */ "abuse" +
|
/* hapDirectiveControl */ "abuse" +
|
||||||
/* hapDirective */ " log chroot maxconn user group pidfile stats mode option bind retries stats total max balance acl tcp http filter stick tcp timeout daemon table request"
|
/* hapDirective */ " log chroot maxconn user group pidfile stats mode option bind retries stats total max balance acl tcp http filter stick tcp timeout daemon table request"
|
||||||
);
|
);
|
||||||
|
|
||||||
var keywords_block = words(
|
var keywords_block = words(
|
||||||
/* hapDirectiveBlock */ "server default_backend use_backend if geo map check ! http roundrobin leastconect queue connect client server forwardfor deny accept socket httplog except redispatch gt ge or and eq ln reject dontlognull admin auth"
|
/* hapDirectiveBlock */ "server default_backend use_backend if geo map check ! http roundrobin leastconect queue connect client server forwardfor deny accept socket httplog except redispatch gt ge or and eq ln reject dontlognull admin auth"
|
||||||
);
|
);
|
||||||
|
|
||||||
var keywords_important = words(
|
var keywords_important = words(
|
||||||
/*hapDirectiveImportant */ "listen backend frontend peers cache global defaults userlist"
|
/*hapDirectiveImportant */ "listen backend frontend peers cache global defaults userlist"
|
||||||
);
|
);
|
||||||
|
|
||||||
var indentUnit = config.indentUnit, type;
|
var indentUnit = config.indentUnit, type;
|
||||||
function ret(style, tp) {type = tp; return style;}
|
function ret(style, tp) {type = tp; return style;}
|
||||||
|
|
||||||
function tokenBase(stream, state) {
|
function tokenBase(stream, state) {
|
||||||
|
|
||||||
|
|
||||||
stream.eatWhile(/[\w\$_]/);
|
stream.eatWhile(/[\w\$_]/);
|
||||||
|
|
||||||
var cur = stream.current();
|
var cur = stream.current();
|
||||||
|
|
||||||
|
|
||||||
if (keywords.propertyIsEnumerable(cur)) {
|
if (keywords.propertyIsEnumerable(cur)) {
|
||||||
return "keyword";
|
return "keyword";
|
||||||
}
|
}
|
||||||
|
@ -53,8 +40,6 @@ CodeMirror.defineMode("haproxy", function(config) {
|
||||||
else if (keywords_important.propertyIsEnumerable(cur)) {
|
else if (keywords_important.propertyIsEnumerable(cur)) {
|
||||||
return "string-2";
|
return "string-2";
|
||||||
}
|
}
|
||||||
/**/
|
|
||||||
|
|
||||||
var ch = stream.next();
|
var ch = stream.next();
|
||||||
if (ch == "@") {stream.eatWhile(/[\w\\\-]/); return ret("meta", stream.current());}
|
if (ch == "@") {stream.eatWhile(/[\w\\\-]/); return ret("meta", stream.current());}
|
||||||
else if (ch == "/" && stream.eat("*")) {
|
else if (ch == "/" && stream.eat("*")) {
|
||||||
|
@ -94,7 +79,6 @@ CodeMirror.defineMode("haproxy", function(config) {
|
||||||
return ret("variable", "variable");
|
return ret("variable", "variable");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function tokenCComment(stream, state) {
|
function tokenCComment(stream, state) {
|
||||||
var maybeEnd = false, ch;
|
var maybeEnd = false, ch;
|
||||||
while ((ch = stream.next()) != null) {
|
while ((ch = stream.next()) != null) {
|
||||||
|
@ -106,7 +90,6 @@ CodeMirror.defineMode("haproxy", function(config) {
|
||||||
}
|
}
|
||||||
return ret("comment", "comment");
|
return ret("comment", "comment");
|
||||||
}
|
}
|
||||||
|
|
||||||
function tokenSGMLComment(stream, state) {
|
function tokenSGMLComment(stream, state) {
|
||||||
var dashes = 0, ch;
|
var dashes = 0, ch;
|
||||||
while ((ch = stream.next()) != null) {
|
while ((ch = stream.next()) != null) {
|
||||||
|
@ -118,7 +101,6 @@ CodeMirror.defineMode("haproxy", function(config) {
|
||||||
}
|
}
|
||||||
return ret("comment", "comment");
|
return ret("comment", "comment");
|
||||||
}
|
}
|
||||||
|
|
||||||
function tokenString(quote) {
|
function tokenString(quote) {
|
||||||
return function(stream, state) {
|
return function(stream, state) {
|
||||||
var escaped = false, ch;
|
var escaped = false, ch;
|
||||||
|
@ -131,14 +113,12 @@ CodeMirror.defineMode("haproxy", function(config) {
|
||||||
return ret("string", "string");
|
return ret("string", "string");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
startState: function(base) {
|
startState: function(base) {
|
||||||
return {tokenize: tokenBase,
|
return {tokenize: tokenBase,
|
||||||
baseIndent: base || 0,
|
baseIndent: base || 0,
|
||||||
stack: []};
|
stack: []};
|
||||||
},
|
},
|
||||||
|
|
||||||
token: function(stream, state) {
|
token: function(stream, state) {
|
||||||
if (stream.eatSpace()) return null;
|
if (stream.eatSpace()) return null;
|
||||||
type = null;
|
type = null;
|
||||||
|
@ -150,7 +130,6 @@ CodeMirror.defineMode("haproxy", function(config) {
|
||||||
if (context == "rule") style = "number";
|
if (context == "rule") style = "number";
|
||||||
else if (!context || context == "@media{") style = "tag";
|
else if (!context || context == "@media{") style = "tag";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context == "rule" && /^[\{\};]$/.test(type))
|
if (context == "rule" && /^[\{\};]$/.test(type))
|
||||||
state.stack.pop();
|
state.stack.pop();
|
||||||
if (type == "{") {
|
if (type == "{") {
|
||||||
|
@ -162,7 +141,6 @@ CodeMirror.defineMode("haproxy", function(config) {
|
||||||
else if (context == "{" && type != "comment") state.stack.push("rule");
|
else if (context == "{" && type != "comment") state.stack.push("rule");
|
||||||
return style;
|
return style;
|
||||||
},
|
},
|
||||||
|
|
||||||
indent: function(state, textAfter) {
|
indent: function(state, textAfter) {
|
||||||
var n = state.stack.length;
|
var n = state.stack.length;
|
||||||
if (/^\}/.test(textAfter))
|
if (/^\}/.test(textAfter))
|
||||||
|
@ -173,7 +151,5 @@ CodeMirror.defineMode("haproxy", function(config) {
|
||||||
electricChars: "}"
|
electricChars: "}"
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
CodeMirror.defineMIME("text/x-haproxy-conf", "haproxy");
|
CodeMirror.defineMIME("text/x-haproxy-conf", "haproxy");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue