forked from ameba23/mmt-metadata
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head></head> | ||
<body> | ||
<script> | ||
// redirect console to main process | ||
var electron = require('electron') | ||
var localLog = console.log | ||
var localError = console.error | ||
var remoteLog = electron.remote.getGlobal('console').log | ||
var remoteError = electron.remote.getGlobal('console').error | ||
|
||
console.log = (...args) => { | ||
localLog.apply(console, args) | ||
remoteLog(...args) | ||
} | ||
|
||
console.error = (...args) => { | ||
localError.apply(console, args) | ||
remoteError(...args) | ||
} | ||
|
||
process.exit = electron.remote.app.quit | ||
// redirect errors to stderr | ||
window.addEventListener('error', (e) => { | ||
e.preventDefault() | ||
console.error(e.error.stack || 'Uncaught ' + e.error) | ||
}) | ||
</script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
const Config = require('ssb-config/inject') | ||
// const Config = require('ssb-config') | ||
const ssbKeys = require('ssb-keys') | ||
const Path = require('path') | ||
|
||
const appName = "ssb" // <<< NOTE THIS IS YOUR DEFAULT IDENTITY | ||
|
||
// const port = process.env.PORT || 8808 | ||
// | ||
// const opts = { | ||
// port: port | ||
// } | ||
const opts = null | ||
|
||
const config = Config(appName, opts) | ||
Object.assign(config, { | ||
appName, | ||
keys: ssbKeys.loadOrCreateSync(Path.join(config.path, 'secret')), | ||
|
||
}) | ||
|
||
// config.remote = `net:127.0.0.1:${config.port}~shs:${config.keys.id.slice(1).replace('.ed25519', '')}` | ||
|
||
module.exports = config | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const defaultMenu = require('electron-default-menu') | ||
|
||
const { | ||
app, | ||
Menu, | ||
shell | ||
} = require('electron') | ||
|
||
module.exports = function () { | ||
var menu = defaultMenu(app, shell) | ||
|
||
var view = menu.find(x => x.label === 'View') | ||
view.submenu = [ | ||
{ role: 'reload' }, | ||
{ role: 'toggledevtools' }, | ||
{ type: 'separator' }, | ||
{ role: 'resetzoom' }, | ||
{ role: 'zoomin' }, | ||
{ role: 'zoomout' }, | ||
{ type: 'separator' }, | ||
{ role: 'togglefullscreen' } | ||
] | ||
|
||
var win = menu.find(x => x.label === 'Window') | ||
win.submenu = [ | ||
{ role: 'minimize' }, | ||
{ role: 'zoom' }, | ||
{ role: 'close', label: 'Close Window', accelerator: 'CmdOrCtrl+Shift+W' }, | ||
{ type: 'separator' }, | ||
{ | ||
label: 'Close Tab', | ||
accelerator: 'CmdOrCtrl+W', | ||
click() { | ||
windows.main.webContents.send('closeTab') | ||
} | ||
}, | ||
{ | ||
label: 'Select Next Tab', | ||
accelerator: 'CmdOrCtrl+Shift+]', | ||
click() { | ||
windows.main.webContents.send('nextTab') | ||
} | ||
}, | ||
{ | ||
label: 'Select Previous Tab', | ||
accelerator: 'CmdOrCtrl+Shift+[', | ||
click() { | ||
windows.main.webContents.send('previousTab') | ||
} | ||
}, | ||
{ type: 'separator' }, | ||
{ role: 'front' } | ||
] | ||
|
||
return Menu.setApplicationMenu(Menu.buildFromTemplate(menu)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const extend = require('xtend') | ||
const { app, BrowserWindow } = require('electron') | ||
|
||
const Path = require('path') | ||
const url = require('url') | ||
|
||
module.exports = function (path, opts) { | ||
var icon = process.platform !== 'darwin' | ||
? Path.join(__dirname, '..', 'assets', 'icon.png') | ||
: Path.join(__dirname, '..', 'assets', 'icon.icns') | ||
|
||
var win = new BrowserWindow( | ||
extend(opts, { | ||
icon: icon | ||
}) | ||
) | ||
|
||
win.webContents.on('dom-ready', () => { | ||
win.webContents.executeJavaScript(` | ||
var electron = require('electron') | ||
electron.webFrame.setZoomLevelLimits(1, 1) | ||
var title = ${JSON.stringify(opts.title || 'Application')} | ||
var head = document.documentElement.querySelector('head') | ||
var element = document.createElement('title') | ||
element.innerHTML = title | ||
head.appendChild(element) | ||
require(${JSON.stringify(path)}) | ||
`) | ||
}) | ||
|
||
win.loadURL(url.format({ | ||
pathname: Path.join(__dirname, '..', '..','assets', 'base.html'), | ||
protocol: 'file:', | ||
slashes: true | ||
})) | ||
|
||
return win | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const Server = require('scuttlebot') | ||
const config = require('./config') | ||
|
||
const fs = require('fs') | ||
const Path = require('path') | ||
|
||
// Install the plugin | ||
Server | ||
.use(require('scuttlebot/plugins/master')) // required | ||
// .use(require('ssb-about')) | ||
.use(require('ssb-private')) | ||
// .use(require('ssb-backlinks')) // not required, just an example | ||
|
||
// Start the server | ||
const server = Server(config) | ||
|
||
const manifest = server.getManifest() | ||
fs.writeFileSync(Path.join(config.path, 'manifest.json'), JSON.stringify(manifest)) |