Updated source/rips and jobs pages to reflect code changes

This commit is contained in:
2010-04-03 23:06:34 +01:00
parent 3121de74cc
commit 2f86156561
8 changed files with 36 additions and 57 deletions

View File

@@ -1,6 +1,6 @@
<?php <?php
$jobs = HandBrakeCluster_Job::all(HandBrakeCluster_Main::instance()->database()); $jobs = HandBrakeCluster_Job::all();
$this->smarty->assign('jobs', $jobs); $this->smarty->assign('jobs', $jobs);
?> ?>

View File

@@ -5,36 +5,30 @@ $req = $main->request();
$config = $main->config(); $config = $main->config();
// Grab the name of this source // Grab the name of this source
$source_id; $encoded_filename = null;
if ($req->get('submit')) { if ($req->get('submit')) {
$this->smarty->assign('rips_submitted', true); $encoded_filename = HandBrakeCluster_Main::issetelse($_POST['id'], HandBrakeCluster_Exception_InvalidParameters);
$source_id = 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 { } else {
$this->smarty->assign('rips_submitted', false); $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());
?> ?>

View File

@@ -4,23 +4,8 @@ $main = HandBrakeCluster_Main::instance();
$req = $main->request(); $req = $main->request();
$config = $main->config(); $config = $main->config();
// Grab the name of this source $source = HandBrakeCluster_Rips_Source::loadEncoded($req->get('id', HandBrakeCluster_Exception_InvalidParameters));
$source_id = $req->get('id');
$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)) {
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('source', $source);
$this->smarty->assign('titles', $source->titles()); $this->smarty->assign('titles', $source->titles());

View File

@@ -8,7 +8,7 @@ $sources = $lister->sources();
$sources_cached = array(); $sources_cached = array();
foreach ($sources as $source) { 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); $this->smarty->assign('sources', $sources);

View File

@@ -15,7 +15,7 @@
{assign var=current_status value=$job->currentStatus()} {assign var=current_status value=$job->currentStatus()}
<tr> <tr>
<td><a href="{$base_uri}/job-details/id/{$job->id()}" title="View job details">{$job->name()}</a></td> <td><a href="{$base_uri}/job-details/id/{$job->id()}" title="View job details">{$job->name()}</a></td>
<td>{$job->destination()}</td> <td>{$job->destinationFilename()}</td>
<td>{$job->title()}</td> <td>{$job->title()}</td>
<td>{$current_status->statusName()}</td> <td>{$current_status->statusName()}</td>
</tr> </tr>

View File

@@ -1,17 +1,18 @@
<h2>Setup Rips</h2> <h2>Setup Rips</h2>
{if $rips_submitted} {if $rips_submitted}
<p> <h3>Jobs Queued</h3>
Processing rips now...
</p>
<pre>{$rips|var_dump}</pre> <p>
The rips have been queued, and processing has begun in the background. View the <a href="{$base_uri}jobs/" title="View running jobs">Jobs</a> page
to see a list of running jobs, or the <a href="{$base_uri}logs/" title="View logs">logs</a> page for more detailed progress information.
</p>
{else} {else}
<form name="setup-rips" id="setup-rips" action="{$base_uri}rips/setup-rip/submit/" method="post"> <form name="setup-rips" id="setup-rips" action="{$base_uri}rips/setup-rip/submit/" method="post">
<fieldset> <fieldset>
<legend>Configure titles to rip</legend> <legend>Configure titles to rip</legend>
<input type="hidden" name="id" value="{$source_path_encoded}" /> <input type="hidden" name="id" value="{$source->filenameEncoded()|escape:"html"}" />
<input type="submit" name="submit" value="Queue rips" /> <input type="submit" name="submit" value="Queue rips" />
@@ -25,9 +26,6 @@
<input type="checkbox" id="rip-title-{$title->id()}" name="rips[{$title->id()}][queue]" value="1" /> <input type="checkbox" id="rip-title-{$title->id()}" name="rips[{$title->id()}][queue]" value="1" />
<label for="rip-title-{$title->id()}">Rip this title</label> <label for="rip-title-{$title->id()}">Rip this title</label>
<input type="checkbox" id="rip-chapters-{$title->id()}" name="rips[{$title->id()}][include-chapters]" value="{$title->id()}" checked="checked" />
<label for="rip-title-{$title->id()}">Include chapter markers</label>
<hr /> <hr />
<label for="rip-audio-{$title->id()}">Audio tracks</label> <label for="rip-audio-{$title->id()}">Audio tracks</label>

View File

@@ -12,7 +12,7 @@
<tbody> <tbody>
<tr> <tr>
<th>Source</th> <th>Source</th>
<td>{$source_path|escape:"html"}</td> <td>{$source->filename()|escape:"html"}</td>
</tr> </tr>
{if $titles} {if $titles}
<tr> <tr>

View File

@@ -10,10 +10,12 @@
</p> </p>
<ul> <ul>
{foreach from=$sources item=source} {foreach from=$sources item=source}
{assign var='source_filename' value=$source->filename()}
{assign var='source_filename_encoded' value=$source->filenameEncoded()}
<li> <li>
[ <a href="{$base_uri}rips/source-details/id/{$source|base64_encode|replace:"/":"-"}" title="Browse source details">Browse</a> | [ <a href="{$base_uri}rips/source-details/id/{$source_filename_encoded}" title="Browse source details">Browse</a> |
<a href="{$base_uri}rips/setup-rip/id/{$source|base64_encode|replace:"/":"-"}" title="Rip this source">Rip</a> ] <a href="{$base_uri}rips/setup-rip/id/{$source_filename_encoded}" title="Rip this source">Rip</a> ]
{$source|escape:'html'}{if $sources_cached.$source} (cached){/if} {$source_filename|escape:'html'}{if $sources_cached.$source_filename} (cached){/if}
</li> </li>
{/foreach} {/foreach}
</ul> </ul>