add ext: protocol
This commit is contained in:
parent
f3421c4bba
commit
fe030cb0e0
@ -3,6 +3,7 @@ var Tray = require('tray')
|
|||||||
var Menu = require('menu')
|
var Menu = require('menu')
|
||||||
var shell = require('shell')
|
var shell = require('shell')
|
||||||
var BrowserWindow = require('browser-window')
|
var BrowserWindow = require('browser-window')
|
||||||
|
|
||||||
var config = require('ssb-config')
|
var config = require('ssb-config')
|
||||||
|
|
||||||
// Report crashes to our server.
|
// Report crashes to our server.
|
||||||
@ -13,7 +14,10 @@ var mainWindow
|
|||||||
|
|
||||||
app.on('ready', function ready () {
|
app.on('ready', function ready () {
|
||||||
// start sbot
|
// start sbot
|
||||||
require('scuttlebot').init(config, function (err, sbot) {
|
require('scuttlebot').init(config, function (err, sbot) {
|
||||||
|
// register protocols
|
||||||
|
require('protocol').registerProtocol('ext', require('./lib/ext-protocol')(config))
|
||||||
|
|
||||||
// open the web app
|
// open the web app
|
||||||
// shell.openExternal('http://localhost:8008')
|
// shell.openExternal('http://localhost:8008')
|
||||||
mainWindow = new BrowserWindow({width: 1000, height: 720})
|
mainWindow = new BrowserWindow({width: 1000, height: 720})
|
||||||
|
14
app/lib/ext-protocol.js
Normal file
14
app/lib/ext-protocol.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
var protocol = require('protocol')
|
||||||
|
var path = require('path')
|
||||||
|
var toPath = require('multiblob/util').toPath
|
||||||
|
|
||||||
|
module.exports = function (config) {
|
||||||
|
var dir = path.join(config.path, 'blobs')
|
||||||
|
return function (request) {
|
||||||
|
var id = request.url.split(':')[1]
|
||||||
|
if (request.method == 'GET' && id) {
|
||||||
|
console.log('loading', id, toPath(dir, id))
|
||||||
|
return new protocol.RequestFileJob(toPath(dir, id))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -25,6 +25,7 @@
|
|||||||
"electron-prebuilt": "^0.28.2"
|
"electron-prebuilt": "^0.28.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"multiblob": "^1.4.3",
|
||||||
"scuttlebot": "^4.2.3",
|
"scuttlebot": "^4.2.3",
|
||||||
"ssb-config": "^1.0.3"
|
"ssb-config": "^1.0.3"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user