Skip to content

Commit

Permalink
v.1.1.1
Browse files Browse the repository at this point in the history
Added context menu to edit / delete tags
Added browsers submenu to url context menu
  • Loading branch information
dgmid committed Sep 2, 2018
1 parent a43db4c commit bcd806f
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 26 deletions.
6 changes: 3 additions & 3 deletions app-source/js/app-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ const template = [
if (focusedWindow) focusedWindow.reload()
}
},
{
/*{
label: 'Toggle Developer Tools',
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
click (item, focusedWindow) {
if (focusedWindow) focusedWindow.webContents.toggleDevTools()
}
},
},*/
{
type: 'separator'
},
Expand Down Expand Up @@ -181,7 +181,7 @@ const template = [
submenu:
[
{
label: 'midwinter-dg.com',
label: 'Nextcloud Bookmark Manager Homepage',
click () { require('electron').shell.openExternal('https://www.midwinter-dg.com/mac-apps/nextcloud-bookmark-manager.html') }
}
]
Expand Down
30 changes: 21 additions & 9 deletions app-source/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ function getBookmarks() {

} else {

console.log('response ERROR')
dialog.showErrorBox(
'Server connection error',
`there was an error connecting to: ${server}`
)

console.log( response.error() )
}

Expand All @@ -123,8 +127,12 @@ function getBookmarks() {

if (doc['status'] == 'error') {

showError(doc['message'])

dialog.showErrorBox(
'JSON parsing error',
`An error occured parsing the bookmarks`
)

console.log(doc['message'])

} else {

Expand All @@ -135,7 +143,11 @@ function getBookmarks() {

}).catch(function(error) {

console.log('ERROR')
dialog.showErrorBox(
'Server connection error',
`there was an error connecting to: ${server}`
)

console.log(error)
})
}
Expand Down Expand Up @@ -494,12 +506,12 @@ function openModal( url, width, height, resize ) {
backgroundColor: '#ECECEC'
})

modal.loadURL( url )
modal.loadURL( url )

modal.once('ready-to-show', () => {

modal.once('ready-to-show', () => {

modal.show()
})
modal.show()
})
}


Expand Down
53 changes: 51 additions & 2 deletions app-source/js/context-menu.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
'use strict'

const electron = require( 'electron' )
const {shell, app} = require( 'electron' )
const {shell, app, clipboard} = require( 'electron' )
const dialog = require( 'electron' ).dialog
const BrowserWindow = electron.BrowserWindow
const Menu = electron.Menu
const MenuItem = electron.MenuItem
const ipc = electron.ipcMain

const Store = require( 'electron-store' )
const store = new Store()

const applescript = require( 'applescript' )

//note(@duncanmid): decodeentities

Expand All @@ -26,9 +30,17 @@ ipc.on('show-bookmark-menu', ( event, message ) => {

const bookmarkMenuTemplate = [
{
label: `Open ${title} URL…`,
label: `Open ${title} in Default Browser`,
click () { require('electron').shell.openExternal( message[3] ) }
},
{
label: `Open ${title} with…`,
submenu: []
},
{
label: `Copy ${title} url to Clipboard`,
click () { clipboard.writeText(message[3], title) }
},
{
type: 'separator'
},
Expand All @@ -43,6 +55,43 @@ ipc.on('show-bookmark-menu', ( event, message ) => {
},
]

const browsers = store.get('browsers')

for (let i = 0, len = browsers.length; i < len; i++) {

let theBrowser = browsers[i]['name']

let launchScript =

`tell application "${theBrowser}"
open location "${message[3]}"
end tell
tell application "System Events"
tell application process "${theBrowser}"
set frontmost to true
end tell
end tell`

bookmarkMenuTemplate[1].submenu.push({
label: theBrowser,
click () {

applescript.execString(launchScript, function(err, rtn) {
if (err) {

dialog.showErrorBox(
`Error launching: ${theBrowser}`,
`the url ${message[3]} could not be opened`
)

console.log( err )
}
})
}
}
)
}

const bookmarkMenu = Menu.buildFromTemplate( bookmarkMenuTemplate )

const win = BrowserWindow.fromWebContents( event.sender )
Expand Down
18 changes: 15 additions & 3 deletions app-source/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const url = require('url')
const path = require('path')
const Store = require('electron-store')

const getAvailableBrowsers = require('detect-installed-browsers').getAvailableBrowsers

let win,
loginFlow

Expand Down Expand Up @@ -36,7 +38,9 @@ let store = new Store({
password: ''
},

tags: null
tags: null,

browsers: null
}
})

Expand Down Expand Up @@ -90,6 +94,16 @@ function createWindow() {
require( './context-menu.min' )
require( './tags-menu.min' )

getAvailableBrowsers( {}, ( browserList ) => {

let results = []

for ( let browser of browserList ) {

results.push( { "name": browser.name } )
store.set('browsers', results )
}
})

protocol.registerFileProtocol('nc', (request, callback) => {

Expand Down Expand Up @@ -125,8 +139,6 @@ ipcMain.on('refresh', (event, message) => {

ipcMain.on('reload', (event, message) => {

console.log('reload')

win.reload()
})

Expand Down
2 changes: 1 addition & 1 deletion dist/js/app-menu.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bcd806f

Please sign in to comment.