Skip to content

Commit

Permalink
Release v2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kingosticks committed Nov 15, 2019
2 parents 25e29b4 + 404d816 commit a488351
Show file tree
Hide file tree
Showing 16 changed files with 155 additions and 104 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"indent": [2, 4, {"SwitchCase": 1}],
"no-undef": 0, // TODO: Set this to '2' once Javascript has been modularised.
"no-unused-vars": 0, // TODO: Set this to '2' once Javascript has been modularised.
"camelcase": 1,
"camelcase": 0,
"no-multi-spaces": ["error", {"ignoreEOLComments": true}],
"no-useless-escape": 0,
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ npm-debug.log
*.egg-info
.cache
.eggs
xunit-py27.xml
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
sudo: required
dist: trusty

language: python

python:
- "2.7_with_system_site_packages"
- "2.7"

virtualenv:
system_site_packages: true

addons:
apt:
Expand All @@ -15,15 +15,13 @@ addons:

env:
# Need to run 'py27' and 'test' together so that we can share coverage reports.
- TOX_ENV=py27,test
- TOX_ENV=py27
#- TOX_ENV=test
- TOX_ENV=flake8
- TOX_ENV=eslint
- TOX_ENV=csslint
- TOX_ENV=tidy

before_install:
- "sudo apt-get update -qq"

install:
- "pip install tox"

Expand Down
14 changes: 12 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,18 @@ Project resources
Changelog
=========

v2.5.0 (2017-05-22)
------------
v2.6.0 (2019-11-15)
-------------------

- Update for compatibility with upccomming Mopidy v3.0.
- Improved performance when fetching playlist track metadata.

**Fixes**

- Support for IPv6 address.

v2.5.0 (2018-05-22)
-------------------

- Detect additional stream formats (rtmp, rtmps, rtsp).
- Include details of currently selected page in HTML title tag. (Addresses: `#243 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/243>`_).
Expand Down
2 changes: 1 addition & 1 deletion mopidy_musicbox_webclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from mopidy import config, ext

__version__ = '2.5.0'
__version__ = '2.6.0'


class Extension(ext.Extension):
Expand Down
78 changes: 40 additions & 38 deletions mopidy_musicbox_webclient/static/js/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,33 @@

var controls = {

/**
* 'onClick' handler for tracks that are rendered in a list.
*
* Adds tracks to current tracklist and starts playback if necessary.
*
* @param {string} action - The action to perform. Valid actions are:
* PLAY_NOW: add the track at the current queue position and
* start playback immediately.
* PLAY_NEXT: insert track after the reference track, if 'index'
* is provided, or after the current track otherwise.
* ADD_THIS_BOTTOM: add track to bottom of tracklist.
* ADD_ALL_BOTTOM: add all tracks in in the list to bottom of
* tracklist.
* PLAY_ALL: clear tracklist and start playback of the track
* with URI provided in 'trackUri'.
* @param {object} mopidy - The Mopidy.js object that should be used to communicate with the
* Mopidy server.
* @param {string} trackUri - (Optional) The URI of the specific track that the action should
* be performed on. If no URI is provided then the 'data' attribute
* of the popup DIV is assumed to contain the track URI.
* @param {string} playlistUri - (Optional) The URI of the playlist containing the tracks
* to be played. If no URI is provided then the 'list' attribute
* of the popup DIV is assumed to contain the playlist URI.
* @param {string} index - (Optional) The tracklist index of the reference track that the
* action should be performed on. Defaults to the index of the currently
* playing track.
*/
/**
* 'onClick' handler for tracks that are rendered in a list.
*
* Adds tracks to current tracklist and starts playback if necessary.
*
* @param {string} action - The action to perform. Valid actions are:
* PLAY_NOW: add the track at the current queue position and
* start playback immediately.
* PLAY_NEXT: insert track after the reference track, if 'index'
* is provided, or after the current track otherwise.
* ADD_THIS_BOTTOM: add track to bottom of tracklist.
* ADD_ALL_BOTTOM: add all tracks in in the list to bottom of
* tracklist.
* PLAY_ALL: clear tracklist and start playback of the track
* with URI provided in 'trackUri'.
* @param {object} mopidy - The Mopidy.js object that should be used to communicate with the
* Mopidy server.
* @param {string} trackUri - (Optional) The URI of the specific track that the action should
* be performed on. If no URI is provided then the 'data' attribute
* of the popup DIV is assumed to contain the track URI.
* @param {string} playlistUri - (Optional) The URI of the playlist containing the tracks
* to be played. If no URI is provided then the 'list' attribute
* of the popup DIV is assumed to contain the playlist URI.
* @param {string} index - (Optional) The tracklist index of the reference track that the
* action should be performed on. Defaults to the index of the currently
* playing track.
*/

playTracks: function (action, mopidy, trackUri, playlistUri, index) {
toast('Updating queue...')
Expand Down Expand Up @@ -78,7 +78,7 @@
case PLAY_ALL:
mopidy.tracklist.add({uris: trackUris}).then(function (tlTracks) {
if (action === PLAY_ALL) { // Start playback of selected track immediately.
mopidy.tracklist.filter({uri: [trackUri]}).then(function (tlTracks) {
mopidy.tracklist.filter({criteria: {uri: [trackUri]}}).then(function (tlTracks) {
mopidy.playback.stop().then(function () {
mopidy.playback.play({tlid: tlTracks[0].tlid})
})
Expand Down Expand Up @@ -211,7 +211,7 @@
toast('Deleting...')

tlid = tlid || $('#popupQueue').data('tlid')
mopidy.tracklist.remove({'tlid': [parseInt(tlid)]})
mopidy.tracklist.remove({criteria: {'tlid': [parseInt(tlid)]}})
$('#popupQueue').popup('close')
},

Expand Down Expand Up @@ -629,7 +629,7 @@
doVolume: function (value) {
if (!volumeChanging) {
volumeChanging = value
mopidy.playback.setVolume({'volume': parseInt(volumeChanging)}).then(function () {
mopidy.mixer.setVolume({'volume': parseInt(volumeChanging)}).then(function () {
volumeChanging = null
})
}
Expand Down Expand Up @@ -737,14 +737,16 @@
},

getFavourites: function () {
return controls.getPlaylistByName(STREAMS_PLAYLIST_NAME,
STREAMS_PLAYLIST_SCHEME,
true).then(function (playlist) {
if (playlist) {
return controls.getPlaylistFull(playlist.uri)
}
return Mopidy.when(false)
})
return controls.getPlaylistByName(
STREAMS_PLAYLIST_NAME,
STREAMS_PLAYLIST_SCHEME,
true
).then(function (playlist) {
if (playlist) {
return controls.getPlaylistFull(playlist.uri)
}
return Mopidy.when(false)
})
},

addToFavourites: function (newTracks) {
Expand Down
18 changes: 11 additions & 7 deletions mopidy_musicbox_webclient/static/js/functionsvars.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ function renderSongLiTrackArtists (track) {
/* Tracklist renderer to insert dividers between albums. */
function renderSongLiDivider (previousTrack, track, nextTrack, target) {
var html = ''
var imageID
// Render differently if part of an album.
if (!hasSameAlbum(previousTrack, track) && hasSameAlbum(track, nextTrack)) {
// Large divider with album cover.
Expand All @@ -315,8 +316,8 @@ function renderSongLiDivider (previousTrack, track, nextTrack, target) {
'<img id="' + getjQueryID(target + '-cover', track.uri) + '" class="artistcover" width="30" height="30"/>' +
'<h1>' + track.album.name + '</h1><p>' +
renderSongLiTrackArtists(track) + '</p></a></li>'
// Retrieve album covers
images.setAlbumImage(track.uri, getjQueryID(target + '-cover', track.uri, true), mopidy, 'small')
// The element ID to populate with an album cover.
imageID = getjQueryID(target + '-cover', track.uri, true)
} else if (previousTrack && !hasSameAlbum(previousTrack, track)) {
// Small divider
html += '<li class="smalldivider"> &nbsp;</li>'
Expand All @@ -325,7 +326,7 @@ function renderSongLiDivider (previousTrack, track, nextTrack, target) {
target = getjQueryID(target, track.uri, true)
$(target).before(html)
}
return html
return [html, imageID]
}

function renderSongLiBackButton (results, target, onClick, optional) {
Expand Down Expand Up @@ -375,6 +376,7 @@ function resultsToTables (results, target, uri, onClickBack, backIsOptional) {

var track, previousTrack, nextTrack, tlid
var html = ''
var requiredImages = {}

// Break into albums and put in tables
for (i = 0; i < results.length; i++) {
Expand All @@ -389,21 +391,23 @@ function resultsToTables (results, target, uri, onClickBack, backIsOptional) {
nextTrack = nextTrack ? nextTrack.track : undefined
}
popupData[track.uri] = track
html += renderSongLiDivider(previousTrack, track, nextTrack, target)
html += renderSongLi(previousTrack, track, nextTrack, uri, tlid, target, i, results.length)
var divider = renderSongLiDivider(previousTrack, track, nextTrack, target)
html += divider[0] + renderSongLi(previousTrack, track, nextTrack, uri, tlid, target, i, results.length)
requiredImages[track.uri] = divider[1]
}
}
$(target).append(html)
updatePlayIcons(songdata.track.uri, songdata.tlid, controls.getIconForAction())
images.setImages(requiredImages, mopidy, 'small')
}

function getPlaylistTracks (uri) {
if (playlists[uri] && playlists[uri].tracks) {
return Mopidy.when(playlists[uri].tracks)
} else {
showLoading(true)
return mopidy.playlists.getItems({'uri': uri}).then(function (refs) {
return processPlaylistItems({'uri': uri, 'items': refs})
return mopidy.playlists.lookup({'uri': uri}).then(function (playlist) {
return processPlaylistItems({'uri': uri, 'playlist': playlist})
}, console.error)
}
}
Expand Down
10 changes: 2 additions & 8 deletions mopidy_musicbox_webclient/static/js/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,6 @@ function initSocketevents () {

mopidy.on('event:tracklistChanged', function (data) {
library.getCurrentPlaylist()
mopidy.tracklist.getTracks().then(function (tracks) {
if (tracks.length === 0) {
// Last track in queue was deleted, reset UI.
resetSong()
}
})
})

mopidy.on('event:seeked', function (data) {
Expand Down Expand Up @@ -362,7 +356,7 @@ function updateStatusOfAll () {

updateOptions()

mopidy.playback.getVolume().then(processVolume, console.error)
mopidy.mixer.getVolume().then(processVolume, console.error)
mopidy.mixer.getMute().then(processMute, console.error)
}

Expand Down Expand Up @@ -505,7 +499,7 @@ $(document).ready(function (event) {
// navigation stuff

$(document).keypress(function (event) {
// console.log('kp: '+event);
// console.log('kp: '+event);
if (event.target.tagName !== 'INPUT') {
var unicode = event.keyCode ? event.keyCode : event.charCode
var actualkey = String.fromCharCode(unicode)
Expand Down
19 changes: 19 additions & 0 deletions mopidy_musicbox_webclient/static/js/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,25 @@
})
},

setImages: function (img_elements, mopidy, size) {
var uris = []
// Set default immediately while we're busy retrieving actual image.
Object.keys(img_elements).forEach(function (uri) {
if (img_elements[uri]) {
$(img_elements[uri]).attr('src', images.DEFAULT_ALBUM_URL)
uris.push(uri)
}
})
size = size || 'extralarge'
mopidy.library.getImages({'uris': uris}).then(function (imageResults) {
Object.keys(imageResults).forEach(function (uri) {
if (imageResults[uri].length > 0) {
$(img_elements[uri]).attr('src', imageResults[uri][0].uri)
}
})
})
},

// Note that this approach has been deprecated in Mopidy
// TODO: Remove when Mopidy no longer supports retrieving images
// from 'album.images'.
Expand Down
32 changes: 16 additions & 16 deletions mopidy_musicbox_webclient/static/js/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

var library = {

/** *******************************
* Search
*********************************/
/** *******************************
* Search
*********************************/
searchPressed: function (key) {
var value = $('#searchinput').val()
switchContent('search')
Expand Down Expand Up @@ -67,9 +67,9 @@
}
},

/** ******************************************************
* process results of a search
*********************************************************/
/** ******************************************************
* process results of a search
*********************************************************/
processSearchResults: function (resultArr) {
$(SEARCH_TRACK_TABLE).empty()
$(SEARCH_ARTIST_TABLE).empty()
Expand Down Expand Up @@ -195,9 +195,9 @@
showLoading(false)
},

/** *******************************
* Playlists & Browse
*********************************/
/** *******************************
* Playlists & Browse
*********************************/
getPlaylists: function () {
// get playlists without tracks
mopidy.playlists.asList().then(processGetPlaylists, console.error)
Expand Down Expand Up @@ -233,9 +233,9 @@
mopidy.tracklist.getTlTracks().then(processCurrentPlaylist, console.error)
},

/** ******************************************************
* Show tracks of playlist
********************************************************/
/** ******************************************************
* Show tracks of playlist
********************************************************/
togglePlaylists: function () {
if ($(window).width() <= 960) {
$('#playlisttracksdiv').toggle();
Expand All @@ -248,9 +248,9 @@
return true
},

/** **********
* Lookups
************/
/** **********
* Lookups
************/
showTracklist: function (uri) {
showLoading(true)
$(PLAYLIST_TABLE).empty()
Expand All @@ -275,7 +275,7 @@
$('#controlsmodal').popup('close')
$(ARTIST_TABLE).empty()

// TODO cache
// TODO cache
$('#h_artistname').html('')
showLoading(true)
mopidy.library.lookup({'uris': [nwuri]}).then(function (resultDict) {
Expand Down
Loading

0 comments on commit a488351

Please sign in to comment.