diff options
author | 2009-07-01 17:46:53 -0400 | |
---|---|---|
committer | 2009-07-01 17:46:53 -0400 | |
commit | e77f28c56eef5feae20bfc7716e6c11b2195ada0 (patch) | |
tree | b675457e790b107f776e6e26e0255811d24facf7 /frontend | |
parent | Many fixes to CD building and some to command execution/logging (diff) | |
download | ingenue-e77f28c56eef5feae20bfc7716e6c11b2195ada0.tar.gz ingenue-e77f28c56eef5feae20bfc7716e6c11b2195ada0.tar.bz2 ingenue-e77f28c56eef5feae20bfc7716e6c11b2195ada0.zip |
Update both parts for proper modularity, start catalyst-based backend, code cleanup, especially on backend
Diffstat (limited to 'frontend')
-rw-r--r-- | frontend/modules/gentoo/step1.php (renamed from frontend/wizard/step1.php) | 6 | ||||
-rw-r--r-- | frontend/modules/gentoo/step2.php (renamed from frontend/wizard/step2.php) | 6 | ||||
-rw-r--r-- | frontend/modules/gentoo/step3.php (renamed from frontend/wizard/step3.php) | 6 | ||||
-rw-r--r-- | frontend/pages/downloadimage.php | 2 | ||||
-rw-r--r-- | frontend/pages/logview.php | 3 | ||||
-rw-r--r-- | frontend/pages/wizard.php | 60 |
6 files changed, 58 insertions, 25 deletions
diff --git a/frontend/wizard/step1.php b/frontend/modules/gentoo/step1.php index 878fc40..16f04d9 100644 --- a/frontend/wizard/step1.php +++ b/frontend/modules/gentoo/step1.php @@ -1,8 +1,8 @@ <?php -function wizard_init_step1() { +function gentoo_init_step1() { return array('title' => 'Step 1 - Choose Profile'); } -function wizard_body_step1() { +function gentoo_body_step1() { global $S; $build=&$S['wizard.build']; //$opts=$build->get_buildopts(); // TODO use this to set selected="selected" on the current profile @@ -15,7 +15,7 @@ function wizard_body_step1() { } echo '</select><br/>'; } -function wizard_process_step1() { +function gentoo_process_step1() { global $S, $request; $profile=new sql_profile($request['pkgdir']); $profileopt=new sql_buildopt($S['wizard.build']->id, 'profile', $profile->id); diff --git a/frontend/wizard/step2.php b/frontend/modules/gentoo/step2.php index 7667b95..4e2907c 100644 --- a/frontend/wizard/step2.php +++ b/frontend/modules/gentoo/step2.php @@ -1,8 +1,8 @@ <?php -function wizard_init_step2() { +function gentoo_init_step2() { return array('title' => 'Step 2 - Choose Extra Packages'); } -function wizard_body_step2() { +function gentoo_body_step2() { global $S; $build=&$S['wizard.build']; $opts=$build->get_buildopts(); @@ -22,7 +22,7 @@ function wizard_body_step2() { echo '</ul></li>'; } } -function wizard_process_step2() { +function gentoo_process_step2() { global $S, $request; if (isset($request['extra_packages'])) { $packages=array(); diff --git a/frontend/wizard/step3.php b/frontend/modules/gentoo/step3.php index 42e5211..f9b83fc 100644 --- a/frontend/wizard/step3.php +++ b/frontend/modules/gentoo/step3.php @@ -1,11 +1,11 @@ <?php -function wizard_init_step3() { +function gentoo_init_step3() { return array('title' => 'Step 3 - Image Format'); } -function wizard_body_step3() { +function gentoo_body_step3() { echo 'Image type: <select name="image_type"><option value="tgz">Tar/Gzip</option><option value="tbz2">Tar/Bzip2</option><option value="installcd">Installer CD with Tar/Bzip2 image</option><option value="livecd">LiveCD</option></select><br/>'; } -function wizard_process_step3() { +function gentoo_process_step3() { global $S, $request; if (isset($request['image_type'])) { debug('wizard', 'step3: image type='.$request['image_type']); diff --git a/frontend/pages/downloadimage.php b/frontend/pages/downloadimage.php index 7346e6a..91c1161 100644 --- a/frontend/pages/downloadimage.php +++ b/frontend/pages/downloadimage.php @@ -34,7 +34,7 @@ function init_downloadimage() { header('Content-Length: '.filesize($S['file'])); header('Content-Description: File Transfer'); header('Content-Transfer-Encoding: binary'); - header('Content-Disposition: attachment; filename="ingenue-'.$build->id.$ext); + header('Content-Disposition: attachment; filename="'.(isset($build->name) && strlen($build->name)?str_replace('"', '\"', $build->name):'ingenue-'.$build->id).$ext); } function body_downloadimage() { global $S; diff --git a/frontend/pages/logview.php b/frontend/pages/logview.php index 4748a63..5107381 100644 --- a/frontend/pages/logview.php +++ b/frontend/pages/logview.php @@ -41,7 +41,8 @@ function body_logview() { $entry=new sql_buildlog_entry($entry); // $text=str_replace(array("\n", "\t"), array("<br/>\n", str_repeat(' ', 4)), htmlentities($entry->text)); // echo '<a name="entry_'.$task->order.'_'.$entry->order.'"'.($entry->stream=='stderr'?' style="color: red" ':'').' title="'.strtoupper($entry->stream).', entry #'.$entry->order.' @ '.date('D j M Y @ H:i:s', $entry->timestamp).' UTC">'.$text.'</a>'; - echo $ansi->process(nl2br($entry->text)); + echo $ansi->process(str_replace(array("\n", ' ', "\t"), array("<br/>\n", ' ', str_repeat(' ', 8)), $entry->text)); + // TODO handle tabs properly, move all this into ansi_to_html } echo $ansi->reset(); // Clear any leftover <span>s echo '</div>'; diff --git a/frontend/pages/wizard.php b/frontend/pages/wizard.php index 18797aa..d8fc9e8 100644 --- a/frontend/pages/wizard.php +++ b/frontend/pages/wizard.php @@ -1,6 +1,6 @@ <?php function init_wizard() { - global $S, $request; + global $S, $request, $conf; if (!isset($S['user'])) { return 'login'; } @@ -10,6 +10,9 @@ function init_wizard() { if ($r->rowCount()) { $S['wizard.build']=new sql_build($r->fetch(PDO::FETCH_ASSOC)); $build=&$S['wizard.build']; + $opts=$build->get_buildopts(); + $S['wizard.module']=$opts['frontend_module']; + $module=&$S['wizard.module']; if (!preg_match('#^config/step([0-9]+)$#', $build->status, $match)) { debug('wizard', 'build not in config stage (status '.$build->status.') - PANIC!'); throw_exception('We haven\'t implemented this yet.'); @@ -19,11 +22,11 @@ function init_wizard() { debug('wizard', 'Build '.$build->id." is at step $step"); if (isset($request['wizard_submit'])) { debug('wizard', "Processing step $step"); - if (!is_file(FRONTEND."/wizard/step$step.php")) { - throw_exception('wizard', "Step $step doesn't exist!"); + if (!is_file(FRONTEND."/modules/$module/step$step.php")) { + throw_exception("$modules step $step doesn't exist!"); } - require_once(FRONTEND."/wizard/step$step.php"); - $proc='wizard_process_step'.$step; + require_once(FRONTEND."/modules/$module/step$step.php"); + $proc=$module.'_process_step'.$step; if (function_exists($proc)) { if ($proc() === true) { debug('wizard', "Step $step returned <i>true</i> - config finished!"); @@ -34,7 +37,7 @@ function init_wizard() { return array('title' => 'Config Finished'); } } else { - debug('wizard', 'No processing function for step '.$step); + debug('wizard', "No processing function for $wizard step $step"); } $build->status='config/step'.++$step; $build->write(); @@ -53,16 +56,28 @@ function init_wizard() { $S['wizard.build']=new sql_build(); $S['wizard.build']->init(); } + $build=&$S['wizard.build']; $S['wizard.build']->name=$request['name']; $S['wizard.build']->write(); + $femods=explode(' ', $conf['frontend_modules']); + $bemods=explode(' ', $conf['backend_modules']); + $femod=isset($request['femod']) && isset($femods[$request['femod']])?$femods[$request['femod']]:$femods[0]; + $bemod=isset($request['bemod']) && isset($bemods[$request['bemod']])?$bemods[$request['bemod']]:$bemods[0]; + $beopt=new sql_buildopt($build->id, 'backend_module', $bemod); + $feopt=new sql_buildopt($build->id, 'frontend_module', $femod); + debug('wizard', "Backend: $bemod; Frontend: $femod"); + $beopt->write(); + $feopt->write(); + $S['wizard.module']=$femod; + $module=&$S['wizard.module']; $S['wizard.step']=1; } if (isset($S['wizard.build'], $S['wizard.step'])) { $step=&$S['wizard.step']; - if (is_file(FRONTEND."/wizard/step$step.php")) { - require_once(FRONTEND.'/wizard/step'.$step.'.php'); + if (is_file(FRONTEND."/modules/$module/step$step.php")) { + require_once(FRONTEND."/modules/$module/step$step.php"); $S['title']='Create - Step '.$step; - $proc='wizard_init_step'.$step; + $proc=$module.'_init_step'.$step; if (function_exists($proc)) { return $proc(); } else { @@ -70,31 +85,48 @@ function init_wizard() { return; } } else { - throw_exception("Step $step doesn't exist"); + throw_exception("$module step $step doesn't exist"); } } return array('title' => 'Create'); } function body_wizard() { - global $S; + global $S, $conf; if (isset($S['wizard.build'])) { if (isset($S['wizard.done'])) { echo '<h3>Config finished!</h3><p>Check your build\'s status <a href="'.url('logs/'.$S['wizard.build']->id).'">here</a></p>'; } else { $build=&$S['wizard.build']; + $module=&$S['wizard.module']; $step=&$S['wizard.step']; echo '<h3>'.$S['title'].'</h3>'; echo '<form action="'.url('create/'.$build->id).'" method="post">'; - require_once(FRONTEND."/wizard/step$step.php"); - $proc='wizard_body_step'.$step; + require_once(FRONTEND."/modules/$module/step$step.php"); + $proc=$module.'_body_step'.$step; if (!function_exists($proc)) { - throw_exception("Body function doesn't exist for wizard step $step"); + throw_exception("Body function doesn't exist for $module step $step"); } $proc(); echo '<input type="submit" name="wizard_submit" value="Continue" /></form>'; } } else { echo '<form action="'.url('create').'" method="post"><h3>Request an image built</h3>Name of your build (optional): <input name="name" /><br/>'; + $femods=explode(' ', $conf['frontend_modules']); + $bemods=explode(' ', $conf['backend_modules']); + if (count($femods) > 1) { + echo 'Frontend module: <select name="femod">'; + $i=0; + foreach ($femods as $mod) + echo '<option value="'.$i++."\">$mod</option>"; + echo '</select><br/>'; + } + if (count($bemods) > 1) { + echo 'Backend module: <select name="bemod">'; + $i=0; + foreach ($bemods as $mod) + echo '<option value="'.$i++."\">$mod</option>"; + echo '</select><br/>'; + } echo '<input type="submit" name="init" value="Start" /></form>'; } } |