Skip to content

Commit

Permalink
added editor, updated libraries, upnp fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
akaJes committed May 18, 2018
1 parent 15e10a8 commit 4780699
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 37 deletions.
Binary file removed .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ bower_components
**/test
package-lock.json
unused
.DS_Store
8 changes: 8 additions & 0 deletions HACKS
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@ nat-upnp/lib/nat-upnp/client.js
@@ -119,3 +119,3 @@
- protocol: data.NewProtocol.toLowerCase(),
+ protocol: (data.NewProtocol || '').toLowerCase(),

used updated version from:
https://github.com/MelvinTo/node-nat-upnp

cd node_modules/ot
npm i
node_modules/.bin/grunt --force
rm -r node_modules
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ supported OS: Linux,Mac,Windows
* quick help for Marlin options and G-codes
* compilation and uploading your customized firmware
* console for access to serial ports
* **collaborative editor for whole project**
* share your configuration on [the site](http://lt.rv.ua/mc)
* **automatical installer for PlatformIO**
# Features:
* automatically clone repository from [Marlin github](https://github.com/MarlinFirmware/Marlin) if you don't have it
* instant changing of Configuration*.h files
Expand Down
2 changes: 1 addition & 1 deletion app/services/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ router.post('/upload/*', function(req, res) {
//git file TODO: git for multiproject
router.get('/git/*', function(req, res) {
git.Tag()
.then(tag => git.Show(tag, req.originalUrl.replace(/.*git\//, '')))
.then(tag => git.Show(tag, req.originalUrl.replace(/.*git\//, '')).catch(a=>''))
.catch(e => res.status(501).send(e.message))
.then(data => res.send(data))
})
39 changes: 20 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "marlin-conf",
"version": "2.9.1",
"version": "2.10.1",
"description": "configuration tool for Marlin project",
"main": "./index.js",
"scripts": {
Expand All @@ -11,7 +11,7 @@
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint .",
"rebuild": "npm rebuild serialport --update-binary",
"prepublish": "./node_modules/.bin/json -I -f package.json -e 'if(this.devDependencies)this.devDependenciesOff=this.devDependencies;this.devDependencies=undefined'",
"prepublishOnly": "./node_modules/.bin/json -I -f package.json -e 'if(this.devDependencies)this.devDependenciesOff=this.devDependencies;this.devDependencies=undefined'",
"postpublish": "./node_modules/.bin/json -I -f package.json -e 'if(this.devDependenciesOff)this.devDependencies=this.devDependenciesOff;this.devDependenciesOff=undefined'",
"prebuild-": "sudo apt install icnsutils graphicsmagick"
},
Expand Down Expand Up @@ -57,50 +57,51 @@
"homepage": "https://github.com/akaJes/marlin-config#readme",
"dependencies": {
"ace-builds": "^1.3.3",
"body-parser": "^1.17.2",
"body-parser": "^1.18.3",
"bootstrap": "4.0.0-alpha.6",
"cropper": "^3.1.5",
"cropper": "^3.1.6",
"data-store": "^1.0.0",
"diff-match-patch": "^1.0.0",
"express": "^4.16.2",
"diff-match-patch": "^1.0.1",
"electron-debug": "^1.5.0",
"express": "^4.16.3",
"fix-path": "^2.1.0",
"font-awesome": "^4.7.0",
"form-data": "^2.3.2",
"formidable": "^1.1.1",
"formidable": "^1.2.1",
"get-port": "^3.1.0",
"highlight.js": "^9.11.0",
"jquery": "^3.3.1",
"jquery-ui-dist": "^1.12.1",
"js-yaml": "^3.8.4",
"js-yaml": "^3.11.0",
"jstree": "^3.3.5",
"marked": "^0.3.16",
"marked": "^0.3.19",
"mkdirp": "^0.5.1",
"moment": "^2.20.1",
"nat-upnp": "^1.1.1",
"moment": "^2.22.1",
"nat-upnp": "git+https://github.com/MelvinTo/node-nat-upnp.git",
"node-machine-id": "^1.1.10",
"node-notifier": "^5.2.1",
"opn": "^5.2.0",
"opn": "^5.3.0",
"ot": "git+https://github.com/Operational-Transformation/ot.js.git",
"platformio-node-helpers": "^0.4.3",
"qr-image": "^3.2.0",
"rtcmulticonnection-v3": "^3.4.4",
"serialport": "^6.1.0",
"simple-git": "^1.91.0",
"socket.io": "^2.0.4",
"serialport": "^6.2.0",
"simple-git": "^1.92.0",
"socket.io": "^2.1.1",
"swig-templates": "^2.0.2",
"tether": "^1.4.3",
"tether": "^1.4.4",
"tmp": "0.0.33",
"tty2html": "^1.0.0",
"universal-analytics": "^0.4.16",
"vex-js": "^4.1.0",
"which": "^1.2.14",
"yauzl": "^2.9.1",
"yazl": "^2.4.3"
},
"devDependencies": {
"devtron": "^1.4.0",
"electron": "=1.7.10",
"electron-builder": "^20.2.0",
"electron-debug": "^1.5.0",
"electron": "latest",
"electron-builder": "latest",
"eslint": "^4.18.1",
"json": "^9.0.6",
"nodemon": "^1.15.1"
Expand Down
6 changes: 4 additions & 2 deletions static/editor/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ ace.define("diff", function(require, exports, module) {
function DMP(editor) {
this.editor = editor;
var self = this;
var dc = debounce(scan, 500, self)
this.onChange = function(obj, editor) {
self.scan();
dc(); //self.scan();
}
this.updateAnnotations = function(session) {
self.editor.renderer.setAnnotations((session.$annotations || []).concat(session.diffAnnotations || []))
Expand Down Expand Up @@ -96,7 +97,8 @@ ace.define("diff", function(require, exports, module) {
}
return seek(-1).concat(quote(diffs[pos][1], diffs[pos][0]), seek(1));
}
this.scan = function() {
this.scan = scan;
function scan() {
var session = this.editor.getSession();
session.diffAnnotations = [];
var markers = session.getMarkers();
Expand Down
8 changes: 4 additions & 4 deletions static/editor/editor.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* editor*/
.added-gutter { background: #00AA0055; }
.changed-gutter { background: #AA000055; }
.changed-text { background: #AA000025; position:absolute; z-index:2;}
.added-text { background: #00AA0025; position:absolute; z-index:2;}
.added-gutter { background-color: rgba(0,170,0,.33); }
.changed-gutter { background-color: rgba(170,0,0,.33); }
.changed-text { background-color: rgba(170,0,0,.14); position:absolute; z-index:2;}
.added-text { background-color: rgba(0,170,0,.14); position:absolute; z-index:2;}
.ace_gutter-cell { background-repeat: no-repeat; }
/* layout */
html, body {
Expand Down
33 changes: 26 additions & 7 deletions static/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ var myName;
var otI;
var state;
function createFileUploader(element, tree, editor) {
function addButton(name,fn){
$(element).append($('<button>').addClass('btn btn-sm m-1').text(name).on('click',fn));
function addButton(name, fn, title) {
$(element).append($('<button>').addClass('btn btn-sm m-1').text(name).on('click', fn).attr('title', title));
}
// addButton('<<',function(e){ $('.jstree').toggle(); });
// addButton('A',function(e){ toggleFullScreen(); });
// addButton('Save',function(e){ editor.execCommand("saveCommand") });
addButton('next',function(e){ editor.execCommand("nextDiff") });
addButton('prev',function(e){ editor.execCommand("prevDiff") });
addButton('next',function(e){ editor.execCommand("nextDiff") }, 'seek for next diff');
addButton('prev',function(e){ editor.execCommand("prevDiff") }, 'seek for previous diff');
addButton('{}', function(e) {
if (!editor.getSelectedText()) return;
var beautify = ace.require("ace/ext/beautify"); // get reference to extension
Expand All @@ -22,10 +22,29 @@ var state;
session.setValue(val);
beautify.beautify(session);
var b = session.getValue();
var space = val.match(/^\s+/);
if (space)
b = b.split(/\r\n?|\n/).map(function(line){ return space[0] + line;}).join('\n');
editor.session.doc.replace(range, b);
editor._signal("change", {});
});
addButton('NAME',function(e){ myName = prompt('Tell Ur Name!!!'); otI.setName(myName); });
}, 'beauitify JS code');
addButton('NAME',function(e){
if(isElectron()) {
var d = vex.dialog.prompt({
message: 'Tell Ur Name!!!',
placeholder: 'name',
callback: function (value) {
if(value)
otI.setName(myName = value);
}
})
$(d.contentEl).find('input').val(myName);
} else {
var value = prompt('Tell Ur Name!!!', myName);
if(value)
otI.setName(myName = value);
}
}, 'set Your name for collaborative editing');
addButton('undo',function(e){ editor.getSession().getUndoManager().undo(false); });
$(element).append(state = $('<span class="m-1">Loading...</span>'));
}
Expand Down Expand Up @@ -180,7 +199,7 @@ if(0)
}

$(function(){
$(window).on('beforeunload',function() { return "Realy?"; });
// $(window).on('beforeunload',function() { return "Realy?"; });
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { vars[key] = value; });
var editor = createEditor("editor", vars.file, vars.lang, vars.theme);
Expand Down
3 changes: 3 additions & 0 deletions static/editor/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ function toggleFullScreen() {
cancelFullScreen.call(doc);
}
}
function isElectron() {
return navigator.userAgent.toLowerCase().indexOf(' electron/') >= 0;
}
7 changes: 5 additions & 2 deletions static/editor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<script src="/libs/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="/libs/socket.io-client/dist/socket.io.js"></script>
<script src="/libs/ot/dist/ot.js"></script>
<link href="/libs/vex-js/dist/css/vex.css" rel="stylesheet">
<link href="/libs/vex-js/dist/css/vex-theme-os.css" rel="stylesheet">
<script src="/libs/vex-js/dist/js/vex.combined.js"></script>
<script src="marker.js"></script>

<script>
Expand All @@ -32,8 +35,8 @@
<body>
<div class="stickit top">
<div>
<button class="btn btn-sm m-1" onclick="$('.tree').toggle()" style="float: left;">&lt;</button>
<button class="btn btn-sm m-1" onclick="toggleFullScreen()" style="float: left;">F</button>
<button class="btn btn-sm m-1" onclick="$('.tree').toggle()" style="float: left;" title="toggle filebrowser window">&lt;</button>
<button class="btn btn-sm m-1" onclick="toggleFullScreen()" style="float: left;" title="fullscreen">F</button>
<button type="button" class="btn btn-warning btn-sm m-1" style="float: left;display:none;" title="share workflow to friends">QR</button>
<ul class="nav nav-tabs" id="myTab" role="tablist" style="margin-left: 75px;">
<li class="nav-item">
Expand Down
8 changes: 6 additions & 2 deletions static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,12 @@ $(function(){
})
}($('.mct-restore'),$('#mct-restoreModal')));
// consoles menu
$('.mct-consoles').on('click',function(){ window.open('consoles.html','_blank') });
$('.mct-editor').on('click',function(){ window.open('editor','_blank') });
var wins = {};
function openWin(url, target) {
(wins[target] || ( wins[target] = window.open(url, target))).focus();
}
$('.mct-consoles').on('click',function(){ openWin('consoles.html', 'consoles') });
$('.mct-editor').on('click',function(){ openWin('editor', 'editor') });
// ports dropdown menu management
(function(ports){
function createPort(p){
Expand Down

0 comments on commit 4780699

Please sign in to comment.