Skip to content

Commit 906e9c8

Browse files
committed
added option to open app via url and fixed css
1 parent c0e704c commit 906e9c8

File tree

4 files changed

+53
-11
lines changed

4 files changed

+53
-11
lines changed

assets/style.css

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@ main {
22
margin-left: 255px;
33
}
44

5+
/*body header {
6+
height: 60px;
7+
}
8+
body header .navbar-fixed{
9+
height: 60px;
10+
}
11+
12+
.navbar-fixed .top-nav {
13+
height: 60px;
14+
}*/
15+
516
webview {
617
display:inline-flex;
718
min-width:100%;
8-
min-height:91%;
19+
min-height:90%;
920
}
1021

1122
.side-nav .search input {

bootstrap.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ let container = document.getElementById('container')
5252
// and keep a reference for communicating with the app
5353
let devination = Elm.Main.fullscreen();
5454

55-
ipcRenderer.on('external-link' , function(event , data){ console.log(data.msg) });
55+
ipcRenderer.on('external-link', function(event , data) {
56+
console.log(data);
57+
devination.ports.externalSearch(data);
58+
});
5659

5760
devination.ports.showError.subscribe(function (error) {
5861
dialog.showMessageBox({ type: 'info', buttons: ['Report', 'Cancel'], message: "An error has occured: " + error }, function (buttonIndex) { });

main.js

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,38 @@ const WebContents = electron.WebContents
88
// Open devtools with F12
99
const remote = electron.remote;
1010
const {ipcMain} = require('electron')
11+
var exec = require('child_process').exec;
1112

1213
// Keep a global reference of the window object, if you don't, the window will
1314
// be closed automatically when the JavaScript object is garbage collected.
1415
let win;
1516

16-
app.setAsDefaultProtocolClient('devination')
17-
18-
app.on('open-url', function (event, url) {
19-
if(win)
20-
{
21-
win.webContents.send('external-link' , {msg: url});
17+
var shouldQuit = app.makeSingleInstance(function(commandLine, workingDirectory) {
18+
// Someone tried to run a second instance, we should focus our window
19+
if (win) {
20+
if (win.isMinimized()) win.restore();
21+
win.focus();
2222
}
23+
return true;
2324
});
2425

26+
if (shouldQuit) {
27+
app.quit();
28+
return;
29+
}
30+
31+
app.setAsDefaultProtocolClient('devination');
32+
33+
if(os.platform() == "linux") {
34+
var execute = function(command, callback){
35+
exec(command, function(error, stdout, stderr){ callback(stdout); });
36+
};
37+
38+
execute('xdg-mime default devination-app.desktop x-scheme-handler/devination', function(output) {
39+
console.log(output);
40+
});
41+
}
42+
2543
function createWindow() {
2644
// Create the browser window.
2745
win = new BrowserWindow({ width: 1400, height: 900, frame: false });
@@ -40,7 +58,16 @@ function createWindow() {
4058
app.on('uncaughtException', function (error) {
4159
dialog.showMessageBox({ type: 'info', buttons: ['Report', 'Cancel'], message: "An error has occured: " + error }, function (buttonIndex) { });
4260
});
43-
61+
62+
app.on('open-url', function (event, url) {
63+
event.preventDefault();
64+
app.quit();
65+
win.webContents.send('external-link', {msg: url});
66+
});
67+
app.on('open-file', function (event, url) {
68+
event.preventDefault();
69+
win.webContents.send('external-link', {msg: url});
70+
});
4471

4572
new AppUpdater(win)
4673

@@ -60,6 +87,7 @@ function createWindow() {
6087
// Some APIs can only be used after this event occurs.
6188
app.on('ready', createWindow);
6289

90+
6391
// Quit when all windows are closed.
6492
app.on('window-all-closed', () => {
6593
// On macOS it is common for applications and their menu bar

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "devination",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "a cross plattform offline documentation browser",
55
"productName": "devination",
66
"main": "main.js",
@@ -35,7 +35,7 @@
3535
"chokidar": "^1.6.1",
3636
"chokidar-cli": "^1.2.0",
3737
"electron": "^1.4.13",
38-
"electron-builder": "^10.13.1",
38+
"electron-builder": "^10.15.1",
3939
"electron-packager": "^8.4.0",
4040
"electron-rebuild": "^1.4.0",
4141
"electron-settings": "^2.2.2"

0 commit comments

Comments
 (0)