Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Naomi Aro 2012-04-25 12:51:00 +02:00
commit 7aeddf5bb0
15 changed files with 122 additions and 60 deletions

View File

@ -42,4 +42,25 @@ class Application_Common_OsPath{
else else
return '.'; return '.';
} }
/* Similar to the os.path.join python method
* http://stackoverflow.com/a/1782990/276949 */
function join() {
$args = func_get_args();
$paths = array();
foreach($args as $arg) {
$paths = array_merge($paths, (array)$arg);
}
foreach($paths as &$path) {
$path = trim($path, DIRECTORY_SEPARATOR);
}
if (substr($args[0], 0, 1) == DIRECTORY_SEPARATOR) {
$paths[0] = DIRECTORY_SEPARATOR . $paths[0];
}
return join(DIRECTORY_SEPARATOR, $paths);
}
} }

View File

@ -37,12 +37,13 @@ $ccAcl->allow('G', 'index')
->allow('H', 'usersettings') ->allow('H', 'usersettings')
->allow('H', 'plupload') ->allow('H', 'plupload')
->allow('H', 'library') ->allow('H', 'library')
->allow('H', 'playlist') ->allow('H', 'playlist')
->allow('A', 'playouthistory') ->allow('H', 'audiopreview')
->allow('A', 'user') ->allow('A', 'playouthistory')
->allow('A', 'systemstatus') ->allow('A', 'user')
->allow('A', 'preference') ->allow('A', 'systemstatus')
->allow('A', 'audiopreview'); ->allow('A', 'preference');
$aclPlugin = new Zend_Controller_Plugin_Acl($ccAcl); $aclPlugin = new Zend_Controller_Plugin_Acl($ccAcl);

View File

@ -98,7 +98,7 @@ class AudiopreviewController extends Zend_Controller_Action
$pl = new Application_Model_Playlist($playlistID); $pl = new Application_Model_Playlist($playlistID);
$result = Array(); $result = Array();
foreach ( $pl->getContents() as $track ){ foreach ( $pl->getContents(true) as $track ){
$elementMap = array( 'element_title' => isset($track['CcFiles']['track_title'])?$track['CcFiles']['track_title']:"", $elementMap = array( 'element_title' => isset($track['CcFiles']['track_title'])?$track['CcFiles']['track_title']:"",
'element_artist' => isset($track['CcFiles']['artist_name'])?$track['CcFiles']['artist_name']:"", 'element_artist' => isset($track['CcFiles']['artist_name'])?$track['CcFiles']['artist_name']:"",
@ -115,7 +115,7 @@ class AudiopreviewController extends Zend_Controller_Action
} }
$result[] = $elementMap; $result[] = $elementMap;
} }
$this->_helper->json($result); $this->_helper->json($result);
} }

View File

@ -373,7 +373,7 @@ class ScheduleController extends Zend_Controller_Action
$this->view->switch_status = $switch_status; $this->view->switch_status = $switch_status;
$this->view->entries = $range; $this->view->entries = $range;
$this->view->show_name = $show[0]["name"]; $this->view->show_name = isset($show[0])?$show[0]["name"]:"";
} }
public function removeGroupAction() public function removeGroupAction()
@ -752,12 +752,11 @@ class ScheduleController extends Zend_Controller_Action
//Changing the start date was disabled, since the //Changing the start date was disabled, since the
//array key does not exist. We need to repopulate this entry from the db. //array key does not exist. We need to repopulate this entry from the db.
//The start date will be returned in UTC time, so lets convert it to local time. //The start date will be returned in UTC time, so lets convert it to local time.
$dt = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartDate()); $dt = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartDateAndTime());
$data['add_show_start_date'] = $dt->format("Y-m-d"); $data['add_show_start_date'] = $dt->format("Y-m-d");
if (!array_key_exists('add_show_start_time', $data)){ if (!array_key_exists('add_show_start_time', $data)){
$startTime = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartTime()); $data['add_show_start_time'] = $dt->format("H:i");
$data['add_show_start_time'] = $startTime->format("H:i");
$validateStartTime = false; $validateStartTime = false;
} }
$validateStartDate = false; $validateStartDate = false;

View File

@ -99,10 +99,8 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
$live_dj_connection_url = "N/A"; $live_dj_connection_url = "N/A";
} }
$overrideDescription = "If Airtime is behind a router or firewall, you may need to configure port forwarding and this field information will be incorrect. In this case you will need to manually update this field so it shows the correct host/port/mount that your DJ's need to connect to. The allowed range is between 1024 and 49151. For more detail, please read the <a target=\"_blank\" href=\"http://manuals.sourcefabric.org/\">Airtime manual</a>.";
$this->setDecorators(array( $this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml', 'master_dj_connection_url'=>$master_dj_connection_url, 'live_dj_connection_url'=>$live_dj_connection_url,'overrideDescription' => $overrideDescription)) array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml', 'master_dj_connection_url'=>$master_dj_connection_url, 'live_dj_connection_url'=>$live_dj_connection_url))
)); ));
} }

View File

@ -140,18 +140,26 @@ class Application_Model_Playlist {
/** /**
* Get the entire playlist as a two dimentional array, sorted in order of play. * Get the entire playlist as a two dimentional array, sorted in order of play.
* @param boolean $filterFiles if this is true, it will only return files that has
* file_exists flag set to true
* @return array * @return array
*/ */
public function getContents() { public function getContents($filterFiles=false) {
Logging::log("Getting contents for playlist {$this->id}"); Logging::log("Getting contents for playlist {$this->id}");
$files = array(); $files = array();
$rows = CcPlaylistcontentsQuery::create() $query = CcPlaylistcontentsQuery::create()
->joinWith('CcFiles') ->filterByDbPlaylistId($this->id);
->orderByDbPosition()
->filterByDbPlaylistId($this->id) if($filterFiles){
->find($this->con); $query->useCcFilesQuery()
->filterByDbFileExists(true)
->endUse();
}
$query->orderByDbPosition()
->leftJoinWith('CcFiles');
$rows = $query->find($this->con);
$i = 0; $i = 0;
$offset = 0; $offset = 0;

View File

@ -557,15 +557,15 @@ class Application_Model_Show {
$con->exec($sql); $con->exec($sql);
} }
/** /**
* Get the start date of the current show in UTC timezone. * Get the start date of the current show in UTC timezone.
* *
* @return string * @return string
* The start date in the format YYYY-MM-DD * The start date in the format YYYY-MM-DD
*/ */
public function getStartDate(){ public function getStartDateAndTime(){
$con = Propel::getConnection(); $con = Propel::getConnection();
$showId = $this->getId(); $showId = $this->getId();
$sql = "SELECT first_show, start_time, timezone FROM cc_show_days" $sql = "SELECT first_show, start_time, timezone FROM cc_show_days"
@ -583,10 +583,21 @@ class Application_Model_Show {
$dt = new DateTime($row["first_show"]." ".$row["start_time"], new DateTimeZone($row["timezone"])); $dt = new DateTime($row["first_show"]." ".$row["start_time"], new DateTimeZone($row["timezone"]));
$dt->setTimezone(new DateTimeZone("UTC")); $dt->setTimezone(new DateTimeZone("UTC"));
return $dt->format("Y-m-d"); return $dt->format("Y-m-d H:i");
} }
} }
/**
* Get the start date of the current show in UTC timezone.
*
* @return string
* The start date in the format YYYY-MM-DD
*/
public function getStartDate(){
list($date,) = explode(" ", $this->getStartDateAndTime());
return $date;
}
/** /**
* Get the start time of the current show in UTC timezone. * Get the start time of the current show in UTC timezone.
* *
@ -595,25 +606,8 @@ class Application_Model_Show {
*/ */
public function getStartTime(){ public function getStartTime(){
$con = Propel::getConnection(); list(,$time) = explode(" ", $this->getStartDateAndTime());
return $time;
$showId = $this->getId();
$sql = "SELECT first_show, start_time, timezone FROM cc_show_days"
." WHERE show_id = $showId"
." ORDER BY first_show"
." LIMIT 1";
$query = $con->query($sql);
if ($query->rowCount() == 0){
return "";
} else {
$rows = $query->fetchAll();
$row = $rows[0];
$dt = new DateTime($row["first_show"]." ".$row["start_time"], new DateTimeZone($row["timezone"]));
$dt->setTimezone(new DateTimeZone("UTC"));
return $dt->format("H:i");
}
} }
/** /**
@ -856,8 +850,8 @@ class Application_Model_Show {
." WHERE date(starts) = date(TIMESTAMP '$timestamp') " ." WHERE date(starts) = date(TIMESTAMP '$timestamp') "
." AND show_id = $showId"; ." AND show_id = $showId";
$query = $con->query(); $query = $con->query($sql);
$row = $query ? $query->fetchColumn(0) : null; $row = ($query !== false) ? $query->fetchColumn(0) : null;
return CcShowInstancesQuery::create() return CcShowInstancesQuery::create()
->findPk($row); ->findPk($row);
} }

View File

@ -224,7 +224,7 @@ class Application_Model_ShowBuilder {
$this->getScheduledStatus($startsEpoch, min($endsEpoch, $showEndEpoch), $row); $this->getScheduledStatus($startsEpoch, min($endsEpoch, $showEndEpoch), $row);
$row["id"] = intval($p_item["sched_id"]); $row["id"] = intval($p_item["sched_id"]);
$row["image"] = $p_item["file_exists"] == "t" ? true : false; $row["image"] = $p_item["file_exists"];
$row["instance"] = intval($p_item["si_id"]); $row["instance"] = intval($p_item["si_id"]);
$row["starts"] = $schedStartDT->format("H:i:s"); $row["starts"] = $schedStartDT->format("H:i:s");
$row["ends"] = $schedEndDT->format("H:i:s"); $row["ends"] = $schedEndDT->format("H:i:s");

View File

@ -841,8 +841,7 @@ Logging::log("getting media! - 2");
//check to see if there is enough space in $stor to continue. //check to see if there is enough space in $stor to continue.
$enough_space = Application_Model_StoredFile::checkForEnoughDiskSpaceToCopy($stor, $audio_file); $enough_space = Application_Model_StoredFile::checkForEnoughDiskSpaceToCopy($stor, $audio_file);
if ($enough_space){ if ($enough_space){
$stor .= "/organize"; $audio_stor = Application_Common_OsPath::join($stor, "organize", $fileName);
$audio_stor = $stor . DIRECTORY_SEPARATOR . $fileName;
Logging::log("copyFileToStor: moving file $audio_file to $audio_stor"); Logging::log("copyFileToStor: moving file $audio_file to $audio_stor");
//Martin K.: changed to rename: Much less load + quicker since this is an atomic operation //Martin K.: changed to rename: Much less load + quicker since this is an atomic operation

View File

@ -77,10 +77,7 @@
</dt> </dt>
<dd id="master_dj_connection_url-element"> <dd id="master_dj_connection_url-element">
<span id="stream_url"><?php echo $this->master_dj_connection_url ?></span> <a href=# id="connection_url_override" style="font-size: 12px;">override</a>&nbsp;&nbsp; <span id="stream_url"><?php echo $this->master_dj_connection_url ?></span> <a href=# id="connection_url_override" style="font-size: 12px;">override</a>&nbsp;&nbsp;
<span class='info-tooltip'> <span class="override_help_icon">
<span>
<?php echo $this->overrideDescription ?>
</span>
</span><br> </span><br>
<div id="master_dj_connection_url_tb" style="display:none"><input type="text"><a href=# id="ok" style="font-size: 12px;">OK</a> <a href=# id="reset" style="font-size: 12px;">RESET</a></div> <div id="master_dj_connection_url_tb" style="display:none"><input type="text"><a href=# id="ok" style="font-size: 12px;">OK</a> <a href=# id="reset" style="font-size: 12px;">RESET</a></div>
</dd> </dd>
@ -118,10 +115,7 @@
</dt> </dt>
<dd id="live_dj_connection_url-element"> <dd id="live_dj_connection_url-element">
<span id="stream_url"><?php echo $this->live_dj_connection_url ?></span> <a href=# id="connection_url_override" style="font-size: 12px;">override</a>&nbsp;&nbsp; <span id="stream_url"><?php echo $this->live_dj_connection_url ?></span> <a href=# id="connection_url_override" style="font-size: 12px;">override</a>&nbsp;&nbsp;
<span class='info-tooltip'> <span class="override_help_icon">
<span>
<?php echo $this->overrideDescription?>
</span>
</span><br> </span><br>
<div id="live_dj_connection_url_tb" style="display:none"><input type="text"><a href=# id="ok" style="font-size: 12px;">OK</a> <a href=# id="reset" style="font-size: 12px;">RESET</a></div> <div id="live_dj_connection_url_tb" style="display:none"><input type="text"><a href=# id="ok" style="font-size: 12px;">OK</a> <a href=# id="reset" style="font-size: 12px;">RESET</a></div>
</dd> </dd>

View File

@ -93,6 +93,17 @@ select {
} }
/* Version Notification Ends*/ /* Version Notification Ends*/
.override_help_icon {
cursor: help;
position: relative;
display:inline-block; zoom:1; display:inline;
width:14px; height:14px;
background:url(/css/images/icon_info.png) 0 0 no-repeat;
float:right; position:relative; top:2px; right:7px;
line-height:16px !important;
}
/* Info Tooltip Starts */ /* Info Tooltip Starts */
.info-tooltip { .info-tooltip {
cursor: help; cursor: help;

View File

@ -114,7 +114,9 @@ function buildplaylist(p_url, p_playIndex) {
} }
myPlaylist[index] = media; myPlaylist[index] = media;
_idToPostionLookUp[data[index]['element_id']] = data[index]['element_position']; // we should create a map according to the new position in the player itself
// total is the index on the player
_idToPostionLookUp[data[index]['element_id']] = total;
total++; total++;
} }
@ -135,6 +137,9 @@ function buildplaylist(p_url, p_playIndex) {
*/ */
function play(p_playlistIndex){ function play(p_playlistIndex){
playlistIndex = _idToPostionLookUp[p_playlistIndex]; playlistIndex = _idToPostionLookUp[p_playlistIndex];
if(playlistIndex == undefined){
playlistIndex = 0
}
//_playlist_jplayer.select(playlistIndex); //_playlist_jplayer.select(playlistIndex);
_playlist_jplayer.play(playlistIndex); _playlist_jplayer.play(playlistIndex);
} }

View File

@ -85,8 +85,8 @@ function updateProgressBarValue(){
if (songPercentDone < 0 || songPercentDone > 100){ if (songPercentDone < 0 || songPercentDone > 100){
songPercentDone = 0; songPercentDone = 0;
currentSong = null; currentSong = null;
} else { } else {
if (currentSong.media_item_played == "t" && currentShow.length > 0){ if (currentSong.media_item_played == true && currentShow.length > 0){
scheduled_play_line_to_switch.attr("class", "line-to-switch on"); scheduled_play_line_to_switch.attr("class", "line-to-switch on");
scheduled_play_div.addClass("ready") scheduled_play_div.addClass("ready")
scheduled_play_source = true; scheduled_play_source = true;

View File

@ -235,4 +235,26 @@ $(document).ready(function() {
showErrorSections() showErrorSections()
setInterval('checkLiquidsoapStatus()', 1000) setInterval('checkLiquidsoapStatus()', 1000)
// qtip for help text
$(".override_help_icon").qtip({
content: {
text: "If Airtime is behind a router or firewall, you may need to configure port forwarding and this field information will be incorrect. In this case you will need to manually update this field so it shows the correct host/port/mount that your DJ's need to connect to. The allowed range is between 1024 and 49151. For more detail, please read the <a target=\"_blank\" href=\"http://manuals.sourcefabric.org/\">Airtime manual</a>."
},
hide: {
delay: 500,
fixed: true
},
style: {
border: {
width: 0,
radius: 4
},
classes: "ui-tooltip-dark ui-tooltip-rounded"
},
position: {
my: "left bottom",
at: "right center"
},
})
}); });

View File

@ -5,6 +5,7 @@ import sys
import os import os
import signal import signal
import traceback import traceback
import locale
from api_clients import api_client as apc from api_clients import api_client as apc
from std_err_override import LogWriter from std_err_override import LogWriter
@ -38,7 +39,16 @@ except Exception, e:
logger.info("\n\n*** Media Monitor bootup ***\n\n") logger.info("\n\n*** Media Monitor bootup ***\n\n")
try: try:
fs_encoding = locale.getdefaultlocale()[1].lower()
if fs_encoding not in ['utf-8', 'utf8']:
logger.error("Filesystem encoding needs to be UTF-8. Currently '%s'. Exiting..." % fs_encoding)
sys.exit(1)
else:
logger.debug("Filesystem encoding: '%s'" % fs_encoding)
config = AirtimeMediaConfig(logger) config = AirtimeMediaConfig(logger)
api_client = apc.api_client_factory(config.cfg) api_client = apc.api_client_factory(config.cfg)
api_client.register_component("media-monitor") api_client.register_component("media-monitor")