git ssb

16+

Dominic / patchbay



Commit 79c10b336a5d261d0c19aedbef677d2a5d332ff3

portably openn links

Dominic Tarr committed on 6/24/2016, 10:20:23 PM
Parent: 82eeb2f00af985004afbb6a3ac6fe9b2f9a64eef

Files changed

modules/tabs.jschanged
modules/tabs.jsView
@@ -2,9 +2,8 @@
22 var h = require('hyperscript')
33 var pull = require('pull-stream')
44 var u = require('../util')
55
6-
76 function ancestor (el) {
87 if(!el) return
98 if(el.tagName !== 'A') return ancestor(el.parentElement)
109 return el
@@ -12,8 +11,23 @@
1211
1312 var plugs = require('../plugs')
1413 var screen_view = plugs.first(exports.screen_view = [])
1514
15+function openExternal (url) {
16+ var _r = require //fool browserify
17+
18+ //electron@1
19+ try {return _r('electron').shell.openExternal(url) }
20+ catch (err) { }
21+
22+ //electron@0
23+ try { return _r('shell').openExternal(url) }
24+ catch (err) { }
25+
26+ //browser
27+ window.open(url, '_blank')
28+}
29+
1630 exports.message_render = []
1731
1832 exports.app = function () {
1933 var tabs = Tabs()
@@ -21,15 +35,9 @@
2135
2236 var saved
2337 try { saved = JSON.parse(localStorage.openTabs) }
2438 catch (_) { saved = ['/public', '/private'] }
25-
26-// var public = screen_view('/public')
27-// if(public) tabs.add('public', public, true)
28-//
29-// var private = screen_view('/private')
30-// if(private) tabs.add('private', private, true)
31-//
39+
3240 saved.forEach(function (path) {
3341 var el = screen_view(path)
3442 if(el) tabs.add(path, el, true)
3543 })
@@ -45,10 +53,9 @@
4553 ev.stopPropagation()
4654
4755 //open external links.
4856 //this ought to be made into something more runcible
49-// if(/^https?/.test(link.href))
50-// return require('electron').shell.openExternal(link.href)
57+ if(/^https?/.test(link.href)) return openExternal(link.href)
5158
5259 if(tabs.has(path)) return tabs.select(path)
5360
5461 var el = screen_view(path)
@@ -61,4 +68,14 @@
6168 return tabs
6269 }
6370
6471
72+
73+
74+
75+
76+
77+
78+
79+
80+
81+

Built with git-ssb-web