Skip to content

Commit 4780699

Browse files
committed
added editor, updated libraries, upnp fixes
1 parent 15e10a8 commit 4780699

File tree

12 files changed

+80
-37
lines changed

12 files changed

+80
-37
lines changed

.DS_Store

-8 KB
Binary file not shown.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ bower_components
4141
**/test
4242
package-lock.json
4343
unused
44+
.DS_Store

HACKS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,11 @@ nat-upnp/lib/nat-upnp/client.js
22
@@ -119,3 +119,3 @@
33
- protocol: data.NewProtocol.toLowerCase(),
44
+ protocol: (data.NewProtocol || '').toLowerCase(),
5+
6+
used updated version from:
7+
https://github.com/MelvinTo/node-nat-upnp
8+
9+
cd node_modules/ot
10+
npm i
11+
node_modules/.bin/grunt --force
12+
rm -r node_modules

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ supported OS: Linux,Mac,Windows
1010
* quick help for Marlin options and G-codes
1111
* compilation and uploading your customized firmware
1212
* console for access to serial ports
13+
* **collaborative editor for whole project**
1314
* share your configuration on [the site](http://lt.rv.ua/mc)
15+
* **automatical installer for PlatformIO**
1416
# Features:
1517
* automatically clone repository from [Marlin github](https://github.com/MarlinFirmware/Marlin) if you don't have it
1618
* instant changing of Configuration*.h files

app/services/editor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ router.post('/upload/*', function(req, res) {
9393
//git file TODO: git for multiproject
9494
router.get('/git/*', function(req, res) {
9595
git.Tag()
96-
.then(tag => git.Show(tag, req.originalUrl.replace(/.*git\//, '')))
96+
.then(tag => git.Show(tag, req.originalUrl.replace(/.*git\//, '')).catch(a=>''))
9797
.catch(e => res.status(501).send(e.message))
9898
.then(data => res.send(data))
9999
})

package.json

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "marlin-conf",
3-
"version": "2.9.1",
3+
"version": "2.10.1",
44
"description": "configuration tool for Marlin project",
55
"main": "./index.js",
66
"scripts": {
@@ -11,7 +11,7 @@
1111
"test": "echo \"Error: no test specified\" && exit 1",
1212
"lint": "eslint .",
1313
"rebuild": "npm rebuild serialport --update-binary",
14-
"prepublish": "./node_modules/.bin/json -I -f package.json -e 'if(this.devDependencies)this.devDependenciesOff=this.devDependencies;this.devDependencies=undefined'",
14+
"prepublishOnly": "./node_modules/.bin/json -I -f package.json -e 'if(this.devDependencies)this.devDependenciesOff=this.devDependencies;this.devDependencies=undefined'",
1515
"postpublish": "./node_modules/.bin/json -I -f package.json -e 'if(this.devDependenciesOff)this.devDependencies=this.devDependenciesOff;this.devDependenciesOff=undefined'",
1616
"prebuild-": "sudo apt install icnsutils graphicsmagick"
1717
},
@@ -57,50 +57,51 @@
5757
"homepage": "https://github.com/akaJes/marlin-config#readme",
5858
"dependencies": {
5959
"ace-builds": "^1.3.3",
60-
"body-parser": "^1.17.2",
60+
"body-parser": "^1.18.3",
6161
"bootstrap": "4.0.0-alpha.6",
62-
"cropper": "^3.1.5",
62+
"cropper": "^3.1.6",
6363
"data-store": "^1.0.0",
64-
"diff-match-patch": "^1.0.0",
65-
"express": "^4.16.2",
64+
"diff-match-patch": "^1.0.1",
65+
"electron-debug": "^1.5.0",
66+
"express": "^4.16.3",
6667
"fix-path": "^2.1.0",
6768
"font-awesome": "^4.7.0",
6869
"form-data": "^2.3.2",
69-
"formidable": "^1.1.1",
70+
"formidable": "^1.2.1",
7071
"get-port": "^3.1.0",
7172
"highlight.js": "^9.11.0",
7273
"jquery": "^3.3.1",
7374
"jquery-ui-dist": "^1.12.1",
74-
"js-yaml": "^3.8.4",
75+
"js-yaml": "^3.11.0",
7576
"jstree": "^3.3.5",
76-
"marked": "^0.3.16",
77+
"marked": "^0.3.19",
7778
"mkdirp": "^0.5.1",
78-
"moment": "^2.20.1",
79-
"nat-upnp": "^1.1.1",
79+
"moment": "^2.22.1",
80+
"nat-upnp": "git+https://github.com/MelvinTo/node-nat-upnp.git",
8081
"node-machine-id": "^1.1.10",
8182
"node-notifier": "^5.2.1",
82-
"opn": "^5.2.0",
83+
"opn": "^5.3.0",
8384
"ot": "git+https://github.com/Operational-Transformation/ot.js.git",
8485
"platformio-node-helpers": "^0.4.3",
8586
"qr-image": "^3.2.0",
8687
"rtcmulticonnection-v3": "^3.4.4",
87-
"serialport": "^6.1.0",
88-
"simple-git": "^1.91.0",
89-
"socket.io": "^2.0.4",
88+
"serialport": "^6.2.0",
89+
"simple-git": "^1.92.0",
90+
"socket.io": "^2.1.1",
9091
"swig-templates": "^2.0.2",
91-
"tether": "^1.4.3",
92+
"tether": "^1.4.4",
9293
"tmp": "0.0.33",
9394
"tty2html": "^1.0.0",
9495
"universal-analytics": "^0.4.16",
96+
"vex-js": "^4.1.0",
9597
"which": "^1.2.14",
9698
"yauzl": "^2.9.1",
9799
"yazl": "^2.4.3"
98100
},
99101
"devDependencies": {
100102
"devtron": "^1.4.0",
101-
"electron": "=1.7.10",
102-
"electron-builder": "^20.2.0",
103-
"electron-debug": "^1.5.0",
103+
"electron": "latest",
104+
"electron-builder": "latest",
104105
"eslint": "^4.18.1",
105106
"json": "^9.0.6",
106107
"nodemon": "^1.15.1"

static/editor/diff.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ ace.define("diff", function(require, exports, module) {
1414
function DMP(editor) {
1515
this.editor = editor;
1616
var self = this;
17+
var dc = debounce(scan, 500, self)
1718
this.onChange = function(obj, editor) {
18-
self.scan();
19+
dc(); //self.scan();
1920
}
2021
this.updateAnnotations = function(session) {
2122
self.editor.renderer.setAnnotations((session.$annotations || []).concat(session.diffAnnotations || []))
@@ -96,7 +97,8 @@ ace.define("diff", function(require, exports, module) {
9697
}
9798
return seek(-1).concat(quote(diffs[pos][1], diffs[pos][0]), seek(1));
9899
}
99-
this.scan = function() {
100+
this.scan = scan;
101+
function scan() {
100102
var session = this.editor.getSession();
101103
session.diffAnnotations = [];
102104
var markers = session.getMarkers();

static/editor/editor.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* editor*/
2-
.added-gutter { background: #00AA0055; }
3-
.changed-gutter { background: #AA000055; }
4-
.changed-text { background: #AA000025; position:absolute; z-index:2;}
5-
.added-text { background: #00AA0025; position:absolute; z-index:2;}
2+
.added-gutter { background-color: rgba(0,170,0,.33); }
3+
.changed-gutter { background-color: rgba(170,0,0,.33); }
4+
.changed-text { background-color: rgba(170,0,0,.14); position:absolute; z-index:2;}
5+
.added-text { background-color: rgba(0,170,0,.14); position:absolute; z-index:2;}
66
.ace_gutter-cell { background-repeat: no-repeat; }
77
/* layout */
88
html, body {

static/editor/editor.js

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ var myName;
22
var otI;
33
var state;
44
function createFileUploader(element, tree, editor) {
5-
function addButton(name,fn){
6-
$(element).append($('<button>').addClass('btn btn-sm m-1').text(name).on('click',fn));
5+
function addButton(name, fn, title) {
6+
$(element).append($('<button>').addClass('btn btn-sm m-1').text(name).on('click', fn).attr('title', title));
77
}
88
// addButton('<<',function(e){ $('.jstree').toggle(); });
99
// addButton('A',function(e){ toggleFullScreen(); });
1010
// addButton('Save',function(e){ editor.execCommand("saveCommand") });
11-
addButton('next',function(e){ editor.execCommand("nextDiff") });
12-
addButton('prev',function(e){ editor.execCommand("prevDiff") });
11+
addButton('next',function(e){ editor.execCommand("nextDiff") }, 'seek for next diff');
12+
addButton('prev',function(e){ editor.execCommand("prevDiff") }, 'seek for previous diff');
1313
addButton('{}', function(e) {
1414
if (!editor.getSelectedText()) return;
1515
var beautify = ace.require("ace/ext/beautify"); // get reference to extension
@@ -22,10 +22,29 @@ var state;
2222
session.setValue(val);
2323
beautify.beautify(session);
2424
var b = session.getValue();
25+
var space = val.match(/^\s+/);
26+
if (space)
27+
b = b.split(/\r\n?|\n/).map(function(line){ return space[0] + line;}).join('\n');
2528
editor.session.doc.replace(range, b);
2629
editor._signal("change", {});
27-
});
28-
addButton('NAME',function(e){ myName = prompt('Tell Ur Name!!!'); otI.setName(myName); });
30+
}, 'beauitify JS code');
31+
addButton('NAME',function(e){
32+
if(isElectron()) {
33+
var d = vex.dialog.prompt({
34+
message: 'Tell Ur Name!!!',
35+
placeholder: 'name',
36+
callback: function (value) {
37+
if(value)
38+
otI.setName(myName = value);
39+
}
40+
})
41+
$(d.contentEl).find('input').val(myName);
42+
} else {
43+
var value = prompt('Tell Ur Name!!!', myName);
44+
if(value)
45+
otI.setName(myName = value);
46+
}
47+
}, 'set Your name for collaborative editing');
2948
addButton('undo',function(e){ editor.getSession().getUndoManager().undo(false); });
3049
$(element).append(state = $('<span class="m-1">Loading...</span>'));
3150
}
@@ -180,7 +199,7 @@ if(0)
180199
}
181200

182201
$(function(){
183-
$(window).on('beforeunload',function() { return "Realy?"; });
202+
// $(window).on('beforeunload',function() { return "Realy?"; });
184203
var vars = {};
185204
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { vars[key] = value; });
186205
var editor = createEditor("editor", vars.file, vars.lang, vars.theme);

static/editor/helpers.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ function toggleFullScreen() {
2323
cancelFullScreen.call(doc);
2424
}
2525
}
26+
function isElectron() {
27+
return navigator.userAgent.toLowerCase().indexOf(' electron/') >= 0;
28+
}

0 commit comments

Comments
 (0)