From 33a9e7e93dc0f87dfc0528f791b419b683da1c1b Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sat, 19 Mar 2016 01:45:11 -0700 Subject: [PATCH 1/5] OS X: Register app as owner of .torrent files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Saw these keys/values in Transmission’s Info.plist. --- bin/package.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/package.js b/bin/package.js index e9be096b..d8f875b8 100755 --- a/bin/package.js +++ b/bin/package.js @@ -156,9 +156,11 @@ function postDarwinism () { infoPlist['CFBundleDocumentTypes'] = [{ CFBundleTypeExtensions: [ 'torrent' ], + CFBundleTypeIconFile: 'WebTorrentFile.icns', CFBundleTypeName: 'BitTorrent Document', CFBundleTypeRole: 'Editor', - CFBundleTypeIconFile: 'WebTorrentFile.icns' + LSHandlerRank: 'Owner', + LSItemContentTypes: [ 'org.bittorrent.torrent' ] }] fs.writeFileSync(infoPlistPath, plist.build(infoPlist)) From 309e509a76bedd1e94966918c199517079d5d377 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sat, 19 Mar 2016 02:48:45 -0700 Subject: [PATCH 2/5] Dock icon should accept all file types (fix #156) --- bin/package.js | 25 +++++++++++++++++-------- main/index.js | 2 +- renderer/index.js | 16 +++++++++++----- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/bin/package.js b/bin/package.js index d8f875b8..ff9469a2 100755 --- a/bin/package.js +++ b/bin/package.js @@ -154,14 +154,23 @@ function postDarwinism () { ]) var infoPlist = plist.parse(fs.readFileSync(infoPlistPath).toString()) - infoPlist['CFBundleDocumentTypes'] = [{ - CFBundleTypeExtensions: [ 'torrent' ], - CFBundleTypeIconFile: 'WebTorrentFile.icns', - CFBundleTypeName: 'BitTorrent Document', - CFBundleTypeRole: 'Editor', - LSHandlerRank: 'Owner', - LSItemContentTypes: [ 'org.bittorrent.torrent' ] - }] + infoPlist.CFBundleDocumentTypes = [ + { + CFBundleTypeExtensions: [ 'torrent' ], + CFBundleTypeIconFile: 'WebTorrentFile.icns', + CFBundleTypeName: 'BitTorrent Document', + CFBundleTypeRole: 'Editor', + LSHandlerRank: 'Owner', + LSItemContentTypes: [ 'org.bittorrent.torrent' ] + }, + { + CFBundleTypeName: 'Any', + CFBundleTypeOSTypes: [ '****' ], + CFBundleTypeRole: 'Editor', + LSTypeIsPackage: false, + LSHandlerRank: 'Owner' + } + ] fs.writeFileSync(infoPlistPath, plist.build(infoPlist)) cp.execSync(`cp ${webTorrentFileIconPath} ${resourcesPath}`) diff --git a/main/index.js b/main/index.js index bcfdb8fe..dd3211f9 100644 --- a/main/index.js +++ b/main/index.js @@ -42,5 +42,5 @@ ipc.init() function onOpen (e, torrentId) { e.preventDefault() - windows.main.send('dispatch', 'addTorrent', torrentId) + windows.main.send('dispatch', 'openFiles', torrentId) } diff --git a/renderer/index.js b/renderer/index.js index 1c633a06..29db7ff1 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -89,7 +89,7 @@ function init () { detectDevices() // ...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 document.addEventListener('paste', onPaste) @@ -159,6 +159,9 @@ function dispatch (action, ...args) { if (['videoMouseMoved', 'playbackJump'].indexOf(action) < 0) { console.log('dispatch: %s %o', action, args) /* log user interactions, but don't spam */ } + if (action === 'openFiles') { + openFiles(args[0] /* files */) + } if (action === 'addTorrent') { addTorrent(args[0] /* torrent */) } @@ -319,14 +322,16 @@ function updateClientProgress () { state.dock.progress = progress } -function onFiles (files) { +function openFiles (files) { + if (!Array.isArray(files)) files = [ files ] + // .torrent file = start downloading the torrent files.filter(isTorrentFile).forEach(function (torrentFile) { - dispatch('addTorrent', torrentFile) + addTorrent(torrentFile) }) // everything else = seed these files - dispatch('seed', files.filter(isNotTorrentFile)) + seed(files.filter(isNotTorrentFile)) } function onPaste (e) { @@ -341,7 +346,8 @@ function onPaste (e) { } 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' } From 3b30ce599fa004959aff55f6004de8efbd394fd4 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sat, 19 Mar 2016 02:49:04 -0700 Subject: [PATCH 3/5] OS X: add copyright statement to About window --- bin/package.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/package.js b/bin/package.js index ff9469a2..9ba3ade2 100755 --- a/bin/package.js +++ b/bin/package.js @@ -172,6 +172,8 @@ function postDarwinism () { } ] + infoPlist.NSHumanReadableCopyright = 'Copyright © 2014-2016 The WebTorrent Project' + fs.writeFileSync(infoPlistPath, plist.build(infoPlist)) cp.execSync(`cp ${webTorrentFileIconPath} ${resourcesPath}`) } From 77592cf765cd223e0474765b34398cbf2ec16bda Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sat, 19 Mar 2016 03:27:53 -0700 Subject: [PATCH 4/5] add small note about how to build for windows --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 4cfea233..dab04124 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,9 @@ $ npm run package -- [platform] 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 [![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) From e9db07e855d059b041bbfd93ce9682cfec1e3209 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sat, 19 Mar 2016 03:27:57 -0700 Subject: [PATCH 5/5] style --- bin/package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/package.js b/bin/package.js index 9ba3ade2..e155d020 100755 --- a/bin/package.js +++ b/bin/package.js @@ -152,7 +152,7 @@ function postDarwinism () { 'static', 'WebTorrentFile.icns' ]) - var infoPlist = plist.parse(fs.readFileSync(infoPlistPath).toString()) + var infoPlist = plist.parse(fs.readFileSync(infoPlistPath, 'utf8')) infoPlist.CFBundleDocumentTypes = [ {