Reorganised code layout
Separated class library and web interface code Added a common config/database config to be referenced by all subprojects Fixed previous commit
This commit is contained in:
9
webui/pages/errors/404.php
Normal file
9
webui/pages/errors/404.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
$main = HandBrakeCluster_Main::instance();
|
||||
$req = $main->request();
|
||||
|
||||
$this->smarty->assign('requested_page', htmlspecialchars($req->request_string()));
|
||||
|
||||
|
||||
?>
|
||||
10
webui/pages/errors/unhandled-exception.php
Normal file
10
webui/pages/errors/unhandled-exception.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
$main = HandBrakeCluster_Main::instance();
|
||||
$config = $main->config();
|
||||
|
||||
$this->smarty->assign('display_exceptions', $config->get('debug.display_exceptions'));
|
||||
$this->smarty->assign('exception', $exception);
|
||||
$this->smarty->assign('exception_type', get_class($exception));
|
||||
|
||||
?>
|
||||
11
webui/pages/home.php
Normal file
11
webui/pages/home.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
$running_jobs = HandBrakeCluster_Job::allWithStatus(HandBrakeCluster_JobStatus::RUNNING);
|
||||
$completed_jobs = HandBrakeCluster_Job::allWithStatus(HandBrakeCluster_JobStatus::COMPLETE);
|
||||
$failed_jobs = HandBrakeCluster_Job::allWithStatus(HandBrakeCluster_JobStatus::FAILED);
|
||||
|
||||
$this->smarty->assign('running_jobs', $running_jobs);
|
||||
$this->smarty->assign('completed_jobs', $completed_jobs);
|
||||
$this->smarty->assign('failed_jobs', $failed_jobs);
|
||||
|
||||
?>
|
||||
13
webui/pages/job-details.php
Normal file
13
webui/pages/job-details.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
$job_id = $this->request->get('id');
|
||||
$job = HandBrakeCluster_Job::fromId($job_id);
|
||||
$this->smarty->assign('job', $job);
|
||||
|
||||
$client_log_entries = HandBrakeCluster_ClientLogEntry::recentForJob($job_id, 30);
|
||||
$worker_log_entries = HandBrakeCluster_WorkerLogEntry::recentForJob($job_id, 30);
|
||||
$this->smarty->assign('client_log_entries', $client_log_entries);
|
||||
$this->smarty->assign('worker_log_entries', $worker_log_entries);
|
||||
|
||||
|
||||
?>
|
||||
90
webui/pages/jobs.php
Normal file
90
webui/pages/jobs.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
$main = HandBrakeCluster_Main::instance();
|
||||
$req = $main->request();
|
||||
$config = $main->config();
|
||||
|
||||
if ($req->get('submit')) {
|
||||
$action = HandBrakeCluster_Main::issetelse($_POST['action'], HandBrakeCluster_Exception_InvalidParameters);
|
||||
|
||||
# If a bulk action was selected, the action will be a single term, otherwise it will also contain
|
||||
# the id of the single item to act upon. Work out which was used now.
|
||||
$matches = $job_ids = array();
|
||||
if (preg_match('/^(.*)\[(\d+)\]$/', $action, $matches)) {
|
||||
$action = $matches[1];
|
||||
$job_ids = array($matches[2]);
|
||||
}
|
||||
else {
|
||||
$job_ids = $_POST['include'];
|
||||
}
|
||||
|
||||
$jobs = array();
|
||||
foreach ($job_ids as $job_id) {
|
||||
$job = HandBrakeCluster_Job::fromId($job_id);
|
||||
if (!$job) {
|
||||
throw new HandBrakeCluster_Exception_InvalidParameters('job_id');
|
||||
}
|
||||
$jobs[] = $job;
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'mark-failed': {
|
||||
foreach ($jobs as $job) {
|
||||
$job->updateStatus(HandBrakeCluster_JobStatus::FAILED);
|
||||
}
|
||||
} break;
|
||||
|
||||
case 'retry': {
|
||||
# Clone each of the selected jobs
|
||||
foreach ($jobs as $job) {
|
||||
$new_job = clone $job;
|
||||
}
|
||||
|
||||
# Dispatch all the jobs in one run
|
||||
HandBrakeCluster_Job::runAllJobs();
|
||||
|
||||
# Redirect to the job queued page to show the jobs were successfully dispatched
|
||||
HandBrakeCluster_Page::redirect('rips/setup-rip/queued');
|
||||
} break;
|
||||
|
||||
case 'delete': {
|
||||
foreach ($jobs as $job) {
|
||||
$job->delete();
|
||||
}
|
||||
} break;
|
||||
|
||||
default: {
|
||||
throw new HandBrakeCluster_Exception_InvalidParameters('action');
|
||||
}
|
||||
}
|
||||
|
||||
HandBrakeCluster_Page::redirect('jobs');
|
||||
|
||||
} else {
|
||||
|
||||
if (isset($_POST['view'])) {
|
||||
$statusName = urlencode($_POST['view']);
|
||||
HandBrakeCluster_Page::redirect("jobs/view/{$statusName}");
|
||||
}
|
||||
|
||||
$statusName = $req->get('view', 'any');
|
||||
switch ($statusName) {
|
||||
case 'any': $status = null; break;
|
||||
case 'queued': $status = HandBrakeCluster_JobStatus::QUEUED; break;
|
||||
case 'running': $status = HandBrakeCluster_JobStatus::RUNNING; break;
|
||||
case 'complete': $status = HandBrakeCluster_JobStatus::COMPLETE; break;
|
||||
case 'failed': $status = HandBrakeCluster_JobStatus::FAILED; break;
|
||||
default: throw new HandBrakeCluster_Exception_InvalidParameters('view');
|
||||
}
|
||||
|
||||
$jobs = array();
|
||||
if ($status) {
|
||||
$jobs = HandBrakeCluster_Job::allWithStatus($status);
|
||||
} else {
|
||||
$jobs = HandBrakeCluster_Job::all();
|
||||
}
|
||||
|
||||
$this->smarty->assign('jobs', $jobs);
|
||||
}
|
||||
|
||||
?>
|
||||
9
webui/pages/logs.php
Normal file
9
webui/pages/logs.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
$client_log_entries = HandBrakeCluster_ClientLogEntry::recent(30);
|
||||
$worker_log_entries = HandBrakeCluster_WorkerLogEntry::recent(30);
|
||||
|
||||
$this->smarty->assign('client_log_entries', $client_log_entries);
|
||||
$this->smarty->assign('worker_log_entries', $worker_log_entries);
|
||||
|
||||
?>
|
||||
35
webui/pages/rips/setup-rip.php
Normal file
35
webui/pages/rips/setup-rip.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
$main = HandBrakeCluster_Main::instance();
|
||||
$req = $main->request();
|
||||
$config = $main->config();
|
||||
|
||||
// Grab the name of this source
|
||||
$encoded_filename = null;
|
||||
if ($req->get('submit')) {
|
||||
$encoded_filename = HandBrakeCluster_Main::issetelse($_POST['id'], HandBrakeCluster_Exception_InvalidParameters);
|
||||
|
||||
// Create the jobs from the request
|
||||
$jobs = HandBrakeCluster_Job::fromPostRequest($_POST['id'], $_POST['rip-options'], $_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);
|
||||
|
||||
} else {
|
||||
$this->smarty->assign('rips_submitted', false);
|
||||
$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());
|
||||
$this->smarty->assign('default_output_directory', $config->get('rips.default.output_directory'));
|
||||
}
|
||||
|
||||
?>
|
||||
12
webui/pages/rips/source-details.php
Normal file
12
webui/pages/rips/source-details.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
$main = HandBrakeCluster_Main::instance();
|
||||
$req = $main->request();
|
||||
$config = $main->config();
|
||||
|
||||
$source = HandBrakeCluster_Rips_Source::loadEncoded($req->get('id', HandBrakeCluster_Exception_InvalidParameters));
|
||||
|
||||
$this->smarty->assign('source', $source);
|
||||
$this->smarty->assign('titles', $source->titles());
|
||||
|
||||
?>
|
||||
17
webui/pages/rips/sources.php
Normal file
17
webui/pages/rips/sources.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
$main = HandBrakeCluster_Main::instance();
|
||||
$config = $main->config();
|
||||
|
||||
$lister = new HandBrakeCluster_Rips_SourceLister($config->get('rips.source_dir'));
|
||||
$sources = $lister->sources();
|
||||
|
||||
$sources_cached = array();
|
||||
foreach ($sources as $source) {
|
||||
$sources_cached[$source->filename()] = HandBrakeCluster_Rips_Source::isCached($source->filename());
|
||||
}
|
||||
|
||||
$this->smarty->assign('sources', $sources);
|
||||
$this->smarty->assign('sources_cached', $sources_cached);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user