$posts, View::LAYOUT_PARAMS => [ 'showRssLink' => true ] ]]; } if ($slug == static::SLUG_RSS) { $posts = Post::find(static::VIEW_FOLDER_NEWS, Post::SORT_DATE_DESC); Response::setHeader(Response::HEADER_CONTENT_TYPE, 'text/xml; charset=utf-8'); return ['content/rss', [ 'posts' => array_slice($posts, 0, 10), '_no_layout' => true ]]; } try { $post = Post::load(static::SLUG_NEWS . '/' . ltrim($slug, '/')); } catch (PostNotFoundException $e) { return NavActions::execute404(); } return ['content/news-post', [ 'post' => $post, View::LAYOUT_PARAMS => [ 'showRssLink' => true ] ]]; } public static function executeFaq(string $slug = null): array { Response::enableHttpCache(); if (!$slug) { $allPosts = Post::find(static::VIEW_FOLDER_FAQ); $allCategories = [ 'getstarted' => 'Getting Started', 'setup' => 'Installing and Running LBRY', 'LBRY 101' => 'LBRY 101', 'wallet' => 'The LBRY Wallet', 'mining' => 'Mining LBC', 'policy' => 'Policies', 'developer' => 'Developers', 'differences' => 'What Makes LBRY Different?', 'other' => 'Other Questions', ] + Post::collectMetadata($allPosts, 'category'); $selectedCategory = Request::getParam('category'); $filters = array_filter([ 'category' => $selectedCategory && isset($allCategories[$selectedCategory]) ? $selectedCategory : null, ]); $posts = $filters ? Post::filter($allPosts, $filters) : $allPosts; $groups = array_fill_keys(array_keys($allCategories), []); foreach ($posts as $post) { $groups[$post->getCategory()][] = $post; } return ['content/faq', [ 'categories' => $allCategories, 'selectedCategory' => $selectedCategory, 'postGroups' => $groups ]]; } try { $post = Post::load(static::SLUG_FAQ . '/' . ltrim($slug, '/')); } catch (PostNotFoundException $e) { return NavActions::execute404(); } return ['content/faq-post', ['post' => $post]]; } public static function executePress(string $slug = null): array { Response::enableHttpCache(); try { $post = Post::load(static::SLUG_PRESS . '/' . ltrim($slug, '/')); } catch (PostNotFoundException $e) { return NavActions::execute404(); } return ['content/press-post', ['post' => $post]]; } public static function executeBounty(string $slug = null): array { Response::enableHttpCache(); if ($slug) { list($metadata, $postHtml) = View::parseMarkdown(ContentActions::VIEW_FOLDER_BOUNTY . '/' . $slug . '.md'); if (!$postHtml) { return NavActions::execute404(); } return ['bounty/show', [ 'postHtml' => $postHtml, 'metadata' => $metadata ]]; } $allBounties = Post::find(static::CONTENT_DIR . '/bounty'); $allCategories = ['' => ''] + Post::collectMetadata($allBounties, 'category'); $allStatuses = ['' => ''] + array_merge(Post::collectMetadata($allBounties, 'status'), ['complete' => 'unavailable']); $selectedStatus = Request::getParam('status', 'available'); $selectedCategory = Request::getParam('category'); $filters = array_filter([ 'category' => $selectedCategory && isset($allCategories[$selectedCategory]) ? $selectedCategory : null, 'status' => $selectedStatus && isset($allStatuses[$selectedStatus]) ? $selectedStatus : null ]); $bounties = $filters ? Post::filter($allBounties, $filters) : $allBounties; uasort($bounties, function($postA, $postB) { $metadataA = $postA->getMetadata(); $metadataB = $postB->getMetadata(); $awardA = strpos('-', $metadataA['award']) !== false ? rtrim(explode('-', $metadataA['award'])[0], '+') : $metadataA['award']; $awardB = strpos('-', $metadataB['award']) !== false ? rtrim(explode('-', $metadataB['award'])[0], '+') : $metadataB['award']; if ($awardA != $awardB) { return $awardA > $awardB ? -1 : 1; } return $metadataA['title'] < $metadataB['title'] ? -1 : 1; }); return ['bounty/list', [ 'bounties' => $bounties, 'categories' => $allCategories, 'statuses' => $allStatuses, 'selectedCategory' => $selectedCategory, 'selectedStatus' => $selectedStatus ]]; } public static function executeRoadmap() { $cache = !Request::getParam('nocache'); $githubItems = Github::listRoadmapChangesets($cache); $projectMaxVersions = []; foreach($githubItems as $group => $items) { if ($items) { $lastItem = end($items); $project = $lastItem['project']; if (!isset($projectMaxVersions[$project]) || $lastItem['version'] > $projectMaxVersions[$project]) { $projectMaxVersions[$project] = $lastItem['version']; } } } $items = array_merge($githubItems, Asana::listRoadmapTasks($cache)); return ['content/roadmap', [ 'projectMaxVersions' => $projectMaxVersions, 'items' => $items ]]; } public static function executePressKit(): array { $zipFileName = 'lbry-press-kit-' . date('Y-m-d') . '.zip'; $zipPath = tempnam('/tmp', $zipFileName); $zip = new ZipArchive(); $zip->open($zipPath, ZipArchive::OVERWRITE); // $pageHtml = View::render('page/press-kit', ['showHeader' => false]); // $html = << // // // LBRY Press Kit // // // // // $pageHtml // // //EOD; // // $zip->addFromString('press.html', $html); foreach (glob(ROOT_DIR . '/web/img/press/*') as $productImgPath) { $imgPathTokens = explode('/', $productImgPath); $imgName = $imgPathTokens[count($imgPathTokens) - 1]; $zip->addFile($productImgPath, '/logo_and_product/' . $imgName); } foreach (glob(ContentActions::CONTENT_DIR . '/bio/*.md') as $bioPath) { list($metadata, $bioHtml) = View::parseMarkdown($bioPath); $zip->addFile($bioPath, '/team_bios/' . $metadata['name'] . ' - ' . $metadata['role'] . '.txt'); } foreach (array_filter(glob(ROOT_DIR . '/web/img/team/*.jpg'), function ($path) { return strpos($path, 'spooner') === false; }) as $bioImgPath) { $imgPathTokens = explode('/', $bioImgPath); $imgName = str_replace('644x450', 'lbry', $imgPathTokens[count($imgPathTokens) - 1]); $zip->addFile($bioImgPath, '/team_photos/' . $imgName); } $zip->close(); Response::enableHttpCache(); Response::setDownloadHttpHeaders($zipFileName, 'application/zip', filesize($zipPath)); return ['internal/zip', [ '_no_layout' => true, 'zipPath' => $zipPath ]]; } public static function prepareBioPartial(array $vars): array { $person = $vars['person']; $path = 'bio/' . $person . '.md'; list($metadata, $bioHtml) = View::parseMarkdown($path); $relativeImgSrc = '/img/team/' . $person . '-644x450.jpg'; $imgSrc = file_exists(ROOT_DIR . '/web' . $relativeImgSrc) ? $relativeImgSrc : '/img/team/spooner-644x450.jpg'; return $vars + $metadata + [ 'imgSrc' => $imgSrc, 'bioHtml' => $bioHtml, 'orientation' => 'vertical' ]; } public static function preparePostAuthorPartial(array $vars): array { $post = $vars['post']; return [ 'authorName' => $post->getAuthorName(), 'photoImgSrc' => $post->getAuthorPhoto(), 'authorBioHtml' => $post->getAuthorBioHtml() ]; } public static function preparePostListPartial(array $vars): array { $count = $vars['count'] ?? 3; return [ 'posts' => array_slice(Post::find(static::VIEW_FOLDER_NEWS, Post::SORT_DATE_DESC), 0, $count) ]; } }