git ssb

2+

mixmix / ticktack



Commit ce533dbe10ead70d29fbc1c92fa3d02700125aac

trying to build from ticktack-builder (electron entry needs to be index.js?)

Matt McKegg committed on 8/14/2017, 5:02:31 AM
Parent: 8737709db876420b4db1aea9a323d248fd75fe20

Files changed

index.jschanged
main.jschanged
package.jsonchanged
electron.jsdeleted
index.jsView
@@ -1,9 +1,135 @@
1-const ticktack = {
2- app: require('./app'),
3- blob: require('./blob'),
4- config: require('./config'),
5- router: require('./router'),
6- styles: require('./styles')
1+var defaultMenu = require('electron-default-menu')
2+var WindowState = require('electron-window-state')
3+var electron = require('electron')
4+var Menu = electron.Menu
5+var Path = require('path')
6+
7+var windows = {}
8+var quitting = false
9+
10+electron.app.on('ready', () => {
11+ var menu = defaultMenu(electron.app, electron.shell)
12+ var view = menu.find(x => x.label === 'View')
13+ view.submenu = [
14+ { role: 'reload' },
15+ { role: 'toggledevtools' },
16+ { type: 'separator' },
17+ { role: 'resetzoom' },
18+ { role: 'zoomin' },
19+ { role: 'zoomout' },
20+ { type: 'separator' },
21+ { role: 'togglefullscreen' }
22+ ]
23+ if (process.platform === 'darwin') {
24+ var win = menu.find(x => x.label === 'Window')
25+ win.submenu = [
26+ { role: 'minimize' },
27+ { role: 'zoom' },
28+ { role: 'close', label: 'Close' },
29+ { type: 'separator' },
30+ { role: 'front' }
31+ ]
32+ }
33+
34+ Menu.setApplicationMenu(Menu.buildFromTemplate(menu))
35+
36+ startBackgroundProcess()
37+
38+ // wait until server has started before opening main window
39+ electron.ipcMain.once('server-started', function (ev, config) {
40+ openMainWindow()
41+ })
42+
43+ electron.app.on('before-quit', function () {
44+ quitting = true
45+ })
46+
47+ // allow inspecting of background process
48+ electron.ipcMain.on('open-background-devtools', function (ev, config) {
49+ if (windows.background) {
50+ windows.background.webContents.openDevTools({detach: true})
51+ }
52+ })
53+})
54+
55+function startBackgroundProcess () {
56+ if (!windows.background) {
57+ windows.background = openWindow(Path.join(__dirname, 'background-process.js'), {
58+ connect: false,
59+ center: true,
60+ fullscreen: false,
61+ fullscreenable: false,
62+ height: 150,
63+ maximizable: false,
64+ minimizable: false,
65+ resizable: false,
66+ show: false,
67+ skipTaskbar: true,
68+ title: 'ticktack-server',
69+ useContentSize: true,
70+ width: 150
71+ })
72+ }
773 }
874
9-module.exports = ticktack
75+function openMainWindow () {
76+ if (!windows.main) {
77+ var windowState = WindowState({
78+ defaultWidth: 1024,
79+ defaultHeight: 768
80+ })
81+ windows.main = openWindow(Path.join(__dirname, 'main.js'), {
82+ minWidth: 800,
83+ x: windowState.x,
84+ y: windowState.y,
85+ width: windowState.width,
86+ height: windowState.height,
87+ autoHideMenuBar: true,
88+ title: 'Ticktack',
89+ show: true,
90+ backgroundColor: '#EEE',
91+ icon: './assets/icon.png'
92+ })
93+ windowState.manage(windows.main)
94+ windows.main.setSheetOffset(40)
95+ windows.main.on('close', function (e) {
96+ if (!quitting && process.platform === 'darwin') {
97+ e.preventDefault()
98+ windows.main.hide()
99+ }
100+ })
101+ windows.main.on('closed', function () {
102+ windows.main = null
103+ if (process.platform !== 'darwin') electron.app.quit()
104+ })
105+ }
106+}
107+
108+function openWindow (path, opts) {
109+ var window = new electron.BrowserWindow(opts)
110+ window.webContents.on('dom-ready', function () {
111+ window.webContents.executeJavaScript(`
112+ var electron = require('electron')
113+ var h = require('mutant/h')
114+ electron.webFrame.setZoomLevelLimits(1, 1)
115+ var title = ${JSON.stringify(opts.title || 'Ticktack')}
116+ document.documentElement.querySelector('head').appendChild(
117+ h('title', title)
118+ )
119+ require(${JSON.stringify(path)})
120+ `)
121+ })
122+
123+ window.webContents.on('will-navigate', function (e, url) {
124+ e.preventDefault()
125+ electron.shell.openExternal(url)
126+ })
127+
128+ window.webContents.on('new-window', function (e, url) {
129+ e.preventDefault()
130+ electron.shell.openExternal(url)
131+ })
132+
133+ window.loadURL('file://' + Path.join(__dirname, 'assets', 'base.html'))
134+ return window
135+}
main.jsView
@@ -9,9 +9,15 @@
99 require('./context-menu')
1010
1111 // from more specialized to more general
1212 const sockets = combine(
13- require('./'),
13+ {
14+ app: require('./app'),
15+ blob: require('./blob'),
16+ config: require('./config'),
17+ router: require('./router'),
18+ styles: require('./styles')
19+ },
1420 require('patch-history'),
1521 require('patchcore')
1622 )
1723
package.jsonView
@@ -4,9 +4,9 @@
44 "description": "",
55 "main": "index.js",
66 "scripts": {
77 "rebuild": "cross-script npm rebuild --runtime=electron \"--target=$(electron -v)\" \"--abi=$(electron --abi)\" --disturl=https://atom.io/download/atom-shell",
8- "start": "electron electron.js",
8+ "start": "electron .",
99 "postinstall": "npm run rebuild",
1010 "test": "echo \"Error: no test specified\" && exit 1"
1111 },
1212 "repository": {
electron.jsView
@@ -1,135 +1,0 @@
1-var defaultMenu = require('electron-default-menu')
2-var WindowState = require('electron-window-state')
3-var electron = require('electron')
4-var Menu = electron.Menu
5-var Path = require('path')
6-
7-var windows = {}
8-var quitting = false
9-
10-electron.app.on('ready', () => {
11- var menu = defaultMenu(electron.app, electron.shell)
12- var view = menu.find(x => x.label === 'View')
13- view.submenu = [
14- { role: 'reload' },
15- { role: 'toggledevtools' },
16- { type: 'separator' },
17- { role: 'resetzoom' },
18- { role: 'zoomin' },
19- { role: 'zoomout' },
20- { type: 'separator' },
21- { role: 'togglefullscreen' }
22- ]
23- if (process.platform === 'darwin') {
24- var win = menu.find(x => x.label === 'Window')
25- win.submenu = [
26- { role: 'minimize' },
27- { role: 'zoom' },
28- { role: 'close', label: 'Close' },
29- { type: 'separator' },
30- { role: 'front' }
31- ]
32- }
33-
34- Menu.setApplicationMenu(Menu.buildFromTemplate(menu))
35-
36- startBackgroundProcess()
37-
38- // wait until server has started before opening main window
39- electron.ipcMain.once('server-started', function (ev, config) {
40- openMainWindow()
41- })
42-
43- electron.app.on('before-quit', function () {
44- quitting = true
45- })
46-
47- // allow inspecting of background process
48- electron.ipcMain.on('open-background-devtools', function (ev, config) {
49- if (windows.background) {
50- windows.background.webContents.openDevTools({detach: true})
51- }
52- })
53-})
54-
55-function startBackgroundProcess () {
56- if (!windows.background) {
57- windows.background = openWindow(Path.join(__dirname, 'background-process.js'), {
58- connect: false,
59- center: true,
60- fullscreen: false,
61- fullscreenable: false,
62- height: 150,
63- maximizable: false,
64- minimizable: false,
65- resizable: false,
66- show: false,
67- skipTaskbar: true,
68- title: 'ticktack-server',
69- useContentSize: true,
70- width: 150
71- })
72- }
73-}
74-
75-function openMainWindow () {
76- if (!windows.main) {
77- var windowState = WindowState({
78- defaultWidth: 1024,
79- defaultHeight: 768
80- })
81- windows.main = openWindow(Path.join(__dirname, 'main.js'), {
82- minWidth: 800,
83- x: windowState.x,
84- y: windowState.y,
85- width: windowState.width,
86- height: windowState.height,
87- autoHideMenuBar: true,
88- title: 'Ticktack',
89- show: true,
90- backgroundColor: '#EEE',
91- icon: './assets/icon.png'
92- })
93- windowState.manage(windows.main)
94- windows.main.setSheetOffset(40)
95- windows.main.on('close', function (e) {
96- if (!quitting && process.platform === 'darwin') {
97- e.preventDefault()
98- windows.main.hide()
99- }
100- })
101- windows.main.on('closed', function () {
102- windows.main = null
103- if (process.platform !== 'darwin') electron.app.quit()
104- })
105- }
106-}
107-
108-function openWindow (path, opts) {
109- var window = new electron.BrowserWindow(opts)
110- window.webContents.on('dom-ready', function () {
111- window.webContents.executeJavaScript(`
112- var electron = require('electron')
113- var h = require('mutant/h')
114- electron.webFrame.setZoomLevelLimits(1, 1)
115- var title = ${JSON.stringify(opts.title || 'Ticktack')}
116- document.documentElement.querySelector('head').appendChild(
117- h('title', title)
118- )
119- require(${JSON.stringify(path)})
120- `)
121- })
122-
123- window.webContents.on('will-navigate', function (e, url) {
124- e.preventDefault()
125- electron.shell.openExternal(url)
126- })
127-
128- window.webContents.on('new-window', function (e, url) {
129- e.preventDefault()
130- electron.shell.openExternal(url)
131- })
132-
133- window.loadURL('file://' + Path.join(__dirname, 'assets', 'base.html'))
134- return window
135-}

Built with git-ssb-web