Do some cleanup
parent
c5b2459e9d
commit
4bd34dab39
|
@ -1,22 +1,13 @@
|
|||
import toConf from './to_conf';
|
||||
import nginxConf from './nginx.conf';
|
||||
|
||||
const toConfig = obj => {
|
||||
// Convert the obj to nginx
|
||||
const rawConf = toConf(obj);
|
||||
|
||||
// Do some magic to comments
|
||||
const commentConf = rawConf
|
||||
.replace(/^([^\S\r\n]*[^#\s].*[^\n])\n([^\S\r\n]*)#/gm, '$1\n\n$2#') // Double linebreak before comment
|
||||
.replace(/^([^\S\r\n]*#.*\n[^\S\r\n]*#.*\n)([^\S\r\n]*[^#\s])/gm, '$1\n$2') // Double linebreak after double comment
|
||||
|
||||
return commentConf;
|
||||
}
|
||||
// Convert the data to nginx conf and do some magic to comments
|
||||
const toConfig = entriesOrObject => toConf(entriesOrObject)
|
||||
.replace(/^([^\S\r\n]*[^#\s].*[^\n])\n([^\S\r\n]*)#/gm, '$1\n\n$2#') // Double linebreak before comment
|
||||
.replace(/^([^\S\r\n]*#.*\n[^\S\r\n]*#.*\n)([^\S\r\n]*[^#\s])/gm, '$1\n$2'); // Double linebreak after double comment
|
||||
|
||||
export default (domains, global) => {
|
||||
const files = {};
|
||||
|
||||
files['nginx.conf'] = toConfig(nginxConf(domains, global));
|
||||
|
||||
const files = [];
|
||||
files.push(['nginx.conf', toConfig(nginxConf(domains, global))]);
|
||||
return files;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -46,6 +46,6 @@ const recurse = (entriesOrObject, depth) => {
|
|||
}
|
||||
|
||||
return retVal.replace(/\n\n\n/g, '\n\n');
|
||||
}
|
||||
};
|
||||
|
||||
export default entriesOrObject => recurse(entriesOrObject, 0);
|
||||
|
|
|
@ -63,9 +63,9 @@ limitations under the License.
|
|||
|
||||
<div :class="`column ${splitColumn ? 'is-half' : 'is-full'} is-full-mobile is-full-tablet`">
|
||||
<h2>Config files</h2>
|
||||
<template v-for="(conf, name) in confFiles">
|
||||
<h3>{{ nginxDir }}/{{ name }}</h3>
|
||||
<Prism language="nginx" :code="conf"></Prism>
|
||||
<template v-for="(conf, i) in confFiles">
|
||||
<h3>{{ nginxDir }}/{{ conf[0] }}</h3>
|
||||
<Prism :key="`${conf[0]}${i}`" language="nginx" :code="conf[1]"></Prism>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue