added dynamic package description tootips

updated tablesorter to v2.25.0
add tablesorter widgets
(filter, saveSort, stickyHeaders, hover highlight)
added cli options to packagemanager script
This commit is contained in:
Derek Macias
2016-01-10 03:23:15 -07:00
parent 71e7008acd
commit 0495315d4f
13 changed files with 7204 additions and 50 deletions

View File

@ -3,6 +3,7 @@
// Progress bar for curl download
function progress_bar($download_size, $downloaded_size, $upload_size = null, $uploaded_size = null)
{
ob_start();
static $previousProgress = 0;
if ($download_size == 0)
@ -29,12 +30,13 @@ function progress_bar($download_size, $downloaded_size, $upload_size = null, $up
echo $status_bar;
ob_flush();
flush();
if($progress == 100) {
echo "\n";
}
}
ob_end_flush();
}
// Download a file from given url
@ -81,4 +83,4 @@ function file_check_sha($file, $sha){
$return = ($sha_file == $sha) ? true : false;
return $return;
}
?>
?>

View File

@ -0,0 +1,35 @@
<?php
function format_size($value, $decimals, $unit='?') {
if ($value == '')
return 'unknown';
/* Autodetect unit that's appropriate */
if ($unit == '?') {
if ($value >= 1099511627776)
$unit = 'T';
else
if ($value >= (1 << 30))
$unit = 'G';
else
if ($value >= (1 << 20))
$unit = 'M';
else
if ($value >= (1 << 10))
$unit = 'K';
else
$unit = 'B';
}
$unit = strtoupper($unit);
switch ($unit) {
case 'T': return number_format($value / (float)1099511627776, $decimals).' TB';
case 'G': return number_format($value / (float)(1 << 30), $decimals).' GB';
case 'M': return number_format($value / (float)(1 << 20), $decimals).' MB';
case 'K': return number_format($value / (float)(1 << 10), $decimals).' kB';
case 'B': return $value.' B';
}
return false;
}
?>

View File

@ -1,24 +1,27 @@
<?php
$config_file = "/boot/config/plugins/NerdPack/NerdPack.cfg";
require_once("/usr/local/emhttp/plugins/NerdPack/include/NerdPackHelpers.php");
$pkg_path = "/boot/config/plugins/NerdPack/packages/"; // package path
$plg_path ="/boot/config/plugins/NerdPack";// plugin path
$pkg_path = "$plg_path/packages"; // package path
$config_file = "$plg_path/NerdPack.cfg";// config file
$pkg_cfg = (is_file($config_file)) ? parse_ini_file($config_file) : array(); // get package configs
$pkgs_downloaded = array_diff( scandir($pkg_path, 1), array(".", "..") ); // get array of packages
$pkgs_downloaded = array_diff( scandir($pkg_path, 1), array(".", "..") ); // get array of downloaded packages
$pkgs_installed = array_diff( scandir("/var/log/packages", 1), array(".", "..") ); // get array of all installed packages
$pkgs_file = file_get_contents("/boot/config/plugins/NerdPack/packages.json");
$pkgs_github = json_decode($pkgs_file, true);
$pkgs_desc_file = file_get_contents("$pkg_path/packages-desc");// get package descriptions
$pkgs_desc_array = json_decode($pkgs_desc_file, true);
$pkgs_github_file = file_get_contents("$pkg_path/packages.json");// get packages
$pkgs_github_array = json_decode($pkgs_github_file, true);
$pkgs_array = array();
for ($i = 0; $i < sizeof($pkgs_github); $i++) {
for ($i = 0; $i < sizeof($pkgs_github_array); $i++) {
$pkg_nameArray = explode("-", $pkgs_github[$i]["name"]); // split package name into array
$pkg_nameArray = explode("-", $pkgs_github_array[$i]["name"]); // split package name into array
$pkg_name = $pkg_nameArray[0];
if (sizeof($pkg_nameArray) > 4){ //if package name has a subset get it
@ -35,7 +38,7 @@ for ($i = 0; $i < sizeof($pkgs_github); $i++) {
$pkg = array();
$pkg["name"] = $pkgs_github[$i]["name"]; // add full package name
$pkg["name"] = $pkgs_github_array[$i]["name"]; // add full package name
$pkg["pkgname"] = $pkg_name; // add package name only
@ -43,24 +46,26 @@ for ($i = 0; $i < sizeof($pkgs_github); $i++) {
$pkg["pkgversion"] = $pkg_version; // add package name with underscored version
$pkg["size"] = $pkgs_github[$i]["size"]; // add package size
$pkg["size"] = format_size($pkgs_github_array[$i]["size"], 1, '?'); // add package size
// checks if package name is installed
$pkg["installed"] = preg_grep($pkg_pattern , $pkgs_installed) ? "yes" : "no";
// checks if package is installed equals github exactly
$pkg["installeq"] = in_array( pathinfo($pkgs_github[$i]["name"], PATHINFO_FILENAME), $pkgs_installed ) ? "yes" : "no";
$pkg["installeq"] = in_array( pathinfo($pkgs_github_array[$i]["name"], PATHINFO_FILENAME), $pkgs_installed ) ? "yes" : "no";
// checks if package name is downloaded
$pkg["downloaded"] = preg_grep($pkg_pattern , $pkgs_downloaded) ? "yes" : "no";
// checks if package is downloaded equals github exactly
$pkg["downloadeq"] = in_array( $pkgs_github[$i]["name"], $pkgs_downloaded ) ? "yes" : "no";
$pkg["downloadeq"] = in_array( $pkgs_github_array[$i]["name"], $pkgs_downloaded ) ? "yes" : "no";
$pkg["config"] = isset($pkg_cfg["$pkg_nver"]) ? $pkg_cfg["$pkg_nver"] : "no"; // checks config for install preference
$pkg["desc"] = $pkgs_desc_array["$pkg_name"];
$pkgs_array[] = $pkg;
}
echo json_encode($pkgs_array);
?>
?>