flash.moe/pages/projects.php

92 lines
3.5 KiB
PHP

<?php
if($reqPath === '/projects.php' || $reqPath === '/projects.html'
|| $reqPath === '/utilities' || $reqPath === '/utilities.php' || $reqPath === '/utilities.html') {
if($reqMethod !== 'GET')
return FM_ERR | 405;
header('Location: /projects');
return FM_HIT | 302;
}
if($reqPath === '/projects') {
if($reqMethod !== 'GET')
return FM_ERR | 405;
$projInfo = cache_output('projects', 300, function() {
return json_decode(file_get_contents('https://flash.moe/2020/projects.php?dump_that_shit'));
});
fm_component('header', [
'title' => 'flash.moe / projects',
]);
$sectionInfos = [
'project' => [
'title' => 'Active Projects',
'desc' => 'Projects that I work on on a fairly regular basis.',
],
'tool' => [
'title' => 'Tools',
'desc' => 'Personal quality of life tools that I update when I need something new from them.',
],
'archive' => [
'title' => 'Archived Projects',
'desc' => 'Past projects that I no longer work on.',
],
];
foreach($projInfo as $section => $projects):
$sectionInfo = $sectionInfos[$section];
?>
<div class="section" id="section-<?=$section;?>">
<div class="section-content">
<div class="section-background"></div>
<h1><?=$sectionInfo['title'];?></h1>
<p><?=$sectionInfo['desc'];?></p>
</div>
</div>
<?php
foreach($projects as $proj):
$links = [];
if(isset($proj->homepage))
$links[] = ['class' => 'homepage', 'text' => 'Homepage', 'url' => $proj->homepage];
if(isset($proj->repository))
$links[] = ['class' => 'repository', 'text' => 'Source', 'url' => $proj->repository];
if(isset($proj->forum))
$links[] = ['class' => 'forum', 'text' => 'Discussion', 'url' => $proj->forum];
$descLines = explode("\n", trim($proj->description ?? ''));
?>
<div class="project project-type-<?=$section;?>" id="<?=$proj->name_clean;?>" style="--project-colour: #<?=str_pad(dechex($proj->colour), 6, '0', STR_PAD_LEFT);?>;">
<div class="project-content">
<div class="project-details">
<h2><?=$proj->name;?><div class="project-languages">
<?php foreach($proj->languages as $lang): ?>
<div class="project-language" style="--language-colour: #<?=str_pad(dechex($lang->colour), 6, '0', STR_PAD_LEFT);?>;">
<?=$lang->name;?>
</div>
<?php endforeach; ?>
</div></h2>
<p class="project-details-summary"><?=$proj->summary;?></p>
<?php foreach($descLines as $line): if(empty($line)) continue; ?>
<p><?=trim($line);?></p>
<?php endforeach; ?>
</div>
<?php if(!empty($links)): ?>
<div class="project-links">
<?php foreach($links as $link): ?>
<a class="project-link project-link-<?=$link['class'];?>" href="<?=$link['url'];?>" rel="noopener" target="_blank">
<?=$link['text'];?>
</a>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</div>
<?php
endforeach;
endforeach;
fm_component('footer');
return FM_HIT;
}