mirror of
https://github.com/danbee/neompc
synced 2025-03-04 08:39:10 +00:00
~ Fixed problems with apostrophes and ampersands in paths/names. Still need to sort out international characters.
+ Tracks in an album are now sorted by tracknumber. + Added config file.
This commit is contained in:
parent
31167a15f4
commit
b46e8f7441
13
config/config.inc.php
Normal file
13
config/config.inc.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**************************************
|
||||||
|
** NeoMPC Config File
|
||||||
|
**************************************/
|
||||||
|
|
||||||
|
$_CONFIG['music_directory'] = '/var/lib/mpd/music';
|
||||||
|
|
||||||
|
$_CONFIG['template'] = 'default';
|
||||||
|
|
||||||
|
$_CONFIG['sort_by_tracknumber'] = true;
|
||||||
|
|
||||||
|
?>
|
||||||
@ -11,6 +11,6 @@
|
|||||||
require("lib/page.php");
|
require("lib/page.php");
|
||||||
|
|
||||||
/* output the template */
|
/* output the template */
|
||||||
$smarty->display('default/index.html');
|
$smarty->display($_CONFIG['template'] . '/index.html');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -94,4 +94,4 @@
|
|||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Smarty stuff */
|
/* Smarty stuff */
|
||||||
|
|
||||||
|
require('config/config.inc.php');
|
||||||
|
|
||||||
define('SMARTY_DIR', 'lib/smarty/libs/');
|
define('SMARTY_DIR', 'lib/smarty/libs/');
|
||||||
require(SMARTY_DIR . 'Smarty.class.php');
|
require(SMARTY_DIR . 'Smarty.class.php');
|
||||||
@ -15,6 +17,12 @@
|
|||||||
if (!$mympd->connected) {
|
if (!$mympd->connected) {
|
||||||
echo "<p>Problem connecting to MPD!</p>";
|
echo "<p>Problem connecting to MPD!</p>";
|
||||||
exit;
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* track number sorting function */
|
||||||
|
|
||||||
|
function track_sort($a, $b) {
|
||||||
|
return $a['Track'] - $b['Track'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* setup some global vars */
|
/* setup some global vars */
|
||||||
@ -43,10 +51,12 @@
|
|||||||
/* do the same with the current browse position */
|
/* do the same with the current browse position */
|
||||||
if ($_GET['browse']) {
|
if ($_GET['browse']) {
|
||||||
$browse = $_GET['browse'];
|
$browse = $_GET['browse'];
|
||||||
setcookie('browse', $browse);
|
setcookie('browse', stripslashes($browse));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$browse = $_COOKIE['browse'];
|
$browse = $_COOKIE['browse'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$browse = stripslashes($browse);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
20
lib/page.php
20
lib/page.php
@ -25,7 +25,9 @@
|
|||||||
$browse = '';
|
$browse = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$browse_list = explode('/', $browse);
|
$browse_list = explode('/', $browse);
|
||||||
|
|
||||||
|
//print_r($browse);
|
||||||
|
|
||||||
if ($browse) {
|
if ($browse) {
|
||||||
|
|
||||||
@ -40,8 +42,18 @@
|
|||||||
|
|
||||||
if (!$browselist) {
|
if (!$browselist) {
|
||||||
$browselist = $mympd->GetDir($browse);
|
$browselist = $mympd->GetDir($browse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_CONFIG['sort_by_tracknumber']) {
|
||||||
|
usort($browselist, "track_sort");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
echo '<pre>';
|
||||||
|
print_r($browselist);
|
||||||
|
echo '</pre>';
|
||||||
|
//*/
|
||||||
|
|
||||||
foreach ($browselist as $key => $browselist_item) {
|
foreach ($browselist as $key => $browselist_item) {
|
||||||
|
|
||||||
|
|
||||||
@ -73,4 +85,4 @@
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
<li>• <a href="index.php?browse=/"><img src="images/home.gif" alt="Home" /></a></li>
|
<li>• <a href="index.php?browse=/"><img src="images/home.gif" alt="Home" /></a></li>
|
||||||
|
|
||||||
{foreach from=$dir_list item=dir_list_item}
|
{foreach from=$dir_list item=dir_list_item}
|
||||||
<li>• <a href="index.php?browse={$dir_list_item.path|escape:'url'}">{$dir_list_item.name}</a></li>
|
<li>• <a href="index.php?browse={$dir_list_item.path|escape:'url'}">{$dir_list_item.name|escape:'html'}</a></li>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
|
|
||||||
{if $browselist_item.directory}
|
{if $browselist_item.directory}
|
||||||
|
|
||||||
<li><a href="index.php?browse={$browselist_item.directory|escape:'url'}"><img src="images/dir.gif" class="icon" /> {$browselist_item.directory_name}</a></li>
|
<li><a href="index.php?browse={$browselist_item.directory|escape:'url'}"><img src="images/dir.gif" class="icon" /> {$browselist_item.directory_name|escape:'html'}</a></li>
|
||||||
|
|
||||||
{else}
|
{else}
|
||||||
|
|
||||||
{if $browselist_item.in_playlist}<li style="background: #555;">{else}<li>{/if}<a href="{$browselist_add_link}{$browselist_item.file}"><img src="images/add.gif" alt="Add" class="button" /></a><a href="{$browselist_play_link}{$browselist_item.file}"><img src="images/play.gif" alt="Play" class="button" /></a><img src="images/note.gif" class="icon" /> {if $browselist_item.Title}<span class="title">{$browselist_item.Title}</span><br /><span class="artist">{$browselist_item.Artist}</span> <span class="album">({$browselist_item.Album})</span>{else}{$browselist_item.file}{/if}</li>
|
{if $browselist_item.in_playlist}<li style="background: #555;">{else}<li>{/if}<a href="{$browselist_add_link}{$browselist_item.file|escape:'url'}"><img src="images/add.gif" alt="Add" class="button" /></a><a href="{$browselist_play_link}{$browselist_item.file|escape:'url'}"><img src="images/play.gif" alt="Play" class="button" /></a><img src="images/note.gif" class="icon" /> {if $browselist_item.Title|escape:'html'}<span class="title">{$browselist_item.Title|escape:'html'}</span><br /><span class="artist">{$browselist_item.Artist|escape:'html'}</span> <span class="album">({$browselist_item.Album|escape:'html'})</span>{else}{$browselist_item.file|escape:'html'}{/if}</li>
|
||||||
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user