Resolve posterURL and torrentPath at runtime

Fixes bug where posters and torrent files can’t be found in the built
app.
This commit is contained in:
Feross Aboukhadijeh
2016-03-27 02:10:58 -07:00
parent 339f472473
commit eb59c11f85
5 changed files with 28 additions and 11 deletions

View File

@@ -4,6 +4,7 @@ var h = require('virtual-dom/h')
var hyperx = require('hyperx')
var hx = hyperx(h)
var util = require('../util')
// Shows a streaming video player. Standard features + Chromecast + Airplay
function Player (state, dispatch) {
@@ -153,7 +154,8 @@ function renderCastScreen (state, dispatch) {
function cssBackgroundImagePoster (state) {
var torrentSummary = getPlayingTorrentSummary(state)
if (!torrentSummary || !torrentSummary.posterURL) return ''
var cleanURL = torrentSummary.posterURL.replace(/\\/g, '/')
var posterURL = util.getAbsoluteStaticPath(torrentSummary.posterURL)
var cleanURL = posterURL.replace(/\\/g, '/')
return 'radial-gradient(circle at center, ' +
'rgba(0,0,0,0.4) 0%, rgba(0,0,0,1) 100%)' +
`, url(${cleanURL})`

View File

@@ -5,6 +5,8 @@ var hyperx = require('hyperx')
var hx = hyperx(h)
var prettyBytes = require('prettier-bytes')
var util = require('../util')
var TorrentPlayer = require('../lib/torrent-player')
function TorrentList (state, dispatch) {
@@ -35,9 +37,10 @@ function TorrentList (state, dispatch) {
var gradient = isSelected
? 'linear-gradient(to bottom, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 100%)'
: 'linear-gradient(to bottom, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 100%)'
var posterURL = util.getAbsoluteStaticPath(torrentSummary.posterURL)
// Work around a Chrome bug (reproduced in vanilla Chrome, not just Electron):
// Backslashes in URLS in CSS cause bizarre string encoding issues
var cleanURL = torrentSummary.posterURL.replace(/\\/g, '/')
var cleanURL = posterURL.replace(/\\/g, '/')
style.backgroundImage = gradient + `, url('${cleanURL}')`
}