diff options
author | Eudyptula <eitan@mosenkis.net> | 2009-07-05 13:55:03 -0400 |
---|---|---|
committer | Eudyptula <eitan@mosenkis.net> | 2009-07-05 13:55:03 -0400 |
commit | 919316aa252440a3f9beed2c1276b4d70a827bab (patch) | |
tree | 197edb7e83a87318b03748ecc37d6193f6ea5ce7 | |
parent | Separated configurations from builds of those configurations, added configura... (diff) | |
download | ingenue-919316aa252440a3f9beed2c1276b4d70a827bab.tar.gz ingenue-919316aa252440a3f9beed2c1276b4d70a827bab.tar.bz2 ingenue-919316aa252440a3f9beed2c1276b4d70a827bab.zip |
Add javascript-based searching to package adding stage
-rw-r--r-- | frontend/include/header.php | 6 | ||||
-rw-r--r-- | frontend/include/setup.php | 3 | ||||
-rw-r--r-- | frontend/modules/gentoo/step2.php | 136 | ||||
-rw-r--r-- | frontend/pages/configurations/manager.php | 2 | ||||
-rw-r--r-- | shared/classes/profile.php | 12 | ||||
-rw-r--r-- | todo | 7 |
6 files changed, 141 insertions, 25 deletions
diff --git a/frontend/include/header.php b/frontend/include/header.php index c88028c..eb70142 100644 --- a/frontend/include/header.php +++ b/frontend/include/header.php @@ -19,6 +19,12 @@ if ($conf['debug']) { foreach (array_merge($S['scripts'], $scripts) as $script) { echo '<script type="text/javascript" src="'.url('js/'.$script.'.js').'"></script>'."\n"; } +foreach ($S['head_scripts'] as $script) { + $S['head'].='<script type="text/javascript">'."\n$script\n</script>\n"; +} +foreach ($S['head_css'] as $style) { + $S['head'].='<style type="text/css">'."\n$style\n</style>\n"; +} if (isset($S['head'])) { echo $S['head']; } diff --git a/frontend/include/setup.php b/frontend/include/setup.php index dbdc3fa..6e9e9e9 100644 --- a/frontend/include/setup.php +++ b/frontend/include/setup.php @@ -7,6 +7,9 @@ $S=array_merge($S, array( 'notemplates' => false, 'title' => null, 'scripts' => array(), + 'head' => null, + 'head_css' => array(), + 'head_scripts' => array(), 'debug' => null, 'debugrow' => 0, 'root' => null, diff --git a/frontend/modules/gentoo/step2.php b/frontend/modules/gentoo/step2.php index 564dd4d..e94e978 100644 --- a/frontend/modules/gentoo/step2.php +++ b/frontend/modules/gentoo/step2.php @@ -1,33 +1,139 @@ <?php function gentoo_init_step2() { - return array('title' => 'Step 2 - Choose Extra Packages'); + $js=<<<JS +function tog_show_pkgs(lc) { + var div=document.getElementById('lc-'+lc); + if (div.style.display == "none") { + div.style.display=""; + } else { + div.style.display="none"; + } +} +var oldq=null; +function packagesearch(entry) { + var q=entry.value; + if (q !== oldq) { + filter_packages_by(q); + } + oldq=q; +} +function filter_packages_by(q) { + var plist=document.getElementById('plist'); + var tfound=0; + for (i=0; i<plist.childNodes.length; i++) { + var bc=plist.childNodes[i]; + if (bc.className !== 'bc') { + continue; + } + var bcid=bc.id.substr(3); + var bfound=0; + for (j=0; j<bc.childNodes.length; j++) { + var lc=bc.childNodes[j]; + if (lc.className !== 'lc') { + continue; + } + var lcid=lc.id.substr(3, lc.id.length-3); + var found=0; + for (k=0; k<lc.childNodes.length; k++) { + var p=lc.childNodes[k]; + if (!p.className || p.className.substr(0,3) !== 'pkg') { + continue; + } + if (q == '') { + p.style.display=""; + } else { + var name=''; + for (l=0; l<p.childNodes.length; l++) { + var d=p.childNodes[l]; + if (d.className == 'pd') { + name=d.innerHTML; + break; + } + } + if (name && name.toLowerCase().indexOf(q.toLowerCase()) != -1) { + p.style.display=""; + found++; + } else { + p.style.display="none"; + } + } + } + if (q == "" || found == 0) { + lc.style.display="none"; + document.getElementById('lct-'+lcid).style.display=(q == ''?"":"none"); + } else { + bfound+=found; + lc.style.display=""; + document.getElementById('lct-'+lcid).style.display=""; + } + } + if (q=="" || bfound > 0) { + document.getElementById('bct-'+bcid).style.display=""; + } else { + document.getElementById('bct-'+bcid).style.display="none"; + } + tfound+=bfound; + } + document.getElementById('zero').style.display=(tfound || !q.length?'none':''); +} +JS; + $css=<<<CSS +#plist { + height: 25em; + overflow: auto; +} +#plist a { + text-decoration: none; +} +div.masked { + color: red; +} +div.bct { + font-size: 125%; +} +div.lct { + font-size: 110%; +} +div.bc, div.lc { + padding-left: 2em; +} +.pd { + cursor: pointer; +} +CSS; + return array('title' => 'Step 2 - Choose Extra Packages', 'head_scripts' => array($js), 'head_css' => array($css)); } function gentoo_body_step2() { global $S; $configuration=&$S['wizard.configuration']; $opts=$configuration->get_configopts(); $profile=new sql_profile($opts['profile']); - $categories=$profile->get_packages(); - echo '<ul>'; - foreach ($categories as $cat => $packages) { - echo '<li><b>'.htmlentities($cat).'</b><ul>'; - foreach ($packages as $name => $vers) { - echo '<li>'.htmlentities($name).'<ul>'; - foreach ($vers as $ver => $attrs) { - $safename=htmlentities("$cat/$name-$ver"); - echo '<li'.($attrs['masked']?' style="color: red"':'').'><input id="pkg-'.$safename.'" type="checkbox" name="extra_packages[='.$safename.']" /><label class="pointer" for="pkg-'.$safename.'">'.htmlentities($ver).' - '.htmlentities($attrs['description']).'</label></li>'; + $bcs=$profile->get_packages(); + echo 'Search packages: <input id="psearch" onkeyup="packagesearch(this)" /> <a href="javascript:var e=document.getElementById(\'psearch\'); e.value=\'\'; e.onkeyup()">Clear</a>'; + echo '<div id="plist"><div id="zero" style="display: none">'.print_error('No results found.').'</div>'; + $i=0; + foreach ($bcs as $bc => $lcs) { + echo '<div class="bct" id="bct-'.$bc.'">'.htmlentities($bc).'</div><div class="bc" id="bc-'.$bc.'">'."\n"; + foreach ($lcs as $lc => $packages) { + echo '<div class="lct" id="lct-'.$bc.$lc.'"><a href="javascript:tog_show_pkgs(\''.$bc.$lc.'\')">±</a> '.htmlentities("$bc$lc").'</div><div class="lc" id="lc-'.$bc.$lc.'" style="display: none">'."\n"; + foreach ($packages as $name => $vers) { + foreach ($vers as $ver => $attrs) { + $safename=htmlentities("$bc$lc/$name-$ver"); + echo '<div class="pkg'.($attrs['masked']?' masked':'').'"><input id="p'.$i.'" type="checkbox" name="expkgs['.$safename.']" /><label class="pd" for="p'.$i++.'">'.htmlentities("$name-$ver").' - '.htmlentities($attrs['description']).($attrs['masked']?' [MASKED]':'').'</label></div>'."\n"; + } } - echo '</ul></li>'; + echo '</div>'."\n"; } - echo '</ul></li>'; + echo '</div>'."\n"; } + echo '</div>'; } function gentoo_process_step2() { global $S, $request; - if (isset($request['extra_packages'])) { + if (isset($request['expkgs'])) { $packages=array(); - foreach ($request['extra_packages'] as $name => $null) { - $packages[]=$name; + foreach ($request['expkgs'] as $name => $null) { + $packages[]='='.$name; } $packages=implode(' ', $packages); $opt=new sql_configopt($S['wizard.configuration']->id, 'install_packages', $packages); diff --git a/frontend/pages/configurations/manager.php b/frontend/pages/configurations/manager.php index dfadf4a..21ee9dc 100644 --- a/frontend/pages/configurations/manager.php +++ b/frontend/pages/configurations/manager.php @@ -1,5 +1,5 @@ <?php -function init_configurations_manage() { +function init_configurations_manager() { global $S; if (!isset($S['user'])) { return 'login'; diff --git a/shared/classes/profile.php b/shared/classes/profile.php index 980599e..77603e2 100644 --- a/shared/classes/profile.php +++ b/shared/classes/profile.php @@ -67,15 +67,15 @@ class sql_profile extends sql_row_obj { } list($name, $val)=array_merge(explode(': ', $line, 2), array(null)); if ($name == 'CPV') { - if (preg_match('#^([^/]+)/(.+?)-([^-]+)((?:-r[0-9]+)?)$#', $val, $match)) { - list(, $cat, $name, $ver, $r)=$match; + if (preg_match('#^([^/-]+)([^/]*)/(.+?)-([^-]+)((?:-r[0-9]+)?)$#', $val, $match)) { + list(, $bcat, $lcat, $name, $ver, $r)=$match; $ver.=$r; } else { debug("Unsplittable atom: $val"); continue; } - if (isset($p[$cat][$name][$ver])) { - debug("Duplicate package $cat/$name-$ver"); + if (isset($p[$bcat][$lcat][$name][$ver])) { + debug("Duplicate package $bcat$lcat/$name-$ver"); // We don't really care about having correct info /* global $conf; $tbz=$conf['pkgdir_root'].'/'.$this->pkgdir.'/'.(isset($p[$cat][$name][$ver]['path'])?$p[$cat][$name][$ver]['path']:"$cat/$name-$ver.tbz2"); @@ -86,8 +86,8 @@ class sql_profile extends sql_row_obj { debug($this->pkgdir.": Duplicate package $cat/$name-$ver - current entry invalid, using new entry"); }*/ } - $p[$cat][$name][$ver]=array(); - $cur=&$p[$cat][$name][$ver]; + $p[$bcat][$lcat][$name][$ver]=array(); + $cur=&$p[$bcat][$lcat][$name][$ver]; } elseif (isset($cur, $val)) { switch($name) { case 'KEYWORDS': @@ -1,8 +1,9 @@ Have backend handle builds that it finds to already be running (break in to steps and store current status) -*** Make frontend package adding a little more user-friendly (ajax or client-side js search) *** +Make package adding friendly for browsers without JS/CSS (use ul/li, not div) +Reduce page size for package adding Write a live git ebuild Write an AJAX-based self-updating status viewer -Add logging besides just commands +*** Add logging besides just commands *** Make backend do a dummy run through and queue all commands and other tasks, then execute them (for better status handling, easier debugging, etc.) Have builds and tasks not give links to logs if we're already viewing the logs Either make task status a TEXT or stop putting command name in the status (via thrown exception) - we can fetch this later anyway - just store the task id that failed (or use the last task) @@ -13,7 +14,6 @@ Add configurable groups of suggested packages to frontend, backend Add a statistics page Add cleanup functions to the frontend and backend Separate variables we got from the URL from the rest, stop using $request, instead keep super globals and strip slashes on them -Get rid of backend use of echo, debug, etc. and do all logging in the db Support ~arch installation or remove it from listings Completely plan out how frontend modules should function - each step needs to report if it finished successfully (required values) See if I can figure any way to use classes instead of funny named functions (namespaces in 5.3.0 perhaps) - also needs to have a depend of some sort so we can make a quick-config page that doesn't show things that we don't have enough info for yet (use AJAX to show them when we're ready) @@ -21,3 +21,4 @@ Allow backend to define bail-out functions to call when it dies (things like unm Add STDERR (maybe STDOUT) only option to log viewer *** Make frontend/backend split possible *** - Stop directly accessing PKGDIR from the frontend - put whatever info we need in the database and write a script for updating it from the backend; track which backend is doing which build Simplify status to numeric on builds, configurations - varchar isn't necessary +Add config option to enable/disable user self-registration/invitations/admin-only invites |