From d8bcb3f03dd2ccd4b0b4d62bc9bc40499b654641 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 14 Oct 2011 00:07:53 +0200 Subject: [PATCH 1/3] CC-2972: Find better way to determine domain which pypo should download from. -Done --- airtime_mvc/application/configs/conf.php | 4 ++-- airtime_mvc/application/models/Schedule.php | 2 +- airtime_mvc/application/models/StoredFile.php | 22 +++++++++++++++++-- airtime_mvc/build/airtime.conf | 2 ++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/airtime_mvc/application/configs/conf.php b/airtime_mvc/application/configs/conf.php index 10d54b01a..51899021a 100644 --- a/airtime_mvc/application/configs/conf.php +++ b/airtime_mvc/application/configs/conf.php @@ -63,8 +63,8 @@ class Config { $CC_CONFIG['webServerUser'] = $values['general']['web_server_user']; $CC_CONFIG['rabbitmq'] = $values['rabbitmq']; - //$CC_CONFIG['baseUrl'] = $values['general']['base_url']; - //$CC_CONFIG['basePort'] = $values['general']['base_port']; + $CC_CONFIG['baseUrl'] = $values['general']['base_url']; + $CC_CONFIG['basePort'] = $values['general']['base_port']; // Database config $CC_CONFIG['dsn']['username'] = $values['database']['dbuser']; diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 7a27541e4..f45b3baaf 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -713,7 +713,7 @@ class Schedule { foreach ($items as $item) { $storedFile = StoredFile::Recall($item["file_id"]); - $uri = $storedFile->getFileUrl(); + $uri = $storedFile->getFileUrlUsingConfigAddress(); $starts = Schedule::AirtimeTimeToPypoTime($item["starts"]); $medias[$starts] = array( diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 359516f48..238fdd69e 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -435,14 +435,32 @@ class StoredFile { } /** - * Get the URL to access this file. + * Get the URL to access this file using the server name/address that + * this PHP script was invoked through. */ public function getFileUrl() { $serverName = $_SERVER['SERVER_NAME']; $serverPort = $_SERVER['SERVER_PORT']; - return "http://$serverName:$serverPort/api/get-media/file/".$this->getGunId().".".$this->getFileExtension(); + return constructGetFileUrl($serverName, $serverPort); + } + + /** + * Get the URL to access this file using the server name/address that + * is specified in the airtime.conf config file. + */ + public function getFileUrlUsingConfigAddress(){ + global $CC_CONFIG; + + $serverName = $CC_CONFIG['baseUrl']; + $serverPort = $CC_CONFIG['basePort']; + + return constructGetFileUrl($serverName, $serverPort); + } + + private function constructGetFileUrl($p_serverName, $p_serverPort){ + return "http://$p_serverName:$p_serverPort/api/get-media/file/".$this->getGunId().".".$this->getFileExtension(); } /** diff --git a/airtime_mvc/build/airtime.conf b/airtime_mvc/build/airtime.conf index aa1ca2dde..b11e672ce 100644 --- a/airtime_mvc/build/airtime.conf +++ b/airtime_mvc/build/airtime.conf @@ -15,6 +15,8 @@ vhost = / api_key = AAA web_server_user = www-data airtime_dir = x +base_url = localhost +base_port = 80 [soundcloud] connection_retries = 3 From f1864e79d8441f2fa9da3eae9df8225bbb89622a Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 14 Oct 2011 00:12:33 +0200 Subject: [PATCH 2/3] CC-2973: Api key is being used for downloads in the "Show Content" window + "Playlist Builder" page. -fixed --- airtime_mvc/application/controllers/LibraryController.php | 2 +- airtime_mvc/application/controllers/ScheduleController.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index bd37ab15e..8e6b3a341 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -84,7 +84,7 @@ class LibraryController extends Zend_Controller_Action $file_id = $this->_getParam('id', null); $file = StoredFile::Recall($file_id); - $url = $file->getRelativeFileUrl($baseUrl).'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true'; + $url = $file->getRelativeFileUrl($baseUrl).'/download/true'; $menu[] = array('action' => array('type' => 'gourl', 'url' => $url), 'title' => 'Download'); diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 793dcbfff..3e1400942 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -703,8 +703,9 @@ class ScheduleController extends Zend_Controller_Action $file_id = $this->_getParam('id', null); $file = StoredFile::Recall($file_id); - - $url = $file->getFileURL().'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true'; + + $baseUrl = $this->getRequest()->getBaseUrl(); + $url = $file->getRelativeFileUrl($baseUrl).'/download/true'; $menu[] = array('action' => array('type' => 'gourl', 'url' => $url), 'title' => 'Download'); From 292b8f5c5d3b83e8c800389586fa26f02fadd358 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 14 Oct 2011 01:28:44 +0200 Subject: [PATCH 3/3] CC-2975: Require python-virtualenv version >= 1.4.9 for Airtime installations. -fixed --- install_minimal/airtime-install | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/install_minimal/airtime-install b/install_minimal/airtime-install index cf900e625..81300459a 100755 --- a/install_minimal/airtime-install +++ b/install_minimal/airtime-install @@ -15,6 +15,22 @@ if [[ "$DEB" = "Status: install ok installed" ]]; then exit 1 fi + +#Check whether version of virtualenv is <= 1.4.5. If so exit install. +BAD_VERSION="1.4.8" +VERSION=$(virtualenv --version) +NEWEST_VERSION=$(echo -e "$BAD_VERSION\n$VERSION\n'" | sort -t '.' -g | tail -n 1) +echo -n "Ensuring python-virtualenv version > $BAD_VERSION..." +if [[ "$NEWEST_VERSION" = "$BAD_VERSION" ]]; then + URL="http://apt.sourcefabric.org/pool/main/p/python-virtualenv/python-virtualenv_1.4.9-3_all.deb" + echo "Failed!" + echo "You have version $BAD_VERSION or older installed. Please install package at $URL first and then try installing Airtime again." + exit 1 +else + echo "Success!" +fi + + echo -e "\n******************************** Install Begin *********************************" # Absolute path to this script