Skip to content

Commit a0c5104

Browse files
committed
p3x-robot sunday release 2017-7-1 13:16:51
1 parent e500e11 commit a0c5104

File tree

8 files changed

+268
-271
lines changed

8 files changed

+268
-271
lines changed

.scrutinizer.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ filter:
99

1010
build:
1111
environment:
12-
node: 8.1.0
1312
variables:
1413
CXX: g++-4.8
1514

15+
1616
dependencies:
1717
before:
18+
- export LATEST=$(nvm ls-remote | tail -1)
19+
- nvm install $LATEST
20+
# - nvm use $LATEST dependencies:
1821
- sudo apt-get -y install software-properties-common python-software-properties
1922
# - sudo apt-cache policy gcc++
2023
# - sudo apt-cache policy g++

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This is an open source project. Just code.
1818

1919
### Built on Node
2020
```
21-
v8.1.2
21+
v8.1.3
2222
```
2323

2424
The ```async``` and ```await``` keywords are required.
@@ -65,9 +65,9 @@ After last startup and you logout and login again, you will have a menu.
6565
[//]: #@corifeus-footer
6666

6767
---
68-
[**P3X-ONENOTE**](https://pages.corifeus.tk/onenote) Build v1.0.131-32
6968

70-
[Corifeus](http://www.corifeus.tk) by [Patrik Laszlo](http://patrikx3.tk)
69+
[**P3X-ONENOTE**](https://pages.corifeus.tk/onenote) Build v1.0.137-43
7170

71+
[Corifeus](http://www.corifeus.tk) by [Patrik Laszlo](http://patrikx3.tk)
7272

7373
[//]: #@corifeus-footer:end

bin/p3x-onenote.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Terminal=false
2626
await mz.fs.chmod(desktopEntry , '0755');
2727
await utils.childProcess.exec('gtk-update-icon-cache || true');
2828
}
29-
await utils.childProcess.exec(`${__dirname}/../node_modules/.bin/electron ${__dirname}/../src/electron/main.js`, true);
29+
await utils.childProcess.exec(`${__dirname}/../node_modules/.bin/electron ${__dirname}/../src/electron/app.js`, true);
3030
}
3131

3232
start();

onenote.iml

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
<module type="WEB_MODULE" version="4">
33
<component name="NewModuleRootManager" inherit-compiler-output="true">
44
<exclude-output />
5-
<content url="file://$MODULE_DIR$" />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
<sourceFolder url="file://$MODULE_DIR$/bin" isTestSource="false" />
8+
<sourceFolder url="file://$MODULE_DIR$/artifacts" type="java-resource" />
9+
</content>
610
<orderEntry type="inheritedJdk" />
711
<orderEntry type="sourceFolder" forTests="false" />
812
</component>

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "p3x-onenote",
3-
"version": "1.0.131-32",
3+
"version": "1.0.137-43",
44
"description": "P3X Onenote Linux",
55
"main": "src/electron/main.js",
66
"corifeus": {
@@ -32,12 +32,12 @@
3232
"homepage": "https://pages.corifeus.tk/onenote",
3333
"dependencies": {
3434
"configstore": "^3.1.0",
35-
"corifeus-utils": "^1.1.338-32",
35+
"corifeus-utils": "^1.1.346-40",
3636
"electron": "^1.6.11"
3737
},
3838
"devDependencies": {
39-
"corifeus-builder": "^1.7.669-24",
40-
"electron-builder": "^19.8.0"
39+
"corifeus-builder": "^1.7.685-33",
40+
"electron-builder": "^19.11.1"
4141
},
4242
"engines": {
4343
"node": ">=7.8.0"

src/electron/app.js

+250
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
const electron = require('electron');
2+
const { app, Menu, Tray, shell} = require('electron')
3+
const ipc = electron.ipcMain;
4+
let tray;
5+
let mainWindow;
6+
const iconFile = `${__dirname}/images/256x256.png`;
7+
8+
const title = 'P3X OneNote';
9+
10+
11+
const BrowserWindow = electron.BrowserWindow;
12+
const configstore = require('configstore');
13+
const pkg = require('../../package.json');
14+
const conf = new configstore(pkg.name);
15+
16+
17+
const action = {
18+
restart: () => {
19+
mainWindow.webContents.send('action', {
20+
action: 'restart'
21+
})
22+
},
23+
home: () => {
24+
mainWindow.show();
25+
mainWindow.webContents.send('action', {
26+
action: 'home'
27+
})
28+
},
29+
toggleVisible: () => {
30+
if (mainWindow === undefined) {
31+
return;
32+
}
33+
setVisible(!mainWindow.isVisible());
34+
},
35+
quit: function () {
36+
app.isQuiting = true;
37+
app.quit();
38+
},
39+
github: () => {
40+
shell.openExternal('https://github.com/patrikx3/onenote')
41+
},
42+
patrik: () => {
43+
shell.openExternal('https://patrikx3.tk')
44+
},
45+
p3x: () => {
46+
shell.openExternal('https://github.com/patrikx3')
47+
},
48+
corifeus: () => {
49+
shell.openExternal('https://corifeus.tk')
50+
},
51+
npm: () => {
52+
shell.openExternal('https://www.npmjs.com/~patrikx3')
53+
},
54+
download: () => {
55+
shell.openExternal('https://github.com/patrikx3/onenote/releases')
56+
},
57+
}
58+
59+
const menus = {
60+
default: () => {
61+
62+
let visible = false;
63+
if (mainWindow !== undefined) {
64+
visible = mainWindow.isVisible() ? true : false;
65+
}
66+
return [
67+
{
68+
label: 'Home',
69+
click: action.home
70+
},
71+
{
72+
label: 'Restart / Logout',
73+
tooltip: 'You logout and can login again',
74+
click: action.restart
75+
},
76+
{
77+
label: visible ? 'Hide' : 'Show',
78+
click: action.toggleVisible
79+
},
80+
{
81+
label: 'Download',
82+
click: action.download
83+
},
84+
{
85+
label: 'Quit',
86+
click: action.quit
87+
}
88+
]
89+
}
90+
}
91+
92+
function createMenu() {
93+
const template = [
94+
{
95+
label: title,
96+
submenu: menus.default(),
97+
},
98+
{
99+
label: 'Edit',
100+
submenu: [
101+
{role: 'undo'},
102+
{role: 'redo'},
103+
{type: 'separator'},
104+
{role: 'cut'},
105+
{role: 'copy'},
106+
{role: 'paste'},
107+
{role: 'pasteandmatchstyle'},
108+
{role: 'delete'},
109+
{role: 'selectall'}
110+
]
111+
},
112+
{
113+
label: 'View',
114+
submenu: [
115+
{role: 'reload'},
116+
{role: 'forcereload'},
117+
{role: 'toggledevtools'},
118+
{type: 'separator'},
119+
{role: 'resetzoom'},
120+
{role: 'zoomin'},
121+
{role: 'zoomout'},
122+
{type: 'separator'},
123+
{role: 'togglefullscreen'}
124+
]
125+
},
126+
{
127+
role: 'help',
128+
submenu: [
129+
{
130+
label: 'Download',
131+
click: action.download
132+
},
133+
{
134+
label: 'GitHub',
135+
click: action.github
136+
},
137+
{
138+
label: 'Patrik Laszlo',
139+
click: action.patrik
140+
},
141+
{
142+
label: 'P3X',
143+
click: action.p3x
144+
},
145+
{
146+
label: 'Corifeus',
147+
click: action.corifeus
148+
},
149+
{
150+
label: 'Npm',
151+
click: action.npm
152+
},
153+
]
154+
}
155+
]
156+
157+
const menu = Menu.buildFromTemplate(template)
158+
Menu.setApplicationMenu(menu)
159+
}
160+
161+
function createTray() {
162+
if (tray === undefined) {
163+
tray = new Tray(iconFile)
164+
tray.setToolTip(title)
165+
tray.on('click', action.toggleVisible)
166+
}
167+
const contextMenu = Menu.buildFromTemplate(menus.default())
168+
tray.setContextMenu(contextMenu)
169+
}
170+
171+
function setVisible(visible = true) {
172+
if (visible === null) {
173+
visible = true;
174+
}
175+
if (mainWindow !== undefined) {
176+
if (visible) {
177+
mainWindow.show();
178+
} else {
179+
mainWindow.hide();
180+
}
181+
}
182+
conf.set('visible', visible);
183+
createMenu();
184+
createTray()
185+
}
186+
187+
188+
function createWindow() {
189+
190+
mainWindow = new BrowserWindow({
191+
icon: iconFile,
192+
toolbar: false,
193+
});
194+
195+
196+
setVisible(conf.get('visible'));
197+
198+
mainWindow.loadURL('file://' + __dirname + '/index.html');
199+
200+
mainWindow.on('minimize', function (event) {
201+
event.preventDefault()
202+
setVisible(false);
203+
});
204+
205+
mainWindow.on('close', function (event) {
206+
if (!app.isQuiting) {
207+
event.preventDefault()
208+
setVisible(false);
209+
}
210+
return false;
211+
});
212+
213+
const windowBounds = conf.get('windowBounds');
214+
if (windowBounds !== null && windowBounds !== undefined) {
215+
mainWindow.setBounds(windowBounds);
216+
}
217+
218+
219+
220+
}
221+
ipc.on('did-finish-load', function () {
222+
const hostData = conf.get('toHost');
223+
// console.log('Loading data', hostData);
224+
if (hostData !== undefined && hostData !== null) {
225+
mainWindow.webContents.send('onload-user', hostData);
226+
}
227+
});
228+
229+
ipc.on('save', function (event, data) {
230+
// console.log('Save', data)
231+
conf.set('toHost', data);
232+
conf.set('windowBounds', mainWindow.getBounds());
233+
})
234+
235+
app.on('ready', createWindow);
236+
237+
app.on('window-all-closed', function () {
238+
239+
if (process.platform !== 'darwin') {
240+
app.quit();
241+
}
242+
});
243+
244+
app.on('activate', function () {
245+
if (mainWindow === null) {
246+
createWindow();
247+
}
248+
});
249+
250+

src/electron/js/preload.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ window.electronWindowSetup = function() {
4949

5050
const webview = document.getElementById("p3x-onenote-webview");
5151
webview.addEventListener('did-stop-loading', function(event) {
52-
webview.insertCSS(window.cssData);
52+
// webview.insertCSS(window.cssData);
5353
});
5454

5555
webview.addEventListener('did-navigate', function(event, url) {

0 commit comments

Comments
 (0)