Skip to content

Commit

Permalink
added option to open app via url and fixed css
Browse files Browse the repository at this point in the history
  • Loading branch information
JorisM committed Dec 30, 2016
1 parent c0e704c commit 906e9c8
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 11 deletions.
13 changes: 12 additions & 1 deletion assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@ main {
margin-left: 255px;
}

/*body header {
height: 60px;
}
body header .navbar-fixed{
height: 60px;
}
.navbar-fixed .top-nav {
height: 60px;
}*/

webview {
display:inline-flex;
min-width:100%;
min-height:91%;
min-height:90%;
}

.side-nav .search input {
Expand Down
5 changes: 4 additions & 1 deletion bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ let container = document.getElementById('container')
// and keep a reference for communicating with the app
let devination = Elm.Main.fullscreen();

ipcRenderer.on('external-link' , function(event , data){ console.log(data.msg) });
ipcRenderer.on('external-link', function(event , data) {
console.log(data);
devination.ports.externalSearch(data);
});

devination.ports.showError.subscribe(function (error) {
dialog.showMessageBox({ type: 'info', buttons: ['Report', 'Cancel'], message: "An error has occured: " + error }, function (buttonIndex) { });
Expand Down
42 changes: 35 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,38 @@ const WebContents = electron.WebContents
// Open devtools with F12
const remote = electron.remote;
const {ipcMain} = require('electron')
var exec = require('child_process').exec;

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

app.setAsDefaultProtocolClient('devination')

app.on('open-url', function (event, url) {
if(win)
{
win.webContents.send('external-link' , {msg: url});
var shouldQuit = app.makeSingleInstance(function(commandLine, workingDirectory) {
// Someone tried to run a second instance, we should focus our window
if (win) {
if (win.isMinimized()) win.restore();
win.focus();
}
return true;
});

if (shouldQuit) {
app.quit();
return;
}

app.setAsDefaultProtocolClient('devination');

if(os.platform() == "linux") {
var execute = function(command, callback){
exec(command, function(error, stdout, stderr){ callback(stdout); });
};

execute('xdg-mime default devination-app.desktop x-scheme-handler/devination', function(output) {
console.log(output);
});
}

function createWindow() {
// Create the browser window.
win = new BrowserWindow({ width: 1400, height: 900, frame: false });
Expand All @@ -40,7 +58,16 @@ function createWindow() {
app.on('uncaughtException', function (error) {
dialog.showMessageBox({ type: 'info', buttons: ['Report', 'Cancel'], message: "An error has occured: " + error }, function (buttonIndex) { });
});


app.on('open-url', function (event, url) {
event.preventDefault();
app.quit();
win.webContents.send('external-link', {msg: url});
});
app.on('open-file', function (event, url) {
event.preventDefault();
win.webContents.send('external-link', {msg: url});
});

new AppUpdater(win)

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


// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "devination",
"version": "0.0.3",
"version": "0.0.4",
"description": "a cross plattform offline documentation browser",
"productName": "devination",
"main": "main.js",
Expand Down Expand Up @@ -35,7 +35,7 @@
"chokidar": "^1.6.1",
"chokidar-cli": "^1.2.0",
"electron": "^1.4.13",
"electron-builder": "^10.13.1",
"electron-builder": "^10.15.1",
"electron-packager": "^8.4.0",
"electron-rebuild": "^1.4.0",
"electron-settings": "^2.2.2"
Expand Down

0 comments on commit 906e9c8

Please sign in to comment.