diff --git a/CMakeLists.txt b/CMakeLists.txt index a6a7d76..0a5bff0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project (mympd C) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/") set(CPACK_PACKAGE_VERSION_MAJOR "4") set(CPACK_PACKAGE_VERSION_MINOR "2") -set(CPACK_PACKAGE_VERSION_PATCH "0") +set(CPACK_PACKAGE_VERSION_PATCH "1") if(CMAKE_BUILD_TYPE MATCHES RELEASE) set(ASSETS_PATH "/usr/share/${PROJECT_NAME}/htdocs") @@ -54,5 +54,4 @@ install(FILES dist/htdocs/js/mympd.min.js DESTINATION share/${PROJECT_NAME}/htdo install(FILES dist/htdocs/css/bootstrap.min.css DESTINATION share/${PROJECT_NAME}/htdocs/css/) install(FILES dist/htdocs/css/mympd.min.css DESTINATION share/${PROJECT_NAME}/htdocs/css/) install(DIRECTORY htdocs/assets DESTINATION share/${PROJECT_NAME}/htdocs) -install(DIRECTORY DESTINATION share/${PROJECT_NAME}/htdocs/pics) -install(DIRECTORY DESTINATION ../var/lib/${PROJECT_NAME}/) +install(DIRECTORY DESTINATION ../var/lib/${PROJECT_NAME}/pics) diff --git a/PKGBUILD b/PKGBUILD index a689af7..ff6356d 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,18 +1,17 @@ -# Maintainer: K. Loz -# Based on jcorporation's myMPD mkrelease.sh +# Maintainer: Juergen Mang # Website: https://github.com/jcorporation/myMPD -# PKGBUILD Based on mympd-archphile by Mike Andonov +# PKGBUILD Based on https://github.com/CultofRobots/archphile-custom/tree/master/mympd pkgname=mympd _pkgname=myMPD -pkgver=4.2.0 +pkgver=4.2.1 pkgrel=1 pkgdesc="A standalone MPD Web GUI based on YMPD - Default port set to 80" arch=('x86_64' 'armv7h' 'aarch64') url="http://github.org/jcorporation/myMPD" license=('GPL') depends=('libmpdclient' 'openssl') -makedepends=('cmake' 'git') +makedepends=('cmake') optdepends=() provides=() conflicts=() @@ -21,49 +20,6 @@ install=contrib/archlinux.install source=("https://github.com/jcorporation/${_pkgname}/archive/v${pkgver}.tar.gz") sha256sums=('SKIP') -prepare() { - export java=$(which java 2> /dev/null) - - if [ -f ${srcdir}/${_pkgname}-${pkgver}/dist/buildtools/closure-compiler.jar ] && [ "$java" != "$NULL" ] - then - echo "Minifying javascript" - [ ${srcdir}/${_pkgname}-${pkgver}/htdocs/js/player.js -nt ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/js/player.min.js ] && \ - java -jar ${srcdir}/${_pkgname}-${pkgver}/dist/buildtools/closure-compiler.jar ${srcdir}/${_pkgname}-${pkgver}/htdocs/js/player.js > ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/js/player.min.js - [ ${srcdir}/${_pkgname}-${pkgver}/htdocs/js/mympd.js -nt ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/js/mympd.min.js ] && \ - java -jar ${srcdir}/${_pkgname}-${pkgver}/dist/buildtools/closure-compiler.jar ${srcdir}/${_pkgname}-${pkgver}/htdocs/js/mympd.js > ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/js/mympd.min.js - [ ${srcdir}/${_pkgname}-${pkgver}/htdocs/sw.js -nt ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/sw.min.js ] && \ - java -jar ${srcdir}/${_pkgname}-${pkgver}/dist/buildtools/closure-compiler.jar ${srcdir}/${_pkgname}-${pkgver}/htdocs/sw.js > ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/sw.min.js - else - echo "${srcdir}/${_pkgname}-${pkgver}/dist/buildtools/closure-compiler.jar not found, using non-minified files" - [ ${srcdir}/${_pkgname}-${pkgver}/htdocs/js/player.js -nt ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/js/player.min.js ] && \ - cp ${srcdir}/${_pkgname}-${pkgver}/htdocs/js/player.js ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/js/player.min.js - [ ${srcdir}/${_pkgname}-${pkgver}/htdocs/js/mympd.js -nt ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/js/mympd.min.js ] && \ - cp ${srcdir}/${_pkgname}-${pkgver}/htdocs/js/mympd.js ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/js/mympd.min.js - [ ${srcdir}/${_pkgname}-${pkgver}/htdocs/sw.js -nt ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/sw.min.js ] && \ - cp ${srcdir}/${_pkgname}-${pkgver}/htdocs/sw.js ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/sw.min.js - fi - - if [ -f ${srcdir}/${_pkgname}-${pkgver}/dist/buildtools/closure-stylesheets.jar ] && [ "$java" != "$NULL" ] - then - echo "Minifying stylesheets" - [ ${srcdir}/${_pkgname}-${pkgver}/htdocs/css/mympd.css -nt ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/css/mympd.min.css ] && \ - java -jar ${srcdir}/${_pkgname}-${pkgver}/dist/buildtools/closure-stylesheets.jar --allow-unrecognized-properties ${srcdir}/${_pkgname}-${pkgver}/htdocs/css/mympd.css > ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/css/mympd.min.css - else - echo "${srcdir}/${_pkgname}-${pkgver}/dist/buildtools/closure-stylesheets.jar not found, using non-minified files" - [ ${srcdir}/${_pkgname}-${pkgver}/htdocs/css/mympd.css -nt ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/css/mympd.min.css ] && \ - cp ${srcdir}/${_pkgname}-${pkgver}/htdocs/css/mympd.css ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/css/mympd.min.css - fi - - echo "Replacing javascript and stylesheets with minified files" - sed -e 's/mympd\.css/mympd\.min\.css/' -e 's/mympd\.js/mympd\.min\.js/' ${srcdir}/${_pkgname}-${pkgver}/htdocs/index.html > ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/index.html - sed -e 's/mympd\.css/mympd\.min\.css/' -e 's/player\.js/player\.min\.js/' ${srcdir}/${_pkgname}-${pkgver}/htdocs/player.html > ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/player.html - sed -i -e 's/mympd\.css/mympd\.min\.css/' -e 's/mympd\.js/mympd\.min\.js/' -e 's/player\.js/player\.min\.js/' ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/sw.min.js - sed -i -e 's/\/sw\.js/\/sw\.min\.js/' ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/js/mympd.min.js - echo "Minifying html" - perl -i -pe 's/^\s*//gm; s/\s*$//gm' ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/index.html - perl -i -pe 's/^\s*//gm; s/\s*$//gm' ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/player.html -} - build() { cd "${srcdir}/${_pkgname}-${pkgver}" @@ -80,4 +36,3 @@ package() { install -Dm644 "${srcdir}/${_pkgname}-${pkgver}/contrib/mympd.service" "$pkgdir/usr/lib/systemd/system/mympd.service" /usr/share/mympd/crcert.sh } - diff --git a/contrib/archlinux.install b/contrib/archlinux.install index 6e10041..133983d 100644 --- a/contrib/archlinux.install +++ b/contrib/archlinux.install @@ -11,7 +11,7 @@ post_upgrade() { [ "$?" = "2" ] && useradd --system -d /var/lib/mympd -s /usr/sbin/nologin -g mympd mympd # fix ownership of /var/lib/mympd - if ! [ $(stat -c '%U:%G' /var/lib/mympd/) == 'mympd:mympd' ] + if ! [ $(stat -c '%U:%G' /var/lib/mympd/) = 'mympd:mympd' ] then echo "INFO: Fixing ownership of /var/lib/mympd" chown -R mympd.mympd /var/lib/mympd @@ -27,6 +27,9 @@ post_upgrade() { echo "/etc/mpd.conf not found, you must link your musicdir manually to /usr/share/mympd/htdocs/library" fi + echo "Linking pics directory" + [ -e /usr/share/mympd/htdocs/pics ] || ln -s /var/lib/mympd/pics /usr/share/mympd/htdocs/ + # install systemd service echo "INFO: Installing systemd service" if [ -d /etc/systemd/system ] @@ -77,18 +80,9 @@ post_remove() { echo -e "\e[93mINFO\e[0m: /etc/mympd/mympd.conf backed up to /etc/mympd/mympd.conf.pacsave" fi - # unlink music dir - echo "unlinking musicdir to library" - [ -e /usr/share/mympd/htdocs/library ] && rm -v /usr/share/mympd/htdocs/library - - # remove mympd user and group - getent passwd mympd > /dev/null - echo -e "\e[93mWARNING\e[0m: Removing \e[1mmympd \e[0muser and group!" - [ "$?" != "2" ] && userdel -r mympd - getent group mympd > /dev/null - [ "$?" != "2" ] && groupdel mympd - # remove leftover directories - rmdir -v /usr/share/{mympd/htdocs/,mympd/} + rm -v -f /usr/share/mympd/htdocs/pics + rm -v -f /usr/share/mympd/htdocs/library + rmdir -v /usr/share/mympd/htdocs/ + rmdir -v /usr/share/mympd/ } - diff --git a/contrib/myMPD.spec b/contrib/myMPD.spec index 9b7da3f..58b864b 100644 --- a/contrib/myMPD.spec +++ b/contrib/myMPD.spec @@ -1,16 +1,16 @@ # # spec file for package myMPD # -# (c) 2018 Juergen Mang Name: myMPD -Version: 4.2.0 +Version: 4.2.1 Release: 0 License: GPL-2.0 Group: Productivity/Multimedia/Sound/Players Summary: Standalone webclient for mpd Url: https://github.com/jcorporation/myMPD -Source: https://github.com/jcorporation/myMPD/archive/v4.2.0.zip +Source: https://github.com/jcorporation/myMPD/archive/v4.2.1.zip BuildRequires: gcc BuildRequires: cmake BuildRequires: unzip @@ -44,15 +44,15 @@ getent group mympd > /dev/null getent passwd mympd > /dev/null [ "$?" = "2" ] && useradd -r mympd -g mympd -d /var/lib/mympd -s /usr/sbin/nologin -if ! [ $(stat -c '%U:%G' /var/lib/mympd/) == 'mympd:mympd' ] +if ! [ $(stat -c '%U:%G' /var/lib/mympd/) = 'mympd:mympd' ] then echo "Fixing ownership of /var/lib/mympd" chown -R mympd.mympd /var/lib/mympd fi -if [ -d /usr/lib/systemd/ ] +if [ -d /etc/systemd ] then - [ -d /usr/lib/systemd/system ] || sudo mkdir /usr/lib/systemd/system + [ -d /usr/lib/systemd/system ] || sudo mkdir -p /usr/lib/systemd/system cp /usr/share/mympd/mympd.service /usr/lib/systemd/system/ systemctl daemon-reload systemctl enable mympd @@ -64,6 +64,8 @@ then [ "$LIBRARY" != "" ] && [ ! -e /usr/share/mympd/htdocs/library ] && ln -s "$LIBRARY" /usr/share/mympd/htdocs/library fi +[ -e /usr/share/mympd/htdocs/pics ] || ln -s /var/lib/mympd/pics /usr/share/mympd/htdocs/ + if [ ! -f /etc/mympd/mympd.conf ] then mv /etc/mympd/mympd.conf.dist /etc/mympd/mympd.conf @@ -74,28 +76,22 @@ fi /usr/share/mympd/crcert.sh %postun -if [ -f /usr/lib/systemd/system/mympd.service ] +if [ "$1" = "0" ] then - if `systemctl is-active --quiet mympd` + if [ -f /usr/lib/systemd/system/mympd.service ] then - echo "stopping mympd.service" && systemctl stop mympd + if `systemctl is-active --quiet mympd` + then + echo "stopping mympd.service" && systemctl stop mympd + fi + echo "disabling mympd.service" && systemctl disable mympd + rm -v -f /usr/lib/systemd/system/mympd.service + systemctl daemon-reload fi - echo "disabling mympd.service" && systemctl disable mympd - rm -v -f /usr/lib/systemd/system/mympd.service - systemctl daemon-reload + rm -v -f /usr/share/mympd/htdocs/pics + rm -v -f /usr/share/mympd/htdocs/library fi -rm -v -fr /var/lib/mympd -[ -e /usr/share/mympd/htdocs/library ] && rm -v /usr/share/mympd/htdocs/library -rmdir -v /usr/share/{mympd/htdocs/,mympd/} - -getent passwd mympd > /dev/null -echo "Removing mympd user and group" -[ "$?" != "2" ] && userdel -r mympd -getent group mympd > /dev/null -[ "$?" != "2" ] && groupdel mympd - - %files %defattr(-,root,root,-) %doc README.md LICENSE @@ -106,5 +102,5 @@ getent group mympd > /dev/null /var/lib/mympd %changelog -* Wed Sep 17 2018 Juergen Mang - master +* Fri Sep 21 2018 Juergen Mang - master - Version from master diff --git a/debian/changelog b/debian/changelog index 0a70634..2d2c8bf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,5 @@ -mympd (4.2.0-1) stable; urgency=medium +mympd (4.2.1-1) stable; urgency=medium * Release from master - -- Juergen Mang Mon, 17 Sep 2018 17:59:00 +0200 + -- Juergen Mang Thu, 20 Sep 2018 19:32:00 +0200 diff --git a/debian/postinst b/debian/postinst index 199efbc..ca6f8d6 100755 --- a/debian/postinst +++ b/debian/postinst @@ -6,7 +6,7 @@ getent group mympd > /dev/null getent passwd mympd > /dev/null [ "$?" = "2" ] && useradd -r mympd -g mympd -d /var/lib/mympd -s /usr/sbin/nologin -if ! [ $(stat -c '%U:%G' /var/lib/mympd/) == 'mympd:mympd' ] +if ! [ $(stat -c '%U:%G' /var/lib/mympd/) = 'mympd:mympd' ] then echo "Fixing ownership of /var/lib/mympd" chown -R mympd.mympd /var/lib/mympd @@ -21,10 +21,13 @@ else echo "/etc/mpd.conf not found, you must link your music_directory manually to /usr/share/mympd/htdocs/library" fi -if [ -d /usr/lib/systemd/ ] +echo "Linking pics directory" +[ -e /usr/share/mympd/htdocs/pics ] || ln -s /var/lib/mympd/pics /usr/share/mympd/htdocs/ + +if [ -d /etc/systemd ] then echo "Installing systemd service" - [ -d /usr/lib/systemd/system ] || mkdir /usr/lib/systemd/system + [ -d /usr/lib/systemd/system ] || mkdir -p /usr/lib/systemd/system if [ contrib/mympd.service -nt /usr/lib/systemd/system/mympd.service ] then cp contrib/mympd.service /usr/lib/systemd/system/ diff --git a/debian/postrm b/debian/postrm index d93626e..9ddda89 100755 --- a/debian/postrm +++ b/debian/postrm @@ -9,13 +9,5 @@ then systemctl daemon-reload fi -rm -v -fr /var/lib/mympd - -[ -e /usr/share/mympd/htdocs/library ] && rm -v /usr/share/mympd/htdocs/library -rmdir -v /usr/share/{mympd/htdocs/,mympd/} - -getent passwd mympd > /dev/null -echo "Removing mympd user and group" -[ "$?" != "2" ] && userdel -r mympd -getent group mympd > /dev/null -[ "$?" != "2" ] && groupdel mympd +rm -v -f /usr/share/mympd/htdocs/pics +rm -v -f /usr/share/mympd/htdocs/library diff --git a/debian/rules b/debian/rules index 132d6ee..20e2c14 100755 --- a/debian/rules +++ b/debian/rules @@ -16,6 +16,7 @@ binary-arch: cd $(BUILDDIR); cmake -P cmake_install.cmake mkdir debian/tmp/DEBIAN cp debian/postinst debian/tmp/DEBIAN + cp debian/postrm debian/tmp/DEBIAN dpkg-gencontrol -pmympd dpkg --build debian/tmp .. diff --git a/dist/htdocs/css/mympd.min.css b/dist/htdocs/css/mympd.min.css index 88b784e..722d16d 100644 --- a/dist/htdocs/css/mympd.min.css +++ b/dist/htdocs/css/mympd.min.css @@ -1 +1 @@ -html{position:relative;min-height:100%}body{margin-bottom:60px;padding-top:50px;padding-bottom:50px;background-color:#888}main{padding-top:20px}footer{position:absolute;bottom:0}button{overflow:hidden}#BrowseBreadrumb{overflow:auto;white-space:nowrap}#BrowseBreadcrumb>li>a{cursor:pointer}.card{min-height:350px}@media only screen and (max-width:576px){.header-logo{display:none!important}}.clickable{cursor:pointer}.tblnum,.tblaction{width:30px}small{color:#aaa}.card-footer-playback{padding:0}.album-cover{background-size:cover;border:1px solid black;border-radius:5px;overflow:hidden;width:240px;height:240px;background-color:#eee;float:left;margin-right:20px;margin-bottom:20px}.album-desc{min-width:240px;float:left}.hide{display:none!important}.pull-right{float:right!important}.card-toolbar{margin-bottom:10px}.card-toolbar>div,.card-toolbar>form{margin-bottom:5px}@font-face{font-family:'Material Icons';font-style:normal;font-weight:400;src:url(/assets/MaterialIcons-Regular.eot);src:local('Material Icons'),local('MaterialIcons-Regular');src:url(/assets/MaterialIcons-Regular.woff2) format('woff2'),url(/assets/MaterialIcons-Regular.woff) format('woff'),url(/assets/MaterialIcons-Regular.ttf) format('truetype')}.material-icons{font-family:'Material Icons';font-weight:normal;font-style:normal;font-size:18px;display:inline-block;line-height:1;text-transform:none;letter-spacing:normal;word-wrap:normal;white-space:nowrap;direction:ltr;vertical-align:top;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-feature-settings:'liga'}.material-icons-small{font-size:16px}.material-icons-small-left{font-size:1rem;margin-left:-1em}.color-darkgrey,.color-darkgrey:hover{color:#6c757d!important}#btn-outputs-block>button{margin-bottom:10px}#btn-outputs-block>button:last-child{margin-bottom:0}.card-body{overflow-x:hidden}.progressBarPlay{font-size:22px}#counter{cursor:text}#volumeBar{margin-top:2px;width:160px}.title-icon{float:left;margin-right:5px;font-size:1.8rem}.header-logo{font-size:2rem;float:left;margin-right:5px}.letters>button{width:28px;height:28px}.col-md{max-width:250px;min-width:250px}a.card-img-top{overflow:hidden;display:block}button.active{color:#fff;background-color:#28a745!important;border-color:#28a745!important}button.active-fg-green{color:#28a745!important}button.active-fg-red{color:#bd2130!important}div#alertBox{position:fixed;top:50px;right:10px;width:80%;max-width:400px;z-index:1000;opacity:0;visibility:visible;transition:opacity .5s ease-in}div.alertBoxActive{opacity:1!important;visibility:visible!important;transition:opacity .5s ease-in}.popover-content{padding-top:4px;padding-bottom:4px}.opacity05{opacity:.5}caption{caption-side:top;font-size:120%;font-weight:bold;color:black}.dragover>td{border-top:25px solid transparent}[draggable]{-moz-user-select:none;-khtml-user-select:none;-webkit-user-select:none;user-select:none;-khtml-user-drag:element;-webkit-user-drag:element}@keyframes changewidth{0%{margin-left:-20px}to{margin-left:100%}}#updateDBprogress{width:20px}.updateDBprogressAnimate{animation-duration:2s;animation-name:changewidth;animation-iteration-count:infinite}.modal-body{overflow-x:hidden}.modal-body .album-cover{float:none}#BrowseDatabaseAlbumListCaption{width:100%;margin-left:15px} \ No newline at end of file +html{position:relative;min-height:100%}body{margin-bottom:60px;padding-top:50px;padding-bottom:50px;background-color:#888}main{padding-top:20px}footer{position:absolute;bottom:0}button{overflow:hidden}#BrowseBreadrumb{overflow:auto;white-space:nowrap}#BrowseBreadcrumb>li>a{cursor:pointer}.card{min-height:350px}@media only screen and (max-width:576px){.header-logo{display:none!important}}.clickable{cursor:pointer}.tblnum,.tblaction{width:30px}small{color:#aaa}.card-footer-playback{padding:0}.album-cover{background-size:cover;border:1px solid black;border-radius:5px;overflow:hidden;width:240px;height:240px;background-color:#eee;float:left;margin-right:20px;margin-bottom:20px}.album-desc{min-width:240px;float:left}.hide{display:none!important}.pull-right{float:right!important}.card-toolbar{margin-bottom:10px}.card-toolbar>div,.card-toolbar>form{margin-bottom:5px}@font-face{font-family:'Material Icons';font-style:normal;font-weight:400;src:url(/assets/MaterialIcons-Regular.eot);src:local('Material Icons'),local('MaterialIcons-Regular');src:url(/assets/MaterialIcons-Regular.woff2) format('woff2'),url(/assets/MaterialIcons-Regular.woff) format('woff'),url(/assets/MaterialIcons-Regular.ttf) format('truetype')}.material-icons{font-family:'Material Icons';font-weight:normal;font-style:normal;font-size:18px;display:inline-block;line-height:1;text-transform:none;letter-spacing:normal;word-wrap:normal;white-space:nowrap;direction:ltr;vertical-align:top;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-feature-settings:'liga'}.material-icons-left{font-size:1rem;margin-left:-1em;vertical-align:middle}.material-icons-small{font-size:16px}.material-icons-small-left{font-size:1rem;margin-left:-1em}.color-darkgrey,.color-darkgrey:hover{color:#6c757d!important}#btn-outputs-block>button{margin-bottom:10px}#btn-outputs-block>button:last-child{margin-bottom:0}.card-body{overflow-x:hidden}.progressBarPlay{font-size:22px}#counter{cursor:text}#volumeBar{margin-top:2px;width:160px}.title-icon{float:left;margin-right:5px;font-size:1.8rem}.header-logo{font-size:2rem;float:left;margin-right:5px}.letters>button{width:28px;height:28px}.col-md{max-width:250px;min-width:250px}a.card-img-top{overflow:hidden;display:block}button.active{color:#fff;background-color:#28a745!important;border-color:#28a745!important}button.active-fg-green{color:#28a745!important}button.active-fg-red{color:#bd2130!important}div#alertBox{position:fixed;top:50px;right:10px;width:80%;max-width:400px;z-index:1000;opacity:0;visibility:visible;transition:opacity .5s ease-in}div.alertBoxActive{opacity:1!important;visibility:visible!important;transition:opacity .5s ease-in}.popover-content{padding-top:4px;padding-bottom:4px}.opacity05{opacity:.5}caption{caption-side:top;font-size:120%;font-weight:bold;color:black}.dragover>td{border-top:25px solid transparent}[draggable]{-moz-user-select:none;-khtml-user-select:none;-webkit-user-select:none;user-select:none;-khtml-user-drag:element;-webkit-user-drag:element}@keyframes changewidth{0%{margin-left:-20px}to{margin-left:100%}}#updateDBprogress{width:20px}.updateDBprogressAnimate{animation-duration:2s;animation-name:changewidth;animation-iteration-count:infinite}.modal-body{overflow-x:hidden}.modal-body .album-cover{float:none}#BrowseDatabaseAlbumListCaption{width:100%;margin-left:15px}#menu-dbupdate{padding-left:1rem} \ No newline at end of file diff --git a/dist/htdocs/index.html b/dist/htdocs/index.html index c20df44..821a2b7 100644 --- a/dist/htdocs/index.html +++ b/dist/htdocs/index.html @@ -1 +1 @@ -myMPD
Playback

Artist

Album

Queue
#TitleArtistAlbumDuration
PlaylistLast modified
Playlist List
#TitleArtistAlbumDuration
Artist

TitleArtistAlbumDuration
Search
TitleArtistAlbumDuration
\ No newline at end of file +myMPD
Playback

Artist

Album

Queue
#TitleArtistAlbumDuration
PlaylistLast modified
Playlist List
#TitleArtistAlbumDuration
Artist

TitleArtistAlbumDuration
Search
TitleArtistAlbumDuration
\ No newline at end of file diff --git a/dist/htdocs/js/mympd.min.js b/dist/htdocs/js/mympd.min.js index e0d8e8e..d1b7331 100644 --- a/dist/htdocs/js/mympd.min.js +++ b/dist/htdocs/js/mympd.min.js @@ -26,22 +26,23 @@ if("Playback"==app.current.app)sendAPI({cmd:"MPD_API_PLAYER_CURRENT_SONG"},songC app.last.app!=app.current.app&&""!=app.current.search&&(document.getElementById("SearchList").getElementsByTagName("tbody")[0].innerHTML='searchSearching...'),2<=app.current.search.length?sendAPI({cmd:"MPD_API_DATABASE_SEARCH",data:{plist:"",offset:app.current.page,filter:app.current.filter,searchstr:app.current.search}},parseSearch):(document.getElementById("SearchList").getElementsByTagName("tbody")[0].innerHTML="",document.getElementById("searchAddAllSongs").setAttribute("disabled", "disabled"),document.getElementById("searchAddAllSongsBtn").setAttribute("disabled","disabled"),document.getElementById("panel-heading-search").innerText="",document.getElementById("SearchList").classList.remove("opacity05"),setPagination(0)),selectTag("searchtags","searchtagsdesc",app.current.filter)):appGoto("Playback");app.last.app=app.current.app;app.last.tab=app.current.tab;app.last.view=app.current.view}else appGoto("Playback")} function appInit(){getSettings();sendAPI({cmd:"MPD_API_PLAYER_STATE"},parseState);webSocketConnect();domCache.volumeBar.value=0;domCache.volumeBar.addEventListener("click",function(a){a.stopPropagation()},!1);domCache.volumeBar.addEventListener("change",function(a){sendAPI({cmd:"MPD_API_PLAYER_VOLUME",data:{volume:domCache.volumeBar.value}})},!1);domCache.progressBar.value=0;domCache.progressBar.addEventListener("change",function(a){currentSong&&0<=currentSong.currentSongId&&sendAPI({cmd:"MPD_API_PLAYER_SEEK", -data:{songid:currentSong.currentSongId,seek:Math.ceil(domCache.progressBar.value/100*currentSong.totalTime)}})},!1);document.getElementById("volumeIcon").parentNode.addEventListener("show.bs.dropdown",function(){sendAPI({cmd:"MPD_API_PLAYER_OUTPUT_LIST"},parseOutputs)});document.getElementById("modalAbout").addEventListener("shown.bs.modal",function(){sendAPI({cmd:"MPD_API_DATABASE_STATS"},parseStats)});document.getElementById("modalUpdateDB").addEventListener("hidden.bs.modal",function(){document.getElementById("updateDBprogress").classList.remove("updateDBprogressAnimate")}); -document.getElementById("modalSaveQueue").addEventListener("shown.bs.modal",function(){var a=document.getElementById("saveQueueName");a.focus();a.value="";a.classList.remove("is-invalid");document.getElementById("saveQueueFrm").classList.remove("was-validated")});document.getElementById("modalSettings").addEventListener("shown.bs.modal",function(){getSettings();document.getElementById("settingsFrm").classList.remove("was-validated");document.getElementById("inputCrossfade").classList.remove("is-invalid"); -document.getElementById("inputMixrampdb").classList.remove("is-invalid");document.getElementById("inputMixrampdelay").classList.remove("is-invalid")});document.getElementById("addToPlaylistPlaylist").addEventListener("change",function(a){"New Playlist"==this.options[this.selectedIndex].text?(document.getElementById("addToPlaylistNewPlaylistDiv").classList.remove("hide"),document.getElementById("addToPlaylistNewPlaylist").focus()):document.getElementById("addToPlaylistNewPlaylistDiv").classList.add("hide")}, -!1);addFilterLetter("BrowseFilesystemFilterLetters");addFilterLetter("BrowseDatabaseFilterLetters");addFilterLetter("BrowsePlaylistsFilterLetters");for(var a=document.querySelectorAll("[data-href]"),b=a.length,c=0;cd?"0":"")+d}c+=""+f+""+d+""}c+='Uri'+a.data.uri+"";if(1==settings.stickers){var f="not voted";0==a.data.like?f='thumb_down_alt':2==a.data.like&&(f='thumb_up_alt');c+='StatisticsPlay count'+a.data.playCount+"Skip count"+a.data.skipCount+"Last played"+(0==a.data.lastPlayed?"never":(new Date(1E3*d)).toUTCString())+"Like"+ +'">'+a.data.uri+"";if(1==settings.stickers){var f="not voted";0==a.data.like?f='thumb_down_alt':2==a.data.like&&(f='thumb_up_alt');c+='StatisticsPlay count'+a.data.playCount+"Skip count"+a.data.skipCount+"Last played"+(0==a.data.lastPlayed?"never":(new Date(1E3*a.data.lastPlayed)).toUTCString())+"Like"+ f+""}b.getElementsByTagName("tbody")[0].innerHTML=c}function playlistDetails(a){appGoto("Browse","Playlists","Detail","0/-/"+a)}function removeFromPlaylist(a,b){b--;sendAPI({cmd:"MPD_API_PLAYLIST_RM_TRACK",data:{uri:a,track:b}});document.getElementById("BrowsePlaylistsDetailList").classList.add("opacity05");sendAPI({cmd:"MPD_API_PLAYLIST_CONTENT_LIST",data:{offset:app.current.page,filter:app.current.filter,uri:app.current.search}},parsePlaylists)} function playlistClear(){var a=document.getElementById("BrowsePlaylistsDetailList").getAttribute("data-uri");sendAPI({cmd:"MPD_API_PLAYLIST_CLEAR",data:{uri:a}});document.getElementById("BrowsePlaylistsDetailList").classList.add("opacity05");sendAPI({cmd:"MPD_API_PLAYLIST_CONTENT_LIST",data:{offset:app.current.page,filter:app.current.filter,uri:app.current.search}},parsePlaylists)} function getAllPlaylists(a){var b=a.data.length,c="";0==a.offset&&("addToPlaylistPlaylist"==playlistEl?c="":"jukeboxPlaylist"==playlistEl&&(c=""));for(var d=0;d";0==a.offset?document.getElementById(playlistEl).innerHTML=c:document.getElementById(playlistEl).innerHTML+=c;a.totalEntities>a.returnedEntities&& @@ -120,7 +121,7 @@ options:[d]},"Rename playlist")+addMenuItem({cmd:"delPlaylist",options:[d]},"Del a.stopPropagation();if("A"==a.target.nodeName&&(a=a.target.getAttribute("data-href"))){a=JSON.parse(atob(a));if("function"===typeof window[a.cmd])switch(a.cmd){case "sendAPI":sendAPI.apply(null,$jscomp.arrayFromIterable(a.options));break;default:window[a.cmd].apply(null,$jscomp.arrayFromIterable(a.options))}g.hide()}},!1);if(a=document.getElementById("advancedMenuLink"))a.addEventListener("click",function(a){a=this.getElementsByTagName("span")[0];a.innerText="keyboard_arrow_right"==a.innerText?"keyboard_arrow_down": "keyboard_arrow_right"},!1),new Collapse(a)},!1));g.show()} function sendAPI(a,b){var c=new XMLHttpRequest;c.open("POST","/api",!0);c.setRequestHeader("Content-type","application/json");c.onreadystatechange=function(){if(4==c.readyState)if(""!=c.responseText){var d=JSON.parse(c.responseText);"error"==d.type?(showNotification("Error",d.data,d.data,"danger"),console.log("Error: "+d.data)):"result"==d.type&&"ok"!=d.data?showNotification(d.data,"","","success"):void 0!=b&&"function"==typeof b&&b(d)}else console.log("Empty response for request: "+JSON.stringify(a))}; -c.send(JSON.stringify(a))}function openLocalPlayer(){window.open("/player.html#"+settings.mpdstream,"LocalPlayer")}function updateDB(){sendAPI({cmd:"MPD_API_DATABASE_UPDATE"});updateDBstarted(!0)} +c.send(JSON.stringify(a))}function openLocalPlayer(){window.open("/player.html#"+settings.mpdstream,"LocalPlayer")}function updateDB(){sendAPI({cmd:"MPD_API_DATABASE_UPDATE"});updateDBstarted(!0)}function rescanDB(){sendAPI({cmd:"MPD_API_DATABASE_RESCAN"});updateDBstarted(!0)} function updateDBstarted(a){1==a?(document.getElementById("updateDBfinished").innerText="",document.getElementById("updateDBfooter").classList.add("hide"),updateDBprogress.style.width="20px",updateDBprogress.style.marginLeft="-20px",modalUpdateDB.show(),document.getElementById("updateDBprogress").classList.add("updateDBprogressAnimate")):showNotification("Database update started","","","success")} function updateDBfinished(a){document.getElementById("modalUpdateDB").classList.contains("show")?("update_database"==a?document.getElementById("updateDBfinished").innerText="Database successfully updated.":"update_finished"==a&&(document.getElementById("updateDBfinished").innerText="Database update finished."),a=document.getElementById("updateDBprogress"),a.classList.remove("updateDBprogressAnimate"),a.style.width="100%",a.style.marginLeft="0px",document.getElementById("updateDBfooter").classList.remove("hide")): "update_database"==a?showNotification("Database successfully updated.","","","success"):"update_finished"==a&&showNotification("Database update finished.","","","success")}function clickPlay(){"play"!=playstate?sendAPI({cmd:"MPD_API_PLAYER_PLAY"}):sendAPI({cmd:"MPD_API_PLAYER_PAUSE"})}function clickStop(){sendAPI({cmd:"MPD_API_PLAYER_STOP"})}function clickPrev(){sendAPI({cmd:"MPD_API_PLAYER_PREV"})}function clickNext(){sendAPI({cmd:"MPD_API_PLAYER_NEXT"})} diff --git a/dist/htdocs/sw.min.js b/dist/htdocs/sw.min.js index 01bc1cc..5b46321 100644 --- a/dist/htdocs/sw.min.js +++ b/dist/htdocs/sw.min.js @@ -10,5 +10,5 @@ function(){function a(a){return function(d){c||(c=!0,a.call(b,d))}}var b=this,c= void 0;try{d=a.then}catch(h){this.reject_(h);return}"function"==typeof d?this.settleSameAsThenable_(d,a):this.fulfill_(a)};c.prototype.reject_=function(a){this.settle_(2,a)};c.prototype.fulfill_=function(a){this.settle_(1,a)};c.prototype.settle_=function(a,b){if(0!=this.state_)throw Error("Cannot settle("+a+", "+b+"): Promise already settled in state"+this.state_);this.state_=a;this.result_=b;this.executeOnSettledCallbacks_()};c.prototype.executeOnSettledCallbacks_=function(){if(null!=this.onSettledCallbacks_){for(var a= 0;a - + @@ -24,7 +24,11 @@ - + diff --git a/htdocs/js/mympd.js b/htdocs/js/mympd.js index 9fab572..0f750ab 100644 --- a/htdocs/js/mympd.js +++ b/htdocs/js/mympd.js @@ -309,6 +309,16 @@ function appInit() { sendAPI({"cmd": "MPD_API_PLAYER_SEEK", "data": {"songid": currentSong.currentSongId, "seek": seekVal}}); } }, false); + + document.getElementById('navDBupdate').addEventListener('click', function(event) { + event.stopPropagation(); + event.preventDefault(); + var icon = this.getElementsByTagName('span')[0]; + if (icon.innerText == 'keyboard_arrow_right') + icon.innerText = 'keyboard_arrow_down'; + else + icon.innerText = 'keyboard_arrow_right'; + }, false); document.getElementById('volumeIcon').parentNode.addEventListener('show.bs.dropdown', function () { sendAPI({"cmd": "MPD_API_PLAYER_OUTPUT_LIST"}, parseOutputs); @@ -550,7 +560,7 @@ function appInit() { if ('serviceWorker' in navigator && document.URL.substring(0, 5) == 'https') { window.addEventListener('load', function() { - navigator.serviceWorker.register('/sw.js', {scope: '/'}).then(function(registration) { + navigator.serviceWorker.register('/sw.min.js', {scope: '/'}).then(function(registration) { // Registration was successful console.log('ServiceWorker registration successful with scope: ', registration.scope); registration.update(); @@ -1482,7 +1492,7 @@ function parseSongDetails(obj) { songDetails += 'Statistics' + 'Play count' + obj.data.playCount + '' + 'Skip count' + obj.data.skipCount + '' + - 'Last played' + (obj.data.lastPlayed == 0 ? 'never' : new Date(value * 1000).toUTCString()) + '' + + 'Last played' + (obj.data.lastPlayed == 0 ? 'never' : new Date(obj.data.lastPlayed * 1000).toUTCString()) + '' + 'Like' + like + ''; } @@ -1840,6 +1850,11 @@ function updateDB() { updateDBstarted(true); } +function rescanDB() { + sendAPI({"cmd": "MPD_API_DATABASE_RESCAN"}); + updateDBstarted(true); +} + function updateDBstarted(showModal) { if (showModal == true) { document.getElementById('updateDBfinished').innerText = ''; diff --git a/htdocs/player.html b/htdocs/player.html index 3752433..c3ac9b9 100644 --- a/htdocs/player.html +++ b/htdocs/player.html @@ -7,7 +7,7 @@ myMPD: Local Player - + @@ -29,6 +29,6 @@ - + diff --git a/htdocs/sw.js b/htdocs/sw.js index 3e63157..a163b4e 100644 --- a/htdocs/sw.js +++ b/htdocs/sw.js @@ -1,12 +1,12 @@ -var CACHE = 'myMPD-cache-v4.2.0'; +var CACHE = 'myMPD-cache-v4.2.1'; var urlsToCache = [ '/', '/player.html', '/css/bootstrap.min.css', - '/css/mympd.css', + '/css/mympd.min.css', '/js/bootstrap-native-v4.min.js', - '/js/mympd.js', - '/js/player.js', + '/js/mympd.min.js', + '/js/player.min.js', '/assets/appicon-167.png', '/assets/appicon-192.png', '/assets/appicon-512.png', @@ -28,15 +28,16 @@ self.addEventListener('install', function(event) { }); self.addEventListener('fetch', function(event) { - event.respondWith( - caches.match(event.request).then(function(response) { - if (response) - return response - else - return fetch(event.request); - } - ) - ); + if (event.request.url.match('^http://')) + return false; + event.respondWith( + caches.match(event.request).then(function(response) { + if (response) + return response + else + return fetch(event.request); + }) + ); }); self.addEventListener('activate', function(event) { diff --git a/mkclean.sh b/mkclean.sh index 0ccc345..688a570 100755 --- a/mkclean.sh +++ b/mkclean.sh @@ -3,6 +3,16 @@ rm -rf release rm -rf debug rm -rf debian/tmp rm -f debian/files + +rm -f htdocs/library +rm -f htdocs/pics + +rm -f htdocs/sw.min.js +rm -f htdocs/js/mympd.min.js +rm -f htdocs/js/player.min.js rm -f htdocs/js/bootstrap-native-v4.min.js + +rm -f htdocs/css/mympd.min.css rm -f htdocs/css/bootstrap.min.css + find ./ -name \*~ -delete diff --git a/mkdebian.sh b/mkdebian.sh index 45e05dc..5214536 100755 --- a/mkdebian.sh +++ b/mkdebian.sh @@ -1,4 +1,4 @@ #!/bin/bash ./mkclean.sh -tar -czvf ../mympd_4.2.0.orig.tar.gz * +tar -czvf ../mympd_4.2.1.orig.tar.gz * dpkg-buildpackage -rfakeroot diff --git a/mkdebug.sh b/mkdebug.sh index f46b39a..dfcd094 100755 --- a/mkdebug.sh +++ b/mkdebug.sh @@ -1,7 +1,23 @@ #/bin/sh +[ -e $PWD/htdocs/sw.min.js ] || ln -s $PWD/htdocs/sw.js $PWD/htdocs/sw.min.js +[ -e $PWD/htdocs/js/mympd.min.js ] || ln -s $PWD/htdocs/js/mympd.js $PWD/htdocs/js/mympd.min.js +[ -e $PWD/htdocs/js/player.min.js ] || ln -s $PWD/htdocs/js/player.js $PWD/htdocs/js/player.min.js +[ -e $PWD/htdocs/js/bootstrap-native-v4.min.js ] || ln -s $PWD/dist/htdocs/js/bootstrap-native-v4.js $PWD/htdocs/js/bootstrap-native-v4.min.js -cp dist/htdocs/js/bootstrap-native-v4.min.js htdocs/js/ -cp dist/htdocs/css/bootstrap.min.css htdocs/css/ +[ -e $PWD/htdocs/css/mympd.min.css ] || ln -s $PWD/htdocs/css/mympd.css $PWD/htdocs/css/mympd.min.css +[ -e $PWD/htdocs/css/bootstrap.min.css ] || ln -s $PWD/dist/htdocs/css/bootstrap.min.css $PWD/htdocs/css/bootstrap.min.css + +echo "Trying to link musicdir to library" +if [ -f /etc/mpd.conf ] +then + LIBRARY=$(grep ^music_directory /etc/mpd.conf | awk {'print $2'} | sed -e 's/"//g') + [ "$LIBRARY" != "" ] && [ ! -e htdocs/library ] && ln -s "$LIBRARY" htdocs/library +else + echo "/etc/mpd.conf not found, you must link your music_directory manually to htdocs/library" +fi + +echo "Linking pics directory" +[ -e $PWD/htdocs/pics ] || ln -s /var/lib/mympd/pics htdocs/ [ -d debug ] || mkdir debug cd debug diff --git a/mkrelease.sh b/mkrelease.sh index f2f346c..89f8fb8 100755 --- a/mkrelease.sh +++ b/mkrelease.sh @@ -32,14 +32,11 @@ else cp htdocs/css/mympd.css dist/htdocs/css/mympd.min.css fi -echo "Replacing javascript and stylesheets with minified files" -sed -e 's/mympd\.css/mympd\.min\.css/' -e 's/mympd\.js/mympd\.min\.js/' htdocs/index.html > dist/htdocs/index.html -sed -e 's/mympd\.css/mympd\.min\.css/' -e 's/player\.js/player\.min\.js/' htdocs/player.html > dist/htdocs/player.html -sed -i -e 's/mympd\.css/mympd\.min\.css/' -e 's/mympd\.js/mympd\.min\.js/' -e 's/player\.js/player\.min\.js/' dist/htdocs/sw.min.js -sed -i -e 's/\/sw\.js/\/sw\.min\.js/' dist/htdocs/js/mympd.min.js echo "Minifying html" -perl -i -pe 's/^\s*//gm; s/\s*$//gm' dist/htdocs/index.html -perl -i -pe 's/^\s*//gm; s/\s*$//gm' dist/htdocs/player.html +[ htdocs/index.html -nt dist/htdocs/index.html ] && \ + perl -pe 's/^\s*//gm; s/\s*$//gm' htdocs/index.html > dist/htdocs/index.html +[ htdocs/player.html -nt dist/htdocs/player.html ] && \ + perl -pe 's/^\s*//gm; s/\s*$//gm' htdocs/player.html > dist/htdocs/player.html echo "Compiling and installing mympd" [ -d release ] || mkdir release @@ -50,3 +47,6 @@ sudo make install cd .. debian/postinst + +echo "Running cppcheck" +[ -x /usr/bin/cppcheck ] && cppcheck --enable=warning --inconclusive --force --inline-suppr src/*.c src/*.h diff --git a/src/mpd_client.c b/src/mpd_client.c index 1814ec8..cdbcfd7 100644 --- a/src/mpd_client.c +++ b/src/mpd_client.c @@ -179,6 +179,11 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg) { if (uint_rc > 0) n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}"); break; + case MPD_API_DATABASE_RESCAN: + uint_rc = mpd_run_rescan(mpd.conn, NULL); + if (uint_rc > 0) + n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}"); + break; case MPD_API_PLAYER_PAUSE: mpd_run_toggle_pause(mpd.conn); n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}"); diff --git a/src/mpd_client.h b/src/mpd_client.h index f0d3e02..96763a1 100644 --- a/src/mpd_client.h +++ b/src/mpd_client.h @@ -74,6 +74,7 @@ X(MPD_API_PLAYLIST_CONTENT_LIST) \ X(MPD_API_DATABASE_SEARCH) \ X(MPD_API_DATABASE_UPDATE) \ + X(MPD_API_DATABASE_RESCAN) \ X(MPD_API_DATABASE_FILESYSTEM_LIST) \ X(MPD_API_DATABASE_TAG_LIST) \ X(MPD_API_DATABASE_TAG_ALBUM_LIST) \