get('/projects.php', mkiRedirect('/projects')); $router->get('/projects.html', mkiRedirect('/projects')); $router->get('/utilities', mkiRedirect('/projects')); $router->get('/utilities.php', mkiRedirect('/projects')); $router->get('/utilities.html', mkiRedirect('/projects')); $router->get('/projects', function() use ($db) { $projects = (new Projects($db))->getAll(); $languages = new Languages($db); $sections = [ 'projects' => [ 'title' => 'Active Projects', 'desc' => 'Projects that I work on on a fairly regular basis.', 'items' => [], ], 'tools' => [ 'title' => 'Tools', 'desc' => 'Personal quality of life tools that I update when I need something new from them.', 'items' => [], ], 'archives' => [ 'title' => 'Archived Projects', 'desc' => 'Past projects that I no longer work on.', 'items' => [], ], ]; foreach($projects as $project) { if($project->isArchived()) $sections['archives']['items'][] = $project; else { if($project->isTool()) $sections['tools']['items'][] = $project; else $sections['projects']['items'][] = $project; } } $body = fm_component('header', [ 'title' => 'flash.moe / projects', ]); foreach($sections as $sectionId => $section) { $body .= <<

{$section['title']}

{$section['desc']}

HTML; foreach($section['items'] as $project) { $links = []; if($project->hasHomePageUrl()) $links[] = ['class' => 'homepage', 'text' => 'Homepage', 'url' => $project->getHomePageUrl()]; if($project->hasSourceUrl()) $links[] = ['class' => 'repository', 'text' => 'Source', 'url' => $project->getSourceUrl()]; if($project->hasDiscussionUrl()) $links[] = ['class' => 'forum', 'text' => 'Discussion', 'url' => $project->getDiscussionUrl()]; $descLines = $project->hasDescription() ? $project->getDescription()->trim()->split("\n") : []; $langs = $languages->getByProject($project); if($project->hasColour()) $colour = $project->getColour(); else foreach($langs as $lang) if($lang->hasColour()) { $colour = $lang->getColour(); break; } $colour = str_pad(dechex($colour), 6, '0', STR_PAD_LEFT); $body .= <<

{$project->getName()}
HTML; foreach($langs as $lang) { $langColour = str_pad(dechex($lang->getColour() ?? 0), 6, '0', STR_PAD_LEFT); $body .= "
{$lang->getName()}
"; } $body .= '

'; if($project->hasSummary()) $body .= "

{$project->getSummary()}

"; foreach($descLines as $line) { $line = $line->trim(); if($line->isEmpty()) continue; $body .= "

{$line}

"; } $body .= '
'; if(!empty($links)) { $body .= ''; } $body .= '
'; } } $body .= fm_component('footer'); return $body; });