$app */ $app = require __DIR__ . '/src/bootstrap.php'; $config = $app['config']; $repository = $app['repository']; $service = $app['service']; $activeSource = $_GET['source'] ?? null; if (!is_string($activeSource) || $activeSource === '') { $activeSource = null; } $ranges = $config['ranges'] ?? []; $activeRange = $_GET['range'] ?? ''; if (!is_string($activeRange) || !array_key_exists($activeRange, $ranges)) { $activeRange = ''; } $since = $activeRange !== '' ? gmdate('c', time() - (int) $ranges[$activeRange]) : null; $pageSize = (int) $config['page_size']; // Register the configured feeds before anything renders so the filter tabs are // complete on a fresh database; refreshStale() repeats the same sync cheaply. $repository->syncFeeds($app['feeds']); $sources = $service->sources(); if ($activeSource !== null && !in_array($activeSource, $sources, true)) { $activeSource = null; } // Send the shell (header, filters and the feed loader) before refreshing, so // the loader is on screen while the feeds are being fetched. Nothing may hold // those bytes back. ini_set('zlib.output_compression', '0'); while (ob_get_level() > 0 && ob_end_flush()) { // Drop any active output buffers so the shell reaches the browser now. } echo App\View::render('shell', [ 'config' => $config, 'sources' => $sources, 'activeSource' => $activeSource, 'activeRange' => $activeRange, 'cachedTotal' => $repository->countItems($activeSource, $since), ]); flush(); $refresh = $service->refreshStale(); $page = $service->page($activeSource, 1, $pageSize, $since); echo App\View::render('content', [ 'activeSource' => $activeSource, 'activeRange' => $activeRange, 'page' => $page, 'refresh' => $refresh, ]);