marlin-conf
Advanced tools
Comparing version 2.0.4 to 2.0.5
34
hints.js
@@ -41,3 +41,34 @@ var fs = require('fs'); | ||
var headings=map('heading')(tokens).map(i=>i.index); | ||
function extendTokens(tokens){ | ||
var _alert={ | ||
$$0:{info:'info',error:'danger',warning:'warning'}, | ||
$$1:{info:'info',error:'remove',warning:'exclamation'}, | ||
regex:/\{\% alert (.*) \%\}((.|\n)*)\{\% endalert \%\}/, | ||
template:`<div class="container-fluid"> <div class="row alert alert-$$0 custom-alert"> | ||
<div class="col-lg-1 col-md-2 visible-lg-block visible-md-block"> | ||
<i class="glyphicon glyphicon-$$1-sign" aria-hidden="true" style="font-size:250%;"></i></div> | ||
<div class="col-lg-11 col-md-10">$$2</div> </div> </div>` | ||
}; | ||
var _panel={ | ||
regex:/\{\% panel (.*) \%\}((.|\n)*)\{\% endpanel \%\}/, | ||
template:`<div class="panel panel-info"><div class="panel-heading">$$1</div><div class="panel-body">$$2</div></div>` | ||
} | ||
var _custom={ | ||
regex:/\{\:(.*)\}/, | ||
template:`<div class="panel panel-info"><div class="panel-heading">$$1</div><div class="panel-body">$$2</div></div>` | ||
} | ||
return tokens.map(t=>{ | ||
if (t.text){ | ||
var m; | ||
if(m=t.text.match(_alert.regex)) | ||
t.text=_alert.template.replace('$$0',_alert.$$0[m[1]]).replace('$$1',_alert.$$1[m[1]]).replace('$$2',m[2]) | ||
if(m=t.text.match(_panel.regex)) | ||
t.text=_panel.template.replace('$$1',m[1]).replace('$$2',m[2]) | ||
if(m=t.text.match(_custom.regex)) | ||
t.text=t.text.replace(m[0],'') | ||
} | ||
return t; | ||
}) | ||
} | ||
exports.d2i=define2index; | ||
exports.hint=function(name){ | ||
@@ -53,2 +84,3 @@ var find=define2index[name] | ||
var cut=tokens.slice(ob.min,ob.max); | ||
cut=extendTokens(cut); | ||
cut.links={}; | ||
@@ -55,0 +87,0 @@ return marked.parser(cut); |
@@ -188,2 +188,3 @@ //modules | ||
var section1=(p,i)=>(p[i.name]={changed:i.changed,type:type1(i),condition:i.condition.length&&i.condition||undefined,value:i.value,disabled:i.disabled},p) | ||
var section_txt=(p,i)=>(i.changed&&(p[i.name]={value:i.changed.value||i.value,disabled:i.changed.disabled||i.disabled}),p) | ||
@@ -207,3 +208,4 @@ module.exports.getJson=(root,base,tag)=>file=>{ | ||
// .then(a=>(a.all=a.sections.reduce((p,s)=>(p[s]=a.names.filter(i=>i.section==s).map(section),p),{}),a)) | ||
.then(a=>(a.names=undefined,a)) | ||
.then(a=>(a.txt=a.names.reduce(section_txt,{}),a)) //changed | ||
// .then(a=>(a.names=undefined,a)) | ||
.then(a=>(console.log('done json: ',path.relative(root,file)),a)) | ||
@@ -210,0 +212,0 @@ .catch(a=>console.log('fail json: ',file,a)) |
{ | ||
"name": "marlin-conf", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "configuration tool for Marlin project", | ||
@@ -10,3 +10,4 @@ "scripts": { | ||
"bin": { | ||
"mct": "bin/mct" | ||
"mct": "bin/mct", | ||
"mctd": "bin/mctd" | ||
}, | ||
@@ -25,2 +26,3 @@ "repository": { | ||
"bootstrap": "^3.3.7", | ||
"bootstrap-toggle": "^2.2.2", | ||
"express": "^4.15.2", | ||
@@ -27,0 +29,0 @@ "get-port": "^3.1.0", |
@@ -31,2 +31,5 @@ var express = require('express'); | ||
.then(p=>git.Show(p[1],f).then(file=>mctool.getJson(p[0],file,p[1])(path.join(p[0],f)))) | ||
.then(o=>(o.names.filter(n=>hints.d2i[n.name],1).map(n=>o.defs[n.name].hint=!0),o)) | ||
// .then(o=>(o.names.map(n=>o.defs[n]&&(o.defs[n].hint=1)),o)) | ||
.then(a=>(a.names=undefined,a)) | ||
// .then(a=>res(a)) | ||
@@ -33,0 +36,0 @@ }); |
@@ -78,2 +78,4 @@ function _add(tmpl){ | ||
dis.remove(),p.remove(); | ||
if (def.hint == undefined) | ||
d.find('button').remove(); | ||
}) | ||
@@ -91,2 +93,29 @@ sec.find('.panel-title span.badge:eq(0)').text(cnt); | ||
}) | ||
$('.mct-header button').on('click',function(){ | ||
defs.then(function(data){ | ||
var text=''; | ||
data.forEach(function(file){ | ||
var f=''; | ||
$.each(file.sections,function(n,section){ | ||
var lines=''; | ||
$.each(file.list[section],function(n,define){ | ||
var def=file.defs[define] | ||
if (def.changed){ | ||
var ch=['disabled','value'].filter(function(i){ return i in def.changed &&def.changed[i]!=def[i]}) | ||
if (ch.length) | ||
lines+=(( ch.indexOf('disabled')>=0 ? def.changed.disabled : def.disabled)?'//':'') | ||
+'#define '+define+' ' | ||
+(( ch.indexOf('value')>=0 ? def.changed.value : def.value)||'') | ||
+'\n'; | ||
} | ||
}) | ||
if (lines) | ||
f+='//section '+section+'\n'+lines | ||
}) | ||
if (f) | ||
text+='//file '+file.file.base+'\n'+f; | ||
}) | ||
window.open(encodeURI('https://github.com/MarlinFirmware/Marlin/issues/new?title=&body='+text).replace(/\#/g,'%23')) | ||
}) | ||
}) | ||
var state=$('.mct-header input') | ||
@@ -93,0 +122,0 @@ .on('change',function(){ |
32
tools.js
@@ -45,3 +45,3 @@ var http = require('https'); | ||
var headings=map('heading')(tokens).map(i=>i.index); | ||
var find=define2index['MIXING_VIRTUAL_TOOLS'] | ||
var find=define2index['TEMP_SENSOR_1'] | ||
var banner='<link rel="stylesheet" title="Default" href="styles/default.css">'; | ||
@@ -59,3 +59,27 @@ | ||
var cut=tokens.slice(ob.min,ob.max); | ||
var _alert={ | ||
$$0:{info:'info',error:'danger',warning:'warning'}, | ||
$$1:{info:'info',error:'remove',warning:'exclamation'}, | ||
regex:/\{\% alert (.*) \%\}((.|\n)*)\{\% endalert \%\}/, | ||
template:`<div class="container-fluid"> <div class="row alert alert-$$0 custom-alert"> | ||
<div class="col-lg-1 col-md-2 visible-lg-block visible-md-block"> | ||
<i class="glyphicon glyphicon-$$1-sign" aria-hidden="true" style="font-size:250%;"></i></div> | ||
<div class="col-lg-11 col-md-10">$$2</div> </div> </div>` | ||
}; | ||
var _panel={ | ||
regex:/\{\% panel (.*) \%\}((.|\n)*)\{\% endpanel \%\}/, | ||
template:`<div class="panel panel-info"><div class="panel-heading">$$1</div><div class="panel-body">$$2</div></div>` | ||
} | ||
cut=cut.map(t=>{ | ||
if (t.text){ | ||
var m; | ||
if(m=t.text.match(_alert.regex)) | ||
console.log(t.text=_alert.template.replace('$$0',_alert.$$0[m[1]]).replace('$$1',_alert.$$1[m[1]]).replace('$$2',m[2])) | ||
if(m=t.text.match(_panel.regex)) | ||
console.log(t.text=_panel.template.replace('$$1',m[1]).replace('$$2',m[2])) | ||
} | ||
return t; | ||
}) | ||
cut.links={}; | ||
fs.writeFile("cut",JSON.stringify(cut,null,2)); | ||
fs.writeFile("static/conf.html",banner+marked.parser(cut)); | ||
@@ -65,7 +89,7 @@ // console.log(banner+marked.parser(cut)); | ||
//fs.writeFile("map",JSON.stringify(map(tokens),null,2)); | ||
fs.writeFile("d",JSON.stringify(define2index,null,2)); | ||
fs.writeFile("h",JSON.stringify(headings,null,2)); | ||
fs.writeFile("t",JSON.stringify((tokens),null,2)); | ||
//fs.writeFile("d",JSON.stringify(define2index,null,2)); | ||
//fs.writeFile("h",JSON.stringify(headings,null,2)); | ||
//fs.writeFile("t",JSON.stringify((tokens),null,2)); | ||
if(0){ | ||
fs.writeFile("static/configuration.html",banner+marked.parser(tokens)); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
173694
966
9
+ Addedbootstrap-toggle@^2.2.2
+ Addedbootstrap-toggle@2.2.2(transitive)