Skip to content

Commit b1785cb

Browse files
committed
adding support to open-in-gimp
1 parent 70ccad7 commit b1785cb

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ exports.ids = {
1212
'noedpljikmfalclpadmnjbabbignpfge', // Open in IE (Opera)
1313
'ocnfecjfebnllnapjjoncgjnnkfmobjc', // Media Converter (Chrome)
1414
'fabccabfpmdadbhljpcmcbmepepfllnb', // Media Converter (Opera)
15+
'jgpghknlbaljigdhcjimjnkkjniiipmm', // Open in GIMP (Chrome)
16+
'cmjahocdpafkodabbojjaebogoigcipj', // Open in GIMP (Opera)
1517
],
1618
firefox: [
1719
'{5610edea-88c1-4370-b93d-86aa131971d1}', // Open in IE

host.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var https = lazyRequire('./follow-redirects').https;
2020
var server, files = [];
2121

2222
var config = {
23-
version: '0.1.6'
23+
version: '0.1.7'
2424
};
2525
// closing node when parent process is killed
2626
process.stdin.resume();
@@ -163,6 +163,7 @@ function observe (msg, push, done) {
163163
else {
164164
push({
165165
files,
166+
folders: files.filter(file => fs.statSync(path.join(msg.path, file)).isDirectory()),
166167
separator: path.sep
167168
});
168169
}
@@ -214,6 +215,48 @@ function observe (msg, push, done) {
214215
socket.on('timeout', () => request.abort());
215216
});
216217
}
218+
else if (msg.cmd === 'save-data') {
219+
let matches = msg.data.match(/^data:.+\/(.+);base64,(.*)$/);
220+
if (matches && matches.length) {
221+
let ext = matches[1];
222+
let data = matches[2];
223+
let buffer = new Buffer(data, 'base64');
224+
225+
fs.mkdtemp(os.tmpdir(), (err, folder) => {
226+
if (err) {
227+
push({
228+
error: err.message,
229+
code: 1007
230+
});
231+
done();
232+
}
233+
let file = path.join(folder, 'image.' + ext);
234+
fs.writeFile(file, buffer, (err) => {
235+
if (err) {
236+
push({
237+
error: err.message,
238+
code: 1006
239+
});
240+
done();
241+
}
242+
else {
243+
push({
244+
code: 0,
245+
file
246+
});
247+
done();
248+
}
249+
});
250+
});
251+
}
252+
else {
253+
push({
254+
error: 'cannot parse data-uri',
255+
code: 1005
256+
});
257+
done();
258+
}
259+
}
217260
else {
218261
push({
219262
error: 'cmd is unknown',

0 commit comments

Comments
 (0)