flash.moe/pages/index.php

259 lines
10 KiB
PHP
Raw Normal View History

2020-07-30 00:55:37 +00:00
<?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;
}
2020-07-30 00:55:37 +00:00
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;
}
2020-08-21 00:33:19 +00:00
if($reqPath === '/home') {
if($reqMethod !== 'GET')
return FM_ERR | 405;
fm_component('header', [
'title' => 'flash.moe / homepage',
'do_fullscreen_header' => true,
]);
?>
<div class="php">
<div class="php-time">
<div class="php-time-analog">
<div class="clock">
<div class="clock-background"></div>
<div class="clock-center"></div>
<div class="clock-hand clock-hand-hours"><div class="clock-hand-display"></div></div>
<div class="clock-hand clock-hand-minutes"><div class="clock-hand-display"></div></div>
<div class="clock-hand clock-hand-seconds"><div class="clock-hand-display"></div></div>
<div class="clock-number clock-number-3"><div class="clock-number-display"></div></div>
<div class="clock-number clock-number-6"><div class="clock-number-display"></div></div>
<div class="clock-number clock-number-9"><div class="clock-number-display"></div></div>
<div class="clock-number clock-number-12"><div class="clock-number-display"></div></div>
</div>
</div>
<div class="php-time-digital">
<div class="php-time-digital-hours">--</div>
<div class="php-time-digital-separator" id=>:</div>
<div class="php-time-digital-minutes" i>--</div>
</div>
</div>
<form class="php-search" method="get" action="https://duckduckgo.com/">
<div class="php-search-input">
<input type="search" name="q" placeholder="Search using DuckDuckGo..."/>
</div>
</form>
</div>
<script>window.addEventListener('load', function() { window.fm.initClock(); window.fm.initIndex(10); });</script>
<?php
fm_component('footer', [
'hide' => true,
]);
return FM_HIT;
}
2020-07-30 00:55:37 +00:00
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',
2020-08-19 01:20:25 +00:00
'icon' => 'fmi fmi-email',
2020-07-30 00:55:37 +00:00
'display' => 'me@flash.moe',
'link' => 'mailto:me+contact@flash.moe',
],
[
'id' => 'flashii',
'name' => 'Flashii',
2020-08-19 01:20:25 +00:00
'icon' => 'fmi fmi-flashii',
2020-07-30 00:55:37 +00:00
'display' => 'flash',
'link' => '//flashii.net/profile.php?u=1',
],
[
'id' => 'twitter',
'name' => 'Twitter',
2020-08-19 01:20:25 +00:00
'icon' => 'fmi fmi-twitter',
2020-07-30 00:55:37 +00:00
'display' => '@smugwave',
'link' => '//twitter.com/smugwave',
],
[
'id' => 'github',
'name' => 'Github',
2020-08-19 01:20:25 +00:00
'icon' => 'fmi fmi-github',
2020-07-30 00:55:37 +00:00
'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; ?>
2020-08-19 01:20:25 +00:00
<div class="social-icon <?=$social['icon'];?>"></div>
2020-07-30 00:55:37 +00:00
<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;
}