diff options
author | Olivier Blin <dev@blino.org> | 2016-10-05 23:28:01 +0200 |
---|---|---|
committer | Olivier Blin <dev@blino.org> | 2016-10-05 23:31:57 +0200 |
commit | 09dc9f8d2ae8fe21e1a115d400db023b16ff8347 (patch) | |
tree | feb88edfe56016c5e1dc047f3c90247b0a594ff6 | |
parent | fb2e997c9212f00ae977259465a06e9cc5947abb (diff) | |
download | pkgsubmit-09dc9f8d2ae8fe21e1a115d400db023b16ff8347.tar pkgsubmit-09dc9f8d2ae8fe21e1a115d400db023b16ff8347.tar.gz pkgsubmit-09dc9f8d2ae8fe21e1a115d400db023b16ff8347.tar.bz2 pkgsubmit-09dc9f8d2ae8fe21e1a115d400db023b16ff8347.tar.xz pkgsubmit-09dc9f8d2ae8fe21e1a115d400db023b16ff8347.zip |
Load check's dependencies.rss asynchronously to avoid hangs
The synchronous load was hanging pkgsubmit load in case alamut was down.
-rw-r--r-- | themes/mageia/page_header.php | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/themes/mageia/page_header.php b/themes/mageia/page_header.php index 5cb0885..eb0f835 100644 --- a/themes/mageia/page_header.php +++ b/themes/mageia/page_header.php @@ -13,21 +13,17 @@ <body class="contribute"> <?php -$figures_list = array(); - if (!isset($_GET['package'])) { + $figures_list = array(); + $separator = ', '; // TODO should be cached. - $missing_deps_count = preg_match_all("/<item>/m", file_get_contents("http://check.mageia.org/cauldron/dependencies.rss"), $matches); $unmaintained_file = $g_webapp_dir . '/data/unmaintained.txt'; $unmaintained_count = file_exists($unmaintained_file) ? count(file($unmaintained_file)) : 0; - if ($missing_deps_count > 0) { - $figures_list[] = sprintf('<strong>%d</strong> <a rel="nofollow" href="%s">broken <abbr title="dependencies">deps.</abbr></a>', - $missing_deps_count, + $missing_deps = sprintf('<span id="missing_deps" style="display: none"><strong id="missing_deps_count"></strong> <a rel="nofollow" href="%s">broken <abbr title="dependencies">deps.</abbr></a>' . $separator . '</span>', 'http://check.mageia.org/cauldron/dependencies.html' ); - } if ($unmaintained_count > 0) { $figures_list[] = sprintf('<strong>%d</strong> <a rel="nofollow" href="%s">unmaintained</a>', @@ -48,10 +44,7 @@ if (!isset($_GET['package'])) { 'YES you can help!', 'see how' ); - $html_figures = null; - if (count($figures_list) > 0) { - $html_figures = 'Packages: ' . implode(', ', $figures_list) . '.'; - } + $html_figures = 'Packages: ' . $missing_deps . implode($separator, $figures_list) . '.'; ?> <header id="mgnavt"> @@ -61,6 +54,17 @@ if (!isset($_GET['package'])) { <li><?php echo $html_figures; ?></li> </ul> </header> + <script type="text/javascript"> + var req = new XMLHttpRequest(); + var deps_url = "http://check.mageia.org/cauldron/dependencies.rss"; + req.open('GET', deps_url, true); + req.onload = function () { + var missing_deps_count = req.responseText.match(/<item>/gm); + document.getElementById("missing_deps_count").innerText = missing_deps_count.length; + document.getElementById("missing_deps").style = ""; // make it visible + }; + req.send(); + </script> <article> <?php } |