diff --git a/pages/jobs.php b/pages/jobs.php index a31e23a..c0aab25 100644 --- a/pages/jobs.php +++ b/pages/jobs.php @@ -1,6 +1,6 @@ database()); +$jobs = HandBrakeCluster_Job::all(); $this->smarty->assign('jobs', $jobs); ?> diff --git a/pages/rips/setup-rip.php b/pages/rips/setup-rip.php index 52da477..47ec4c3 100644 --- a/pages/rips/setup-rip.php +++ b/pages/rips/setup-rip.php @@ -5,36 +5,30 @@ $req = $main->request(); $config = $main->config(); // Grab the name of this source -$source_id; +$encoded_filename = null; if ($req->get('submit')) { - $this->smarty->assign('rips_submitted', true); - $source_id = HandBrakeCluster_Main::issetelse($_POST['id'], HandBrakeCluster_Exception_InvalidParameters); + $encoded_filename = HandBrakeCluster_Main::issetelse($_POST['id'], HandBrakeCluster_Exception_InvalidParameters); + + // Create the jobs from the request + $jobs = HandBrakeCluster_Job::fromPostRequest($_POST['id'], $_POST['rips']); + + // Spawn the background client process to run all the jobs + HandBrakeCluster_Job::runAllJobs(); + + HandBrakeCluster_Page::redirect('rips/setup-rip/queued'); + +} elseif ($req->get('queued')) { + $this->smarty->assign('rips_submitted', true); - $this->smarty->assign('rips', HandBrakeCluster_Main::issetelse($_POST['rips'], HandBrakeCluster_Exception_InvalidParameters)); } else { $this->smarty->assign('rips_submitted', false); - $source_id = $req->get('id', HandBrakeCluster_Exception_InvalidParameters); + $encoded_filename = $req->get('id', HandBrakeCluster_Exception_InvalidParameters); + + $source = HandBrakeCluster_Rips_Source::loadEncoded($encoded_filename); + + $this->smarty->assign('source', $source); + $this->smarty->assign('titles', $source->titles()); + $this->smarty->assign('longest_title', $source->longestTitle()); } -$source_path = base64_decode(str_replace('-', '/', $source_id)); -$real_source_path = realpath($source_path); - -// Ensure the source is a valid directory, and lies below the configured source_dir -if (!is_dir($source_path)) { - throw new HandBrakeCluster_Exception_InvalidParameters(); -} - -$real_source_dir = realpath($config->get('rips.source_dir')); -if (substr($real_source_path, 0, strlen($real_source_dir)) != $real_source_dir) { - throw new HandBrakeCluster_Exception_InvalidParameters(); -} - -$source = HandBrakeCluster_Rips_Source::load($source_path); - -$this->smarty->assign('source_path_encoded', $source_id); -$this->smarty->assign('source_path', $source_path); -$this->smarty->assign('source', $source); -$this->smarty->assign('titles', $source->titles()); -$this->smarty->assign('longest_title', $source->longestTitle()); - ?> \ No newline at end of file diff --git a/pages/rips/source-details.php b/pages/rips/source-details.php index 5ef21ed..5388406 100644 --- a/pages/rips/source-details.php +++ b/pages/rips/source-details.php @@ -4,23 +4,8 @@ $main = HandBrakeCluster_Main::instance(); $req = $main->request(); $config = $main->config(); -// Grab the name of this source -$source_id = $req->get('id'); -$source_path = base64_decode(str_replace('-', '/', $source_id)); -$real_source_path = realpath($source_path); +$source = HandBrakeCluster_Rips_Source::loadEncoded($req->get('id', HandBrakeCluster_Exception_InvalidParameters)); -// Ensure the source is a valid directory, and lies below the configured source_dir -if (!is_dir($source_path)) { - return; -} -$real_source_dir = realpath($config->get('rips.source_dir')); -if (substr($real_source_path, 0, strlen($real_source_dir)) != $real_source_dir) { - return; -} - -$source = HandBrakeCluster_Rips_Source::load($source_path); - -$this->smarty->assign('source_path', $source_path); $this->smarty->assign('source', $source); $this->smarty->assign('titles', $source->titles()); diff --git a/pages/rips/sources.php b/pages/rips/sources.php index 13f6f48..32a06d1 100644 --- a/pages/rips/sources.php +++ b/pages/rips/sources.php @@ -8,7 +8,7 @@ $sources = $lister->sources(); $sources_cached = array(); foreach ($sources as $source) { - $sources_cached[$source] = HandBrakeCluster_Rips_Source::isCached($source); + $sources_cached[$source->filename()] = HandBrakeCluster_Rips_Source::isCached($source->filename()); } $this->smarty->assign('sources', $sources); diff --git a/templates/jobs.tpl b/templates/jobs.tpl index a67dc77..b11a03a 100644 --- a/templates/jobs.tpl +++ b/templates/jobs.tpl @@ -15,7 +15,7 @@ {assign var=current_status value=$job->currentStatus()} {$job->name()} - {$job->destination()} + {$job->destinationFilename()} {$job->title()} {$current_status->statusName()} diff --git a/templates/rips/setup-rip.tpl b/templates/rips/setup-rip.tpl index 9e0a93b..d918aef 100644 --- a/templates/rips/setup-rip.tpl +++ b/templates/rips/setup-rip.tpl @@ -1,17 +1,18 @@

Setup Rips

{if $rips_submitted} -

- Processing rips now... -

+

Jobs Queued

-
{$rips|var_dump}
+

+ The rips have been queued, and processing has begun in the background. View the Jobs page + to see a list of running jobs, or the logs page for more detailed progress information. +

{else}
Configure titles to rip - + @@ -25,9 +26,6 @@ - - -
diff --git a/templates/rips/source-details.tpl b/templates/rips/source-details.tpl index ef52ddf..2a67425 100644 --- a/templates/rips/source-details.tpl +++ b/templates/rips/source-details.tpl @@ -12,7 +12,7 @@ Source - {$source_path|escape:"html"} + {$source->filename()|escape:"html"} {if $titles} diff --git a/templates/rips/sources.tpl b/templates/rips/sources.tpl index dca0fff..422d526 100644 --- a/templates/rips/sources.tpl +++ b/templates/rips/sources.tpl @@ -10,10 +10,12 @@