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