126 lines
4.4 KiB
PHP
126 lines
4.4 KiB
PHP
<?php
|
|
namespace Makai;
|
|
|
|
$router->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 .= <<<HTML
|
|
<div class="section" id="section-{$sectionId}">
|
|
<div class="section-content">
|
|
<div class="section-background"></div>
|
|
<h1>{$section['title']}</h1>
|
|
<p>{$section['desc']}</p>
|
|
</div>
|
|
</div>
|
|
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 .= <<<HTML
|
|
<div class="project project-type-{$sectionId}" id="{$project->getCleanName()}" style="--project-colour: #{$colour};">
|
|
<div class="project-content">
|
|
<div class="project-details">
|
|
<h2>{$project->getName()}<div class="project-languages">
|
|
HTML;
|
|
|
|
foreach($langs as $lang) {
|
|
$langColour = str_pad(dechex($lang->getColour() ?? 0), 6, '0', STR_PAD_LEFT);
|
|
$body .= "<div class=\"project-language\" style=\"--language-colour: #{$langColour};\">{$lang->getName()}</div>";
|
|
}
|
|
|
|
$body .= '</div></h2>';
|
|
|
|
if($project->hasSummary())
|
|
$body .= "<p class=\"project-details-summary\">{$project->getSummary()}</p>";
|
|
|
|
foreach($descLines as $line) {
|
|
$line = $line->trim();
|
|
|
|
if($line->isEmpty())
|
|
continue;
|
|
|
|
$body .= "<p>{$line}</p>";
|
|
}
|
|
|
|
$body .= '</div>';
|
|
|
|
if(!empty($links)) {
|
|
$body .= '<div class="project-links">';
|
|
|
|
foreach($links as $link)
|
|
$body .= "<a class=\"project-link project-link-{$link['class']}\" href=\"{$link['url']}\" rel=\"noopener\" target=\"_blank\">{$link['text']}</a>";
|
|
|
|
$body .= '</div>';
|
|
}
|
|
|
|
$body .= '</div></div>';
|
|
}
|
|
}
|
|
|
|
$body .= fm_component('footer');
|
|
|
|
return $body;
|
|
});
|