flash.moe/tpl/projects.php

84 lines
3.3 KiB
PHP

<?php
$self->extends('master');
$self->header_title = 'flash.moe / projects';
$self->block('container', function($self) {
?>
<?php foreach($self->sections as $sectionId => $section): ?>
<div class="section" id="section-<?=$sectionId;?>">
<div class="section-content">
<div class="section-background"></div>
<h1><?=$section['title'];?></h1>
</div>
</div>
<?php
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 = $self->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);
?>
<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">
<?php
foreach($langs as $lang):
$langColour = str_pad(dechex($lang->getColour() ?? 0), 6, '0', STR_PAD_LEFT);
?>
<div class="project-language" style="--language-colour: #<?=$langColour;?>;"><?=$lang->getName();?></div>
<?php endforeach; ?>
</div></h2>
<?php if($project->hasSummary()): ?>
<p class="project-details-summary"><?=$project->getSummary();?></p>
<?php endif; ?>
<?php
foreach($descLines as $line):
$line = $line->trim();
if($line->isEmpty())
continue;
?>
<p><?=$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; ?>
<?php endforeach; ?>
<?php
});