Merge pull request #163 from feross/poster-image-folder
Write poster images into "$CONFIG_PATH/Posters"
This commit is contained in:
@@ -5,15 +5,13 @@
|
|||||||
* Useful for developers.
|
* Useful for developers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var applicationConfigPath = require('application-config-path')
|
|
||||||
var config = require('../config')
|
var config = require('../config')
|
||||||
var os = require('os')
|
var os = require('os')
|
||||||
var path = require('path')
|
var path = require('path')
|
||||||
var pathExists = require('path-exists')
|
var pathExists = require('path-exists')
|
||||||
var rimraf = require('rimraf')
|
var rimraf = require('rimraf')
|
||||||
|
|
||||||
var tmpPath = path.join(pathExists.sync('/tmp') ? '/tmp' : os.tmpDir(), 'webtorrent')
|
rimraf.sync(config.CONFIG_PATH)
|
||||||
var configPath = applicationConfigPath(config.APP_NAME)
|
|
||||||
|
|
||||||
rimraf.sync(configPath)
|
var tmpPath = path.join(pathExists.sync('/tmp') ? '/tmp' : os.tmpDir(), 'webtorrent')
|
||||||
rimraf.sync(tmpPath)
|
rimraf.sync(tmpPath)
|
||||||
@@ -1,9 +1,15 @@
|
|||||||
|
var applicationConfigPath = require('application-config-path')
|
||||||
var path = require('path')
|
var path = require('path')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
APP_NAME: 'WebTorrent',
|
|
||||||
APP_ICON: path.join(__dirname, 'static', 'WebTorrent.png'),
|
APP_ICON: path.join(__dirname, 'static', 'WebTorrent.png'),
|
||||||
|
APP_NAME: 'WebTorrent',
|
||||||
|
|
||||||
|
CONFIG_PATH: applicationConfigPath('WebTorrent'),
|
||||||
|
CONFIG_POSTER_PATH: path.join(applicationConfigPath('WebTorrent'), 'Posters'),
|
||||||
|
|
||||||
INDEX: 'file://' + path.join(__dirname, 'renderer', 'index.html'),
|
INDEX: 'file://' + path.join(__dirname, 'renderer', 'index.html'),
|
||||||
|
|
||||||
SOUND_ADD: 'file://' + path.join(__dirname, 'static', 'sound', 'add.wav'),
|
SOUND_ADD: 'file://' + path.join(__dirname, 'static', 'sound', 'add.wav'),
|
||||||
SOUND_DELETE: 'file://' + path.join(__dirname, 'static', 'sound', 'delete.wav'),
|
SOUND_DELETE: 'file://' + path.join(__dirname, 'static', 'sound', 'delete.wav'),
|
||||||
SOUND_DISABLE: 'file://' + path.join(__dirname, 'static', 'sound', 'disable.wav'),
|
SOUND_DISABLE: 'file://' + path.join(__dirname, 'static', 'sound', 'disable.wav'),
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
"url": "git://github.com/feross/webtorrent-app.git"
|
"url": "git://github.com/feross/webtorrent-app.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"cleanup": "node ./bin/cleanup.js",
|
"clean": "node ./bin/clean.js",
|
||||||
"debug": "DEBUG=* electron .",
|
"debug": "DEBUG=* electron .",
|
||||||
"package": "npm prune && npm dedupe && node ./bin/package.js",
|
"package": "npm prune && npm dedupe && node ./bin/package.js",
|
||||||
"size": "npm run package -- --darwin && du -ch dist/WebTorrent-darwin-x64 | grep total",
|
"size": "npm run package -- --darwin && du -ch dist/WebTorrent-darwin-x64 | grep total",
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
console.time('init')
|
console.time('init')
|
||||||
|
|
||||||
var cfg = require('application-config')('WebTorrent')
|
var cfg = require('application-config')('WebTorrent')
|
||||||
var cfgDirectory = require('application-config-path')('WebTorrent')
|
|
||||||
var createTorrent = require('create-torrent')
|
var createTorrent = require('create-torrent')
|
||||||
var dragDrop = require('drag-drop')
|
var dragDrop = require('drag-drop')
|
||||||
var electron = require('electron')
|
var electron = require('electron')
|
||||||
@@ -291,6 +290,7 @@ function loadState (callback) {
|
|||||||
state.saved.torrents.forEach(function (torrentSummary) {
|
state.saved.torrents.forEach(function (torrentSummary) {
|
||||||
if (torrentSummary.displayName) torrentSummary.name = torrentSummary.displayName
|
if (torrentSummary.displayName) torrentSummary.name = torrentSummary.displayName
|
||||||
})
|
})
|
||||||
|
saveState()
|
||||||
|
|
||||||
if (callback) callback()
|
if (callback) callback()
|
||||||
})
|
})
|
||||||
@@ -462,12 +462,15 @@ function generateTorrentPoster (torrent, torrentSummary) {
|
|||||||
torrentPoster(torrent, function (err, buf) {
|
torrentPoster(torrent, function (err, buf) {
|
||||||
if (err) return onWarning(err)
|
if (err) return onWarning(err)
|
||||||
// save it for next time
|
// save it for next time
|
||||||
var posterFilePath = path.join(cfgDirectory, torrent.infoHash + '.jpg')
|
fs.mkdir(config.CONFIG_POSTER_PATH, function (err) {
|
||||||
fs.writeFile(posterFilePath, buf, function (err) {
|
|
||||||
if (err) return onWarning(err)
|
if (err) return onWarning(err)
|
||||||
// show the poster
|
var posterFilePath = path.join(config.CONFIG_POSTER_PATH, torrent.infoHash + '.jpg')
|
||||||
torrentSummary.posterURL = 'file:///' + posterFilePath
|
fs.writeFile(posterFilePath, buf, function (err) {
|
||||||
update()
|
if (err) return onWarning(err)
|
||||||
|
// show the poster
|
||||||
|
torrentSummary.posterURL = 'file:///' + posterFilePath
|
||||||
|
update()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ module.exports = {
|
|||||||
*
|
*
|
||||||
* Config path:
|
* Config path:
|
||||||
*
|
*
|
||||||
* OS XDG ~/Library/Application Support/WebTorrent/config.json
|
* OS X ~/Library/Application Support/WebTorrent/config.json
|
||||||
* Linux (XDG) $XDG_CONFIG_HOME/WebTorrent/config.json
|
* Linux (XDG) $XDG_CONFIG_HOME/WebTorrent/config.json
|
||||||
* Linux (Legacy) ~/.config/WebTorrent/config.json
|
* Linux (Legacy) ~/.config/WebTorrent/config.json
|
||||||
* Windows (> Vista) %LOCALAPPDATA%/WebTorrent/config.json
|
* Windows (> Vista) %LOCALAPPDATA%/WebTorrent/config.json
|
||||||
|
|||||||
Reference in New Issue
Block a user