Merge pull request #158 from feross/osx-dock
Dock icon should accept all file types
This commit is contained in:
@@ -60,6 +60,9 @@ $ npm run package -- [platform]
|
|||||||
|
|
||||||
Where `[platform]` is `--darwin`, `--linux`, or `--win32`.
|
Where `[platform]` is `--darwin`, `--linux`, or `--win32`.
|
||||||
|
|
||||||
|
To package a Windows app from non-Windows platforms, [Wine](https://www.winehq.org/) needs
|
||||||
|
to be installed. On OS X, it is installable via [Homebrew](http://brew.sh/).
|
||||||
|
|
||||||
### Code Style
|
### Code Style
|
||||||
|
|
||||||
[](https://github.com/feross/standard)
|
[](https://github.com/feross/standard)
|
||||||
|
|||||||
@@ -153,14 +153,27 @@ function postDarwinism () {
|
|||||||
'static',
|
'static',
|
||||||
'WebTorrentFile.icns'
|
'WebTorrentFile.icns'
|
||||||
])
|
])
|
||||||
var infoPlist = plist.parse(fs.readFileSync(infoPlistPath).toString())
|
var infoPlist = plist.parse(fs.readFileSync(infoPlistPath, 'utf8'))
|
||||||
|
|
||||||
infoPlist['CFBundleDocumentTypes'] = [{
|
infoPlist.CFBundleDocumentTypes = [
|
||||||
CFBundleTypeExtensions: [ 'torrent' ],
|
{
|
||||||
CFBundleTypeName: 'BitTorrent Document',
|
CFBundleTypeExtensions: [ 'torrent' ],
|
||||||
CFBundleTypeRole: 'Editor',
|
CFBundleTypeIconFile: 'WebTorrentFile.icns',
|
||||||
CFBundleTypeIconFile: 'WebTorrentFile.icns'
|
CFBundleTypeName: 'BitTorrent Document',
|
||||||
}]
|
CFBundleTypeRole: 'Editor',
|
||||||
|
LSHandlerRank: 'Owner',
|
||||||
|
LSItemContentTypes: [ 'org.bittorrent.torrent' ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
CFBundleTypeName: 'Any',
|
||||||
|
CFBundleTypeOSTypes: [ '****' ],
|
||||||
|
CFBundleTypeRole: 'Editor',
|
||||||
|
LSTypeIsPackage: false,
|
||||||
|
LSHandlerRank: 'Owner'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
infoPlist.NSHumanReadableCopyright = 'Copyright © 2014-2016 The WebTorrent Project'
|
||||||
|
|
||||||
fs.writeFileSync(infoPlistPath, plist.build(infoPlist))
|
fs.writeFileSync(infoPlistPath, plist.build(infoPlist))
|
||||||
cp.execSync(`cp ${webTorrentFileIconPath} ${resourcesPath}`)
|
cp.execSync(`cp ${webTorrentFileIconPath} ${resourcesPath}`)
|
||||||
|
|||||||
@@ -42,5 +42,5 @@ ipc.init()
|
|||||||
|
|
||||||
function onOpen (e, torrentId) {
|
function onOpen (e, torrentId) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
windows.main.send('dispatch', 'addTorrent', torrentId)
|
windows.main.send('dispatch', 'openFiles', torrentId)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ function init () {
|
|||||||
Cast.init(update)
|
Cast.init(update)
|
||||||
|
|
||||||
// ...drag and drop a torrent or video file to play or seed
|
// ...drag and drop a torrent or video file to play or seed
|
||||||
dragDrop('body', onFiles)
|
dragDrop('body', (files) => dispatch('openFiles', files))
|
||||||
|
|
||||||
// ...same thing if you paste a torrent
|
// ...same thing if you paste a torrent
|
||||||
document.addEventListener('paste', onPaste)
|
document.addEventListener('paste', onPaste)
|
||||||
@@ -158,6 +158,9 @@ function dispatch (action, ...args) {
|
|||||||
if (['videoMouseMoved', 'playbackJump'].indexOf(action) < 0) {
|
if (['videoMouseMoved', 'playbackJump'].indexOf(action) < 0) {
|
||||||
console.log('dispatch: %s %o', action, args) /* log user interactions, but don't spam */
|
console.log('dispatch: %s %o', action, args) /* log user interactions, but don't spam */
|
||||||
}
|
}
|
||||||
|
if (action === 'openFiles') {
|
||||||
|
openFiles(args[0] /* files */)
|
||||||
|
}
|
||||||
if (action === 'addTorrent') {
|
if (action === 'addTorrent') {
|
||||||
addTorrent(args[0] /* torrent */)
|
addTorrent(args[0] /* torrent */)
|
||||||
}
|
}
|
||||||
@@ -319,14 +322,16 @@ function updateClientProgress () {
|
|||||||
state.dock.progress = progress
|
state.dock.progress = progress
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFiles (files) {
|
function openFiles (files) {
|
||||||
|
if (!Array.isArray(files)) files = [ files ]
|
||||||
|
|
||||||
// .torrent file = start downloading the torrent
|
// .torrent file = start downloading the torrent
|
||||||
files.filter(isTorrentFile).forEach(function (torrentFile) {
|
files.filter(isTorrentFile).forEach(function (torrentFile) {
|
||||||
dispatch('addTorrent', torrentFile)
|
addTorrent(torrentFile)
|
||||||
})
|
})
|
||||||
|
|
||||||
// everything else = seed these files
|
// everything else = seed these files
|
||||||
dispatch('seed', files.filter(isNotTorrentFile))
|
seed(files.filter(isNotTorrentFile))
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPaste (e) {
|
function onPaste (e) {
|
||||||
@@ -341,7 +346,8 @@ function onPaste (e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isTorrentFile (file) {
|
function isTorrentFile (file) {
|
||||||
var extname = path.extname(file.name).toLowerCase()
|
var name = typeof file === 'string' ? file : file.name
|
||||||
|
var extname = path.extname(name).toLowerCase()
|
||||||
return extname === '.torrent'
|
return extname === '.torrent'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user