From 1c097759d2deced1619171358b2abcb0ea69dfc2 Mon Sep 17 00:00:00 2001 From: bergware Date: Sun, 18 Jun 2017 10:28:13 +0200 Subject: [PATCH] Emhanced plugin manager with seprate plugin and OS sections --- plugins/dynamix.plugin.manager/Plugins.page | 23 +-- plugins/dynamix.plugin.manager/Update.page | 47 ++++++ .../dynamix.plugin.manager/icons/updateos.png | Bin 0 -> 1008 bytes .../include/PluginHelpers.php | 17 ++- .../include/ShowPlugins.php | 137 ++++++++++++------ plugins/dynamix.plugin.manager/scripts/plugin | 26 ++-- plugins/dynamix/include/DefaultPageLayout.php | 28 +++- 7 files changed, 192 insertions(+), 86 deletions(-) create mode 100644 plugins/dynamix.plugin.manager/Update.page create mode 100644 plugins/dynamix.plugin.manager/icons/updateos.png diff --git a/plugins/dynamix.plugin.manager/Plugins.page b/plugins/dynamix.plugin.manager/Plugins.page index 0378df17b..07bb00415 100644 --- a/plugins/dynamix.plugin.manager/Plugins.page +++ b/plugins/dynamix.plugin.manager/Plugins.page @@ -4,8 +4,8 @@ Title="Installed Plugins" Tabs="true" --- - - -
-Click check for updates to check all plugins. This page might take some time to load depending on your internet connection and how many plugins need to be checked. -
- - - + +
PluginAuthorVersionStatus
Please wait, retrieving plugin information ...
PluginAuthorVersionStatusUninstall
Please wait, retrieving plugin information ...
diff --git a/plugins/dynamix.plugin.manager/Update.page b/plugins/dynamix.plugin.manager/Update.page new file mode 100644 index 000000000..200483ffa --- /dev/null +++ b/plugins/dynamix.plugin.manager/Update.page @@ -0,0 +1,47 @@ +Menu="About" +Title="Update OS" +--- + + +Please wait, updating and retrieving system information ..."?> + + + + + +
SystemAuthorVersionStatusRelease
diff --git a/plugins/dynamix.plugin.manager/icons/updateos.png b/plugins/dynamix.plugin.manager/icons/updateos.png new file mode 100644 index 0000000000000000000000000000000000000000..e68175c037a76f193269c27d6a333027fd8c6263 GIT binary patch literal 1008 zcmVz@;j(q!3lK=n!AY({UO#lFTB>(_`g8%^e{{R4h=>PzA zFaQARU;qF*m;eA5Z<1fdMgRZ))wN+u z+B$X6jgIZ1f-+wQlL=D62Vo%WLGZx`Wfa|mhz=AsH-|1VrtC!&C%UHfQp&p7F11^z zN!n&vk~Zm1%2V~-;duHJ`^DYkIN&{($V0~rA(cWmHc|Fsxe>q z`+AZBZ^|cAgaSWT{`Db_w*}9ai|lE@bcJaKEOl*}Po~)pG4oke+wvSZp@^bf-6(rPzgY3vVHhD01=!>Lm_huK>Hp zHr7PjnJKhx7h3#>Q`6J-@vwx6udY$oL^Ki7vIEM4G5TZTzTguwUoN^Ime565JKSH;XWxmXDWF| zoSI{&O<_3PF&J^q>hCX~`aVV8zSSl#UM`T=ujUB% "; + $check = $method=='remove' ? "" : ""; $disabled = $check ? " disabled" : ""; - $cmd = $method == "delete" ? "/plugins/dynamix.plugin.manager/scripts/plugin_rm&arg1=$arg" : "/plugins/dynamix.plugin.manager/scripts/plugin&arg1=$method&arg2=$arg"; - return "{$check}"; + $cmd = $method == "delete" ? "/plugins/dynamix.plugin.manager/scripts/plugin_rm&arg1=$arg" : "/plugins/dynamix.plugin.manager/scripts/plugin&arg1=$method&arg2=$arg".($extra?"&arg3=$extra":""); + return "{$check}"; } // trying our best to find an icon @@ -47,4 +47,7 @@ function icon($name) { // last resort - plugin manager icon return "plugins/dynamix.plugin.manager/images/dynamix.plugin.manager.png"; } +function mk_option($select,$value) { + return ""; +} ?> diff --git a/plugins/dynamix.plugin.manager/include/ShowPlugins.php b/plugins/dynamix.plugin.manager/include/ShowPlugins.php index f1fb95b30..adb1bb39a 100644 --- a/plugins/dynamix.plugin.manager/include/ShowPlugins.php +++ b/plugins/dynamix.plugin.manager/include/ShowPlugins.php @@ -1,6 +1,6 @@ 'https://raw.github.com/limetech/\&name;/master/\&name;.plg', + 'next' => 'https://s3.amazonaws.com/dnld.lime-technology.com/\&category;/\&name;.plg']; + +foreach (glob("/var/log/plugins/*.plg",GLOB_NOSORT) as $plugin_link) { +//only consider symlinks $plugin_file = @readlink($plugin_link); if ($plugin_file === false) continue; -// plugin name - $name = plugin("name", $plugin_file); - if ($name === false) $name = basename($plugin_file, ".plg"); -// link/icon +//plugin name + $name = plugin('name',$plugin_file) ?: basename($plugin_file,".plg"); + $custom = in_array($name,$builtin); +//switch between system and custom plugins + if (($system && !$custom) || (!$system && $custom)) continue; +//forced plugin check? + if ($stale || $system) plugin('check',$name.'.plg'); +//OS update? + $os = $system && $name==$builtin[0]; + $toggle = false; +//toggle stable/next release? + if ($os && $release) { + $toggle = plugin('version',$plugin_file); + $tmp_plg = "$name-.plg"; + $tmp_file = "/var/tmp/$name.plg"; + copy($plugin_file,$tmp_file); + exec("sed -ri 's|^(|' $tmp_file"); + symlink($tmp_file,"/var/log/plugins/$tmp_plg"); + plugin('check',$tmp_plg); + copy("/tmp/plugins/$tmp_plg",$tmp_file); + $plugin_file = $tmp_file; + } +//link/icon $icon = icon($name); - if ($launch = plugin("launch", $plugin_file)) - $link = ""; + if ($launch = plugin('launch',$plugin_file)) + $link = ""; else - $link = ""; -// desc + $link = ""; +//description $readme = "plugins/{$name}/README.md"; if (file_exists($readme)) $desc = Markdown(file_get_contents($readme)); else $desc = Markdown("**{$name}**"); -// author - $author = plugin("author", $plugin_file); - if ($author === false) $author = "anonymous"; -// version - $version = plugin("version", $plugin_file); - if ($version === false) $version = "unknown"; -// version info - $version_info = $version; -// status info - $status_info = "no update"; +//author + $author = plugin('author',$plugin_file) ?: "anonymous"; +//version + $version = plugin('version',$plugin_file) ?: "unknown"; +//category + $cat = strpos($version,'rc')!==false ? 'next' : 'stable'; +//status + $status = 'no update'; $changes_file = $plugin_file; - $URL = plugin("pluginURL", $plugin_file); + $URL = plugin('pluginURL',$plugin_file); if ($URL !== false) { - $filename = "/tmp/plugins/".basename($URL); + $filename = "/tmp/plugins/".(($os && $release) ? $tmp_plg : basename($URL)); if (file_exists($filename)) { - $latest = plugin("version", $filename); - if (strcmp($latest, $version) > 0) { - $unRAID = plugin("unRAID", $filename); - if ($unRAID === false || version_compare($current['version'], $unRAID, '>=')) { - $version_info .= "
{$latest}"; - $status_info = make_link("update", basename($plugin_file)); - $changes_file = $filename; - } else { - $status_info = "up-to-date"; - } + if ($toggle && $toggle != $version) { + $status = make_link('install',$plugin_file,'forced'); } else { - $status_info = "up-to-date"; + $latest = plugin('version',$filename); + if (strcmp($latest,$version) > 0) { + $unRAID = plugin('unRAID',$filename); + if ($unRAID === false || version_compare($current['version'],$unRAID,'>=')) { + $version .= "
{$latest}"; + $status = make_link("update",basename($plugin_file)); + $changes_file = $filename; + } else { + $status = "up-to-date"; + } + } else { + $status = "up-to-date"; + } } } else { - if ($_GET['stale']) $status_info = "unknown"; + if ($stale) $status = "unknown"; } + $nofetch |= ($status == 'no update'); } - $changes = plugin("changes", $changes_file); + $changes = plugin('changes',$changes_file); if ($changes !== false) { $txtfile = "/tmp/plugins/".basename($plugin_file,'.plg').".txt"; - file_put_contents($txtfile, $changes); - $version_info .= " "; + file_put_contents($txtfile,$changes); + $version .= " "; } -// action - $action = strpos($plugin_file, "$docroot/plugins") !== 0 ? make_link("remove", basename($plugin_file)) : "built-in"; -// write plugin information +//write plugin information + $empty = false; echo ""; echo "

{$link}

"; echo "{$desc}"; echo "{$author}"; - echo "{$version_info}"; - echo "{$status_info}"; - echo "{$action}"; + echo "{$version}"; + echo "{$status}"; + echo ""; + if ($system) { + if ($os) { + echo ""; + } + } else { + echo make_link('remove',basename($plugin_file)); + } + echo ""; echo ""; +//remove temporary symlink + @unlink("/var/log/plugins/$tmp_plg"); } +if ($empty) echo " No plugins installed"; +elseif ($nofetch) echo ""; ?> diff --git a/plugins/dynamix.plugin.manager/scripts/plugin b/plugins/dynamix.plugin.manager/scripts/plugin index 7a0a2f08a..df360e11d 100755 --- a/plugins/dynamix.plugin.manager/scripts/plugin +++ b/plugins/dynamix.plugin.manager/scripts/plugin @@ -7,13 +7,15 @@ $usage = << .inline_help{display:none} +.upgrade_notice{position:fixed;top:1px;left:0;width:100%;height:40px;line-height:40px;color:#E68A00;background:#FEEFB3;border-bottom:#E68A00 1px solid;text-align:center;font-size:15px;z-index:999} +.upgrade_notice i{margin:14px;float:right;cursor:pointer} (.*?)<\/a>/,"$1")); + $('#user-notice').html(data.replace(/(.*)<\/a>/,"$1")); +} +function showUpgrade(data,plugin) { + var href = "href=\"#\" onclick=\"hideUpgrade();openBox('/plugins/dynamix.plugin.manager/scripts/plugin&arg1=update&arg2="+plugin+".plg','Update Plugin',600,900,true)\""; + if ($.cookie('os_upgrade')==null) + $('.upgrade_notice').html(data.replace(/(.*)<\/a>/,"$2")+"").show(); +} +function hideUpgrade(set) { + $('.upgrade_notice').hide(); + if (set) + $.cookie('os_upgrade','true',{path:'/'}); + else + $.removeCookie('os_upgrade',{path:'/'}); } function notifier() { var tub1 = 0, tub2 = 0, tub3 = 0; @@ -272,6 +285,7 @@ $(document).ajaxSend(function(elm, xhr, s){
+