WIP: driftkveld i kalenderen

This commit is contained in:
Torstein Nordgård-Hansen 2021-03-16 20:26:38 +01:00
parent b50a4a7ad4
commit 3c24435688
6 changed files with 146 additions and 0 deletions

View File

@ -28,6 +28,7 @@ Composer will check for the php extension `pdo_sqlite` which must be enabled on
[PHP] [PHP]
extension=pdo_sqlite extension=pdo_sqlite
extension=sqlite3 extension=sqlite3
extension=ext-curl
Composer is used as such: Composer is used as such:

View File

@ -27,6 +27,7 @@ use \pvv\side\Agenda;
$agenda = new \pvv\side\Agenda([ $agenda = new \pvv\side\Agenda([
new \pvv\side\social\NerdepitsaActivity, new \pvv\side\social\NerdepitsaActivity,
new \pvv\side\social\AnimekveldActivity, new \pvv\side\social\AnimekveldActivity,
new \pvv\side\social\Driftkveld,
new \pvv\side\DBActivity($pdo), new \pvv\side\DBActivity($pdo),
]); ]);

View File

@ -0,0 +1,36 @@
<?php //declare(strict_types=1);
namespace pvv\side\social;
use \pvv\side\Activity;
use \DateTimeImmutable;
use \DateInterval;
class DriftkveldActivity implements Activity {
public function nextDate(DateTimeImmutable $date) {
if ($date->format('H') > 18 || $date->format('H') == 17 && $date->format('i') > 30)
return $this->nextDate($date->add(new DateInterval('P1D'))->setTime(18, 15, 0));
$date = $date->setTime(18, 15, 0);
if ($date->format('N') != 2)
return $this->nextDate($date->add(new DateInterval('P1D')));
return $date;
}
public function prevDate(DateTimeImmutable $date) {
if ($date->format('H') < 17 || $date->format('H') == 18 && $date->format('i') < 30)
return $this->prevDate($date->sub(new DateInterval('P1D'))->setTime(18, 15, 0));
$date = $date->setTime(18, 15, 0);
if ($date->format('N') != 2)
return $this->prevDate($date->sub(new DateInterval('P1D')));
return $date;
}
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
return new DriftkveldEvent($this->nextDate($date));
}
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
return new DriftkveldEvent($this->prevDate($date));
}
}

View File

@ -0,0 +1,49 @@
<?php //declare(strict_types=1);
namespace pvv\side\social;
use \pvv\side\Event;
use \DateInterval;
class DriftkveldEvent extends Event {
public function getStop() {
return $this->getStart()->add(new DateInterval('PT4H1800S'));
}
public function getName() /* : string */ {
return "Driftkveld";
}
public function getLocation() /* : Location */ {
return "Terminalrommet / Discord / IRC";
}
public function getOrganiser() /* : User */ {
return "Torstein Nordgård-Hansen";
}
public function getURL() /* : string */ {
return '/drift/';
}
public function getImageURL() {
return '/sosiale/drift.jpg';
}
public function getDescription() {
return [
'Vil du drifte?',
'Vil du være kul kis TM?',
'Kom på driftkveld!',
'',
'Vi møtes en gang i uka for å ta unna driftarbeid og drikke kaffe.',
'Alle PVVere er velkommene, enten de er erfarne driftere eller helt utenforstående!'
];
}
public function getColor() {
return "#35a";
}
}

59
www/drift/index.php Normal file
View File

@ -0,0 +1,59 @@
<?php
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
use \pvv\side\Agenda;
?>
<!DOCTYPE html>
<html lang="no">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="../css/normalize.css">
<link rel="stylesheet" href="../css/style.css">
<link rel="stylesheet" href="../css/nav.css">
<link rel="stylesheet" href="../css/events.css">
<meta name="theme-color" content="#024" />
<title>Drifterverkstedet</title>
<header>Sosial&shy;verk&shy;stedet</header>
<main>
<?php
$activity = new \pvv\side\social\DriftkveldActivity;
$nextEvent = $activity->getNextEventFrom(new DateTimeImmutable);
?>
<article>
<h2><em><?= $nextEvent->getRelativeDate()?></em> Driftkveld
<?php if ($nextEvent->getImageURL()) { ?>
<img src="<?= $nextEvent->getImageURL() ?>">
<?php } ?>
</h2>
<ul class="subtext">
<li>Tid:
<strong>
<?= Agenda::getFormattedDate($nextEvent->getStart());?>
</strong>
<li>Sted:
<strong>
<?= $nextEvent->getLocation();?>
</strong>
<li>Arrangør:
<strong>
<?= $nextEvent->getOrganiser();?>
</strong>
</ul>
<?php
$Parsedown = new \Parsedown();
echo $Parsedown->text(implode("\n", $nextEvent->getDescription()));
?>
</article>
</main>
<nav>
<?= navbar(1, 'aktiviteter'); ?>
<?= loginbar($sp, $pdo); ?>
</nav>

BIN
www/sosiale/drift.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB