213 lines
8.2 KiB
PHP
213 lines
8.2 KiB
PHP
<?php
|
|
if($reqPath === '/about' || $reqPath === '/about.html' || $reqPath === '/about.php'
|
|
|| $reqPath === '/index.php' || $reqPath === '/index.html') {
|
|
if($reqMethod !== 'GET')
|
|
return FM_ERR | 405;
|
|
header('Location: /');
|
|
return FM_HIT | 302;
|
|
}
|
|
|
|
if($reqPath === '/header-bgs.json') {
|
|
if($reqMethod !== 'GET')
|
|
return FM_ERR | 405;
|
|
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
echo json_encode(FM_BGS);
|
|
|
|
return FM_HIT;
|
|
}
|
|
|
|
if($reqPath === '/now-listening') {
|
|
if($reqMethod !== 'GET')
|
|
return FM_ERR | 405;
|
|
|
|
$offset = (int)filter_input(INPUT_GET, 'offset', FILTER_SANITIZE_NUMBER_INT);
|
|
|
|
fm_component('header', [
|
|
'title' => 'flash.moe / now listening',
|
|
'do_fullscreen_header' => true,
|
|
'offset' => $offset,
|
|
]);
|
|
?>
|
|
<script>window.addEventListener('load', function() { window.fm.initIndex(10); });</script>
|
|
<?php
|
|
fm_component('footer', [
|
|
'hide' => true,
|
|
]);
|
|
|
|
return FM_HIT;
|
|
}
|
|
|
|
if($reqPath === '/test') {
|
|
if($reqMethod !== 'GET')
|
|
return FM_ERR | 405;
|
|
|
|
header('Content-Type: text/plain');
|
|
|
|
var_dump(FmProject::byFeatured());
|
|
|
|
return FM_HIT;
|
|
}
|
|
|
|
if($reqPath === '/') {
|
|
if($reqMethod !== 'GET')
|
|
return FM_ERR | 405;
|
|
|
|
$legacyPage = filter_input(INPUT_GET, 'p', FILTER_SANITIZE_STRING);
|
|
if(!empty($legacyPage)) {
|
|
$legacyPages = [
|
|
'projects' => '/projects',
|
|
'contact' => '/contact',
|
|
'about' => '/',
|
|
'etc' => '/etc',
|
|
'hosted' => '/etc',
|
|
'friends' => '/related',
|
|
];
|
|
if(isset($legacyPages[$legacyPage])) {
|
|
header('Location: ' . $legacyPages[$legacyPage]);
|
|
return FM_HIT | 302;
|
|
}
|
|
}
|
|
|
|
$blogInfo = cache_output('blog', 600, function() {
|
|
return json_decode(file_get_contents('https://flash.moe/2020/?blog_dump'));
|
|
});
|
|
$projInfo = cache_output('projects-featured', 300, function() {
|
|
return json_decode(file_get_contents('https://flash.moe/2020/projects.php?dump_that_shit&rf'));
|
|
});
|
|
|
|
shuffle($projInfo);
|
|
|
|
$contact = [
|
|
[
|
|
'id' => 'email',
|
|
'name' => 'E-mail',
|
|
'icon' => 'fmi fmi-email',
|
|
'display' => 'me@flash.moe',
|
|
'link' => 'mailto:me+contact@flash.moe',
|
|
],
|
|
[
|
|
'id' => 'flashii',
|
|
'name' => 'Flashii',
|
|
'icon' => 'fmi fmi-flashii',
|
|
'display' => 'flash',
|
|
'link' => '//flashii.net/profile.php?u=1',
|
|
],
|
|
[
|
|
'id' => 'twitter',
|
|
'name' => 'Twitter',
|
|
'icon' => 'fmi fmi-twitter',
|
|
'display' => '@smugwave',
|
|
'link' => '//twitter.com/smugwave',
|
|
],
|
|
[
|
|
'id' => 'github',
|
|
'name' => 'Github',
|
|
'icon' => 'fmi fmi-github',
|
|
'display' => 'flashwave',
|
|
'link' => '//github.com/flashwave',
|
|
],
|
|
];
|
|
|
|
fm_component('header', [
|
|
'title' => 'flash.moe',
|
|
'is_index' => true,
|
|
]);
|
|
?>
|
|
<div class="index-menu">
|
|
<?php for($i = 1; $i < count(FM_NAV); ++$i): ?>
|
|
<a href="<?=(FM_NAV[$i]['link']);?>"><?=(FM_NAV[$i]['title']);?></a>
|
|
<?php endfor; ?>
|
|
</div>
|
|
<div class="index-featured">
|
|
<div class="index-feature">
|
|
<div class="index-feature-header">
|
|
<a href="//blog.flash.moe" class="index-feature-header-link"></a>
|
|
<div class="index-feature-header-title">Blog</div>
|
|
<div class="index-feature-header-more">More</div>
|
|
</div>
|
|
<div class="index-blog">
|
|
<?php $blogCount = 0; foreach($blogInfo as $blogPost): if($blogCount++ >= 5) break; ?>
|
|
<div class="index-blog-post">
|
|
<a href="//flash.moe/blog/<?=$blogPost->post_id;?>" class="index-blog-post-link"></a>
|
|
<div class="index-blog-post-header">
|
|
<div class="index-blog-post-title"><?=$blogPost->post_title;?></div>
|
|
<div class="index-blog-post-published"><time datetime="<?=date('c', $blogPost->post_published);?>" title="<?=date('r', $blogPost->post_published);?>"><?=time_elapsed($blogPost->post_published);?></time></div>
|
|
</div>
|
|
<div class="index-blog-post-content">
|
|
<?=first_paragraph($blogPost->post_text);?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
<div class="index-feature">
|
|
<div class="index-feature-header">
|
|
<a href="/projects" class="index-feature-header-link"></a>
|
|
<div class="index-feature-header-title">Projects</div>
|
|
<div class="index-feature-header-more">More</div>
|
|
</div>
|
|
<?php
|
|
$projCount = 0;
|
|
foreach($projInfo as $proj):
|
|
if($projCount++ >= 3)
|
|
break;
|
|
|
|
$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];
|
|
?>
|
|
<div class="index-project" style="background-color: #<?=str_pad(dechex($proj->colour), 6, '0', STR_PAD_LEFT);?>;">
|
|
<a href="/projects#<?=$proj->name_clean;?>" class="index-project-anchor"></a>
|
|
<div class="index-project-content">
|
|
<div class="index-project-name"><?=$proj->name;?></div>
|
|
<div class="index-project-summary"><?=$proj->summary;?></div>
|
|
</div>
|
|
<?php if(!empty($links)): ?>
|
|
<div class="index-project-links">
|
|
<?php foreach($links as $link): ?>
|
|
<a class="index-project-link index-project-link-<?=$link['class'];?>" href="<?=$link['url'];?>" rel="noopener" target="_blank">
|
|
<?=$link['text'];?>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<div class="index-feature">
|
|
<div class="index-feature-header">
|
|
<a href="/contact" class="index-feature-header-link"></a>
|
|
<div class="index-feature-header-title">Contact</div>
|
|
<div class="index-feature-header-more">More</div>
|
|
</div>
|
|
<div class="index-contact">
|
|
<?php foreach($contact as $social): ?>
|
|
<div class="social social-<?=$social['id'];?>">
|
|
<?php if(isset($social['link'])): ?>
|
|
<a href="<?=$social['link'];?>" class="social-background" target="_blank" rel="noopener"></a>
|
|
<?php else: ?>
|
|
<div class="social-background" onclick="fm.selectTextInElement(this.parentNode.querySelector('.social-handle')); fm.copySelectedText();"></div>
|
|
<?php endif; ?>
|
|
<div class="social-icon <?=$social['icon'];?>"></div>
|
|
<div class="social-content">
|
|
<div class="social-name"><?=$social['name'];?></div>
|
|
<div class="social-handle"><?=$social['display'];?></div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>window.addEventListener('load', function() { window.fm.initIndex(); });</script>
|
|
<?php
|
|
fm_component('footer', [
|
|
'is_index' => true,
|
|
]);
|
|
|
|
return FM_HIT;
|
|
}
|