Social shit in database now.

This commit is contained in:
Pachira 2022-09-26 19:09:33 +00:00
parent 7f8eab6364
commit cfdc5e4dd7
5 changed files with 160 additions and 131 deletions

View file

@ -6,103 +6,44 @@ $router->get('/contact.html', mkiRedirect('/contact'));
$router->get('/nintendo', mkiRedirect('/contact'));
$router->get('/nintendo.php', mkiRedirect('/contact'));
$router->get('/contact', function() {
$contact = [
[
'id' => 'contact',
'title' => 'Direct Contact',
'items' => [
[
'id' => 'email',
'name' => 'E-mail',
'icon' => 'fmi fmi-email',
'display' => 'contact@flash.moe',
'link' => 'mailto:contact@flash.moe',
],
],
],
[
'id' => 'communities',
'title' => 'Communities & Social Media',
'items' => [
[
'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' => '@flashwahaha',
'link' => '//twitter.com/flashwahaha',
],
[
'id' => 'youtube',
'name' => 'YouTube',
'icon' => 'fmi fmi-youtube',
'display' => 'flashwave',
'link' => '//youtube.com/c/flashwave',
],
[
'id' => 'github',
'name' => 'Github',
'icon' => 'fmi fmi-github',
'display' => 'flashwave',
'link' => '//github.com/flashwave',
],
[
'id' => 'lastfm',
'name' => 'Last.fm',
'icon' => 'fmi fmi-lastfm',
'display' => 'flashwave_',
'link' => '//last.fm/user/flashwave_',
],
],
],
];
$router->get('/contact', function() use ($db) {
$contacts = (new Contacts($db))->getAll();
$body = fm_component('header', [
'title' => 'flash.moe / contact',
]);
foreach($contact as $section) {
$body .= <<<HTML
<div class="section" id="section-{$section['id']}">
<div class="section-content">
<div class="section-background"></div>
<h1>{$section['title']}</h1>
</div>
</div>
<div class="socials">
$body .= <<<HTML
<div class="section">
<div class="section-content">
<div class="section-background"></div>
<h1>Contacts</h1>
</div>
</div>
<div class="socials">
HTML;
foreach($section['items'] as $social) {
$body .= '<div class="social social-' . $social['id'] . '">';
foreach($contacts as $contact) {
$body .= '<div class="social social-' . $contact->getName() . '" style="--social-colour: ' . $contact->getColourHex() . '">';
if(isset($social['link'])) {
$body .= '<a href="' . $social['link'] . '" class="social-background" target="_blank" rel="noopener"></a>';
} else {
$body .= '<div class="social-background" onclick="fm.selectTextInElement(this.parentNode.querySelector(\'.social-handle\')); fm.copySelectedText();"></div>';
}
$body .= <<<HTML
<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>
HTML;
if($contact->hasLink()) {
$body .= '<a href="' . $contact->getLink() . '" class="social-background" target="_blank" rel="noopener"></a>';
} else {
$body .= '<div class="social-background" onclick="fm.selectTextInElement(this.parentNode.querySelector(\'.social-handle\')); fm.copySelectedText();"></div>';
}
$body .= '</div>';
$body .= <<<HTML
<div class="social-icon {$contact->getIcon()}"></div>
<div class="social-content">
<div class="social-name">{$contact->getName()}</div>
<div class="social-handle">{$contact->getDisplay()}</div>
</div>
</div>
HTML;
}
$body .= '</div>';
$body .= fm_component('footer');
return $body;

View file

@ -158,30 +158,7 @@ $router->get('/', function() use ($db) {
$projects = (new Projects($db))->getFeatured();
$languages = new Languages($db);
$contact = [
[
'id' => 'email',
'name' => 'E-mail',
'icon' => 'fmi fmi-email',
'display' => 'contact@flash.moe',
'link' => 'mailto: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' => '@flashwahaha',
'link' => '//twitter.com/flashwahaha',
],
];
$contacts = (new Contacts($db))->getHomePage();
$body = fm_component('header', [
'title' => 'flash.moe',
@ -261,20 +238,20 @@ HTML;
<div class="index-contact">
HTML;
foreach($contact as $social) {
$body .= "<div class=\"social social-{$social['id']}\">";
foreach($contacts as $contact) {
$body .= "<div class=\"social social-{$contact->getName()}\" style=\"--social-colour: {$contact->getColourHex()}\">";
if(isset($social['link'])) {
$body .= "<a href=\"{$social['link']}\" class=\"social-background\" target=\"_blank\" rel=\"noopener\"></a>";
if($contact->hasLink()) {
$body .= "<a href=\"{$contact->getLink()}\" class=\"social-background\" target=\"_blank\" rel=\"noopener\"></a>";
} else {
$body .= "<div class=\"social-background\" onclick=\"fm.selectTextInElement(this.parentNode.querySelector('.social-handle')); fm.copySelectedText();\"></div>";
}
$body .= <<<HTML
<div class="social-icon {$social['icon']}"></div>
<div class="social-icon {$contact->getIcon()}"></div>
<div class="social-content">
<div class="social-name">{$social['name']}</div>
<div class="social-handle">{$social['display']}</div>
<div class="social-name">{$contact->getTitle()}</div>
<div class="social-handle">{$contact->getDisplay()}</div>
</div>
</div>
HTML;

View file

@ -275,6 +275,7 @@ body {
height: 100%;
background-image: linear-gradient(0deg, #1118 0%, #2228 50%, #3338 50%, #5558 100%);
transform: skew(-15deg);
background-color: var(--social-colour);
}
.social:active .social-background {
background-image: linear-gradient(0deg, #1118 0%, #2228 50%, #3338 50%, #3338 100%);
@ -298,21 +299,6 @@ body {
line-height: 1.3em;
font-family: 'Electrolize', Verdana, 'Dejavu Sans', Arial, Helvetica, sans-serif;
}
.social-twitter .social-background { background-color: #1da1f2; }
.social-youtube .social-background { background-color: #ff0000; }
.social-flashii .social-background { background-color: #8559a5; }
.social-github .social-background { background-color: #222222; }
.social-twitch .social-background { background-color: #6441a4; }
.social-steam .social-background { background-color: #2c2e35; }
.social-osu .social-background { background-color: #ff66aa; }
.social-tetrio .social-background { background-color: #40c045; }
.social-email .social-background { background-color: #4a3650; }
.social-lastfm .social-background { background-color: #ba0000; }
.social-nin-sw .social-background { background-color: #e60012; }
.social-nin-3ds .social-background { background-color: #ce171f; }
.social-nin-wiiu .social-background { background-color: #00acca; }
.social-paypal .social-background { background-color: #009cde; }
.social-patreon .social-background { background-color: #f86754; }
.index-featured {
display: grid;

70
src/ContactInfo.php Normal file
View file

@ -0,0 +1,70 @@
<?php
namespace Makai;
use Index\WString;
class ContactInfo {
private string $name;
private bool $homePage;
private int $order;
private WString $title;
private string $icon;
private int $colour;
private WString $display;
private ?string $link;
public function __construct(
string $name, bool $homePage, int $order,
WString $title, string $icon, int $colour,
WString $display, ?string $link
) {
$this->name = $name;
$this->homePage = $homePage;
$this->order = $order;
$this->title = $title;
$this->icon = $icon;
$this->colour = $colour;
$this->display = $display;
$this->link = $link;
}
public function getName(): string {
return $this->name;
}
public function isHomePage(): bool {
return $this->homePage;
}
public function getOrder(): int {
return $this->order;
}
public function getTitle(): WString {
return $this->title;
}
public function getIcon(): string {
return $this->icon;
}
public function getColour(): int {
return $this->colour;
}
public function getColourHex(): string {
return '#' . str_pad(dechex($this->colour), 6, '0', STR_PAD_LEFT);
}
public function getDisplay(): WString {
return $this->display;
}
public function hasLink(): bool {
return $this->link !== null;
}
public function getLink(): ?string {
return $this->link;
}
}

55
src/Contacts.php Normal file
View file

@ -0,0 +1,55 @@
<?php
namespace Makai;
use Index\Data\IDbConnection;
use Index\Data\IDbResult;
class Contacts {
private const QUERY = 'SELECT `cont_name`, `cont_homepage`, `cont_order`, `cont_title`, `cont_icon`, `cont_colour`, `cont_display`, `cont_link` FROM `fm_contacts`';
private const QUERY_HOME = self::QUERY . ' WHERE `cont_homepage` <> 0 ORDER BY `cont_order` LIMIT 3';
private const QUERY_ALL = self::QUERY . ' ORDER BY `cont_order`';
private IDbConnection $conn;
public function __construct(IDbConnection $conn) {
$this->conn = $conn;
}
public function getAll(): array {
$stmt = $this->conn->prepare(self::QUERY_ALL);
$stmt->execute();
$result = $stmt->getResult();
$objs = [];
while($result->next())
$objs[] = self::createObject($result);
return $objs;
}
public function getHomePage(): array {
$stmt = $this->conn->prepare(self::QUERY_HOME);
$stmt->execute();
$result = $stmt->getResult();
$objs = [];
while($result->next())
$objs[] = self::createObject($result);
return $objs;
}
private static function createObject(IDbResult $result): ContactInfo {
return new ContactInfo(
$result->getString(0), // name
$result->getInteger(1) !== 0, // homepage
$result->getInteger(2), // order
$result->getWString(3, 'utf-8'), // title
$result->getString(4), // icon
$result->getInteger(5), // colour
$result->getWString(6, 'utf-8'), // display
$result->isNull(7) ? null : $result->getString(7) // link
);
}
}