mirror of https://github.com/Aidaho12/haproxy-wi
				
				
				
			
							parent
							
								
									0079b79c95
								
							
						
					
					
						commit
						2b4c09a2ab
					
				| 
						 | 
				
			
			@ -1,6 +1,8 @@
 | 
			
		|||
{% extends "base.html" %}
 | 
			
		||||
{% 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>
 | 
			
		||||
	{% if selects|length == 0 %}
 | 
			
		||||
		{% include 'include/getstarted.html' %}
 | 
			
		||||
| 
						 | 
				
			
			@ -50,11 +52,15 @@
 | 
			
		|||
		{% if role <= 2 %}
 | 
			
		||||
			<div id="config">
 | 
			
		||||
				<h4>Config from {{ serv }}</h4>
 | 
			
		||||
				</center>
 | 
			
		||||
				<form action="{{ action }}" name="saveconfig" method="post">
 | 
			
		||||
					<input type="hidden" value="{{ serv }}" name="serv"> 
 | 
			
		||||
					<input type="hidden" value="{{ cfg }}.old" name="oldconfig"> 
 | 
			
		||||
					<textarea name="config" class="config" rows="35" cols="100">{{ config }}</textarea> 
 | 
			
		||||
					<p>
 | 
			
		||||
					<div style="margin-left: 23%;width: 60%;">
 | 
			
		||||
						<textarea name="config" id="config_text_area" class="config" rows="35" cols="100">{{ config }}</textarea> 
 | 
			
		||||
					</div>
 | 
			
		||||
					<p>					
 | 
			
		||||
					<center>
 | 
			
		||||
					{% if service == 'haproxy' %}
 | 
			
		||||
						<button type="submit" value="test" name="save" class="btn btn-default">Just test</button>
 | 
			
		||||
					{% endif %}
 | 
			
		||||
| 
						 | 
				
			
			@ -91,6 +97,15 @@
 | 
			
		|||
	if (cur_url[1].split('&')[2] == '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>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -1,7 +1,6 @@
 | 
			
		|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
 | 
			
		||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
 | 
			
		||||
// Modified for HAProxy by HAProxy-WI
 | 
			
		||||
 | 
			
		||||
(function(mod) {
 | 
			
		||||
  if (typeof exports == "object" && typeof module == "object") // CommonJS
 | 
			
		||||
    mod(require("../../lib/codemirror"));
 | 
			
		||||
| 
						 | 
				
			
			@ -11,39 +10,27 @@
 | 
			
		|||
    mod(CodeMirror);
 | 
			
		||||
})(function(CodeMirror) {
 | 
			
		||||
"use strict";
 | 
			
		||||
 | 
			
		||||
CodeMirror.defineMode("haproxy", 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(
 | 
			
		||||
    /* 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"
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
  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"
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
  var keywords_important = words(
 | 
			
		||||
    /*hapDirectiveImportant */ "listen backend frontend peers cache global defaults userlist"
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
  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";
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -53,8 +40,6 @@ CodeMirror.defineMode("haproxy", function(config) {
 | 
			
		|||
    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("*")) {
 | 
			
		||||
| 
						 | 
				
			
			@ -94,7 +79,6 @@ CodeMirror.defineMode("haproxy", function(config) {
 | 
			
		|||
      return ret("variable", "variable");
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function tokenCComment(stream, state) {
 | 
			
		||||
    var maybeEnd = false, ch;
 | 
			
		||||
    while ((ch = stream.next()) != null) {
 | 
			
		||||
| 
						 | 
				
			
			@ -106,7 +90,6 @@ CodeMirror.defineMode("haproxy", function(config) {
 | 
			
		|||
    }
 | 
			
		||||
    return ret("comment", "comment");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function tokenSGMLComment(stream, state) {
 | 
			
		||||
    var dashes = 0, ch;
 | 
			
		||||
    while ((ch = stream.next()) != null) {
 | 
			
		||||
| 
						 | 
				
			
			@ -118,7 +101,6 @@ CodeMirror.defineMode("haproxy", function(config) {
 | 
			
		|||
    }
 | 
			
		||||
    return ret("comment", "comment");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function tokenString(quote) {
 | 
			
		||||
    return function(stream, state) {
 | 
			
		||||
      var escaped = false, ch;
 | 
			
		||||
| 
						 | 
				
			
			@ -131,14 +113,12 @@ CodeMirror.defineMode("haproxy", function(config) {
 | 
			
		|||
      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;
 | 
			
		||||
| 
						 | 
				
			
			@ -150,7 +130,6 @@ CodeMirror.defineMode("haproxy", function(config) {
 | 
			
		|||
        if (context == "rule") style = "number";
 | 
			
		||||
        else if (!context || context == "@media{") style = "tag";
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (context == "rule" && /^[\{\};]$/.test(type))
 | 
			
		||||
        state.stack.pop();
 | 
			
		||||
      if (type == "{") {
 | 
			
		||||
| 
						 | 
				
			
			@ -162,7 +141,6 @@ CodeMirror.defineMode("haproxy", function(config) {
 | 
			
		|||
      else if (context == "{" && type != "comment") state.stack.push("rule");
 | 
			
		||||
      return style;
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    indent: function(state, textAfter) {
 | 
			
		||||
      var n = state.stack.length;
 | 
			
		||||
      if (/^\}/.test(textAfter))
 | 
			
		||||
| 
						 | 
				
			
			@ -173,7 +151,5 @@ CodeMirror.defineMode("haproxy", function(config) {
 | 
			
		|||
    electricChars: "}"
 | 
			
		||||
  };
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
CodeMirror.defineMIME("text/x-haproxy-conf", "haproxy");
 | 
			
		||||
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Loading…
	
		Reference in New Issue