2020-02-13 23:35:11 +01:00
|
|
|
<?php
|
|
|
|
require_once 'vendor/autoload.php';
|
|
|
|
use ICal\ICal;
|
|
|
|
$state_map = array(
|
|
|
|
'closed' => (object) array(
|
|
|
|
'state_string' => 'Das Dorf ist gerade <em>geschlossen</em>',
|
|
|
|
'svg' => 'lock',
|
|
|
|
'color' => 'red',
|
|
|
|
),
|
|
|
|
'maybe_open' => (object) array(
|
|
|
|
'state_string' => 'Das Dorf ist gerade <em>vielleicht geöffnet</em>',
|
|
|
|
'svg' => 'done',
|
|
|
|
'color' => 'brown',
|
|
|
|
),
|
|
|
|
'open' => (object) array(
|
|
|
|
'state_string' => 'Das Dorf ist gerade <em>geöffnet</em>',
|
|
|
|
'svg' => 'done',
|
|
|
|
'color' => 'green',
|
|
|
|
),
|
|
|
|
'private' => (object) array(
|
|
|
|
'state_string' => 'Das Dorf ist gerade <em>privat</em>: Es sind Leute da, aber der Clubraum ist nicht geöffnet.',
|
|
|
|
'svg' => 'lock',
|
|
|
|
'color' => '#fdd835',
|
|
|
|
),
|
|
|
|
'unknown' => (object) array(
|
|
|
|
'state_string' => 'Der Status vom Dorf ist gerade <em>unbekannt</em>',
|
|
|
|
'svg' => 'warning',
|
|
|
|
'color' => 'orange',
|
|
|
|
),
|
|
|
|
'error' => (object) array(
|
|
|
|
'state_string' => 'Der Server konnte den Status vom Dorf nicht abrufen.',
|
|
|
|
'svg' => 'error',
|
|
|
|
'color' => 'blue',
|
|
|
|
),
|
|
|
|
);
|
|
|
|
$hash_to_state = array(
|
|
|
|
'bff0167ed8aba031c49122ef4046cf1b' => 'closed',
|
|
|
|
'd8ec899c69283bc775952a767db9d5f5' => 'maybe_open',
|
|
|
|
'2c2672c641425e5b2acd6ee74f39ae60' => 'open',
|
|
|
|
'66aece8ae27ffd3a656d42005fa3efbd' => 'private',
|
|
|
|
'86c75c0ad413b06ff8291673162d0b64' => 'unknown',
|
|
|
|
'0' => 'error',
|
|
|
|
);
|
|
|
|
|
|
|
|
$img = file_get_contents('https://chaosdorf.de/raumstatus/status.png');
|
|
|
|
$hash = md5($img);
|
|
|
|
$state = $hash_to_state[$hash];
|
|
|
|
$ical = new ICal(false, array(
|
|
|
|
'defaultSpan' => 2,
|
|
|
|
'defaultTimeZone' => 'Europe/Berlin',
|
|
|
|
'defaultWeekStart' => 'MO',
|
|
|
|
'filterDaysBefore' => '0',
|
|
|
|
));
|
|
|
|
$ical->initUrl('https://chaosdorf.de/~derf/cccd.ics', $acceptLanguage = 'de');
|
|
|
|
$events = $ical->eventsFromInterval('2 week');
|
|
|
|
$first_event = $events[0];
|
|
|
|
$events = array_slice($events, 1);
|
|
|
|
$locale = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
|
|
|
if ($locale !== null){
|
|
|
|
setlocale(LC_TIME, $locale);
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="de">
|
|
|
|
<head>
|
|
|
|
<title>Was geht im Dorf.jetzt?</title>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
|
|
|
<link rel="stylesheet" href="assets/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
|
|
|
|
<link href="assets/font/Material-Icons.css" rel="stylesheet">
|
|
|
|
<meta charset="UTF-8" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="container">
|
|
|
|
<nav class="navbar">
|
|
|
|
<h1 class="text-center">Was geht im Dorf.jetzt?</h1><hr />
|
|
|
|
</nav>
|
|
|
|
<div class="card-deck mb-3 text-center">
|
|
|
|
<div class="card" style="width: 18rem;">
|
|
|
|
<div class="card-img-top">
|
2020-02-14 00:19:15 +01:00
|
|
|
|
2020-02-13 23:35:11 +01:00
|
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
|
|
<h5 class="card-title">Türstatus</h5>
|
2020-02-14 00:19:15 +01:00
|
|
|
<i class="material-icons" id="state-icn" style="color:<?= $state_map[$state]->color ?>;font-size:16rem;">
|
|
|
|
<?= $state_map[$state]->svg ?>
|
|
|
|
</i>
|
2020-02-13 23:35:11 +01:00
|
|
|
<p class="card-text"><?= $state_map[$state]->state_string ?></p>
|
|
|
|
<a href="https://wiki.chaosdorf.de/Raumstatus" class="btn btn-block btn-lg btn-primary">What's this?</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="card" style="width: 18rem;">
|
|
|
|
<div class="card-body">
|
|
|
|
<h5 class="card-title">Events</h5>
|
|
|
|
<h6 class="card-subtitle mb-2 text-muted">Nächste Veranstaltung</h6>
|
|
|
|
<p class="card-text">
|
|
|
|
<h5 class="font-weight-bold"><?= $first_event->summary ?></h5>
|
|
|
|
<span class="font-weight-normal"><?= $ical->iCalDateToDateTime($first_event->dtstart_array[3])->format('Y-m-d H:i'); ?></span>
|
|
|
|
</p>
|
|
|
|
<h5 class="card-title">Danach:</h5>
|
|
|
|
<table class="table">
|
|
|
|
<tbody>
|
|
|
|
<?php foreach ($events as $event) : ?>
|
|
|
|
<tr>
|
|
|
|
<th scope="row"><?= $ical->iCalDateToDateTime($event->dtstart_array[3])->format('Y-m-d H:i') ?></th>
|
|
|
|
<td><?= $event->summary ?></td>
|
|
|
|
</tr>
|
|
|
|
<?php endforeach ?>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<a href="https://wiki.chaosdorf.de/Chaosdorf_Wiki:Current_events" class="btn btn-block btn-lg btn-primary">Event-Kalender</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<footer class="page-footer font-small text-center">
|
2020-02-14 00:19:15 +01:00
|
|
|
<div>
|
|
|
|
Look at the code <a href="https://git.iwonder.name/iwonder/dorf.jetzt">here</a>
|
|
|
|
</div>
|
2020-02-13 23:35:11 +01:00
|
|
|
</footer>
|
|
|
|
<script src="assets/js/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
|
|
|
<script src="assets/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
|
|
|
|
</body>
|
|
|
|
</html>
|