ChaosBrunch Termin eingebunden

This commit is contained in:
xoy 2023-05-16 13:40:03 +02:00
parent 11f5b6fa4f
commit d64e305b6b
5 changed files with 64 additions and 8 deletions

15
events/brunch.md Normal file
View File

@ -0,0 +1,15 @@
ChaosBrunch
Einmal in der Woche treffen wir uns regulär zum quatschen, basteln, frickeln, programmieren, hacken, kochen, essen, …
{{ brunchdatum }}
11:00 - 15:00
Chaostreff Dortmund e.V.
------------------------
# Treff
Alle zwei Wochen an einem Sonntag lädt der CTDO zum **Mitbring-Brunch** in seinen Räume im Kulturzentrum [„Langer August“](/?page=treff) ein!
Um **ca. 11 Uhr** geht es los, das Ende ist wie immer offen. Die Details dazu gibt es im [ctdo wiki](https://wiki.ctdo.de/events/hackerbrunch)!
Schaut einfach vorab im [MitbringPad](https://md.ctdo.de/brunch) rein und kündigt an was ihr auf den Tisch werft, alles kann, nichts muss!
Es sind sowohl alte als auch neue Menschen gerne gesehen! Bringt was zu futtern, euer aktuelles Projekt, beides oder einfach nur Neugierde mit!

View File

@ -58,7 +58,7 @@ switch ($topic->days) {
$treff = $util->get_next_treff(); $treff = $util->get_next_treff();
$trefflink = '<a href="/?page=events&id=treff">Treff</a>'; $trefflink = '<a href="/?page=events&id=treff">Treff</a>';
switch ($topic->days) { switch ($treff->days) {
case 0: case 0:
$treff_output = '<p class="topic">Der nächste '.$trefflink.' findet heute statt!</p>'; $treff_output = '<p class="topic">Der nächste '.$trefflink.' findet heute statt!</p>';
break; break;
@ -72,7 +72,7 @@ switch ($topic->days) {
$repaircafe = $util->get_next_repaircafe(); $repaircafe = $util->get_next_repaircafe();
$repaircafelink = '<a href="/?page=events&id=repaircafe">RepairCafe</a>'; $repaircafelink = '<a href="/?page=events&id=repaircafe">RepairCafe</a>';
switch ($topic->days) { switch ($repaircafe->days) {
case 0: case 0:
$repaircafe_output = '<p class="topic">Das nächste '.$repaircafelink.' findet heute statt!</p>'; $repaircafe_output = '<p class="topic">Das nächste '.$repaircafelink.' findet heute statt!</p>';
break; break;
@ -84,6 +84,20 @@ switch ($topic->days) {
break; break;
} }
$brunch = $util->get_next_brunch();
$brunchlink = '<a href="/?page=events&id=brunch">ChaosBrunch</a>';
switch ($brunch->days) {
case 0:
$brunch_output = '<p class="topic">Das nächste '.$brunchlink.' findet heute statt!</p>';
break;
case 1:
$brunch_output = '<p class="topic">Das nächste '.$brunchlink.' findet morgen statt!</p>';
break;
default:
$brunch_output = '<p class="topic">Das nächste '.$brunchlink.' findet in '.$brunch->days.' Tagen ['.$brunch->date.'] statt.</p>';
break;
}
if(isset($_GET['page'])) { if(isset($_GET['page'])) {
$page = $_GET['page']; $page = $_GET['page'];
$active_page = $util->str_mass_replace(array('adresse', 'irc', 'mail'), array('kontakt', 'kontakt', 'kontakt'), $page); $active_page = $util->str_mass_replace(array('adresse', 'irc', 'mail'), array('kontakt', 'kontakt', 'kontakt'), $page);
@ -112,10 +126,10 @@ if(isset($_GET['page'])) {
break; break;
case 'events': case 'events':
if(!isset($_GET['id'])) { if(!isset($_GET['id'])) {
$content = $twig_pages->render('events.html.twig', [ 'topic' => $topic_output, 'treff' => $treff_output, 'repaircafe' => $repaircafe_output, 'events' => $util->generate_event_list() ]); $content = $twig_pages->render('events.html.twig', [ 'topic' => $topic_output, 'treff' => $treff_output, 'repaircafe' => $repaircafe_output, 'brunch' => $brunch_output, 'events' => $util->generate_event_list() ]);
$head = $util->css_link('css/main.css').$util->css_link('css/events.css'); $head = $util->css_link('css/main.css').$util->css_link('css/events.css');
} else { } else {
$content = $util->str_mass_replace(array('{{ topicdatum }}', 'Chaostreff Dortmund e.V.', '{{ treffdatum }}', '{{ repaircafedatum }}'), array($util->get_next_topic()->date, $util->html_link('/?page=treff', '', 'Chaostreff Dortmund e.V.', FALSE), $util->get_next_treff()->date, $util->get_next_repaircafe()->date), $converter->convert($util->get_event_content($_GET['id']))); $content = $util->str_mass_replace(array('{{ topicdatum }}', 'Chaostreff Dortmund e.V.', '{{ treffdatum }}', '{{ repaircafedatum }}', '{{ brunchdatum }}'), array($util->get_next_topic()->date, $util->html_link('/?page=treff', '', 'Chaostreff Dortmund e.V.', FALSE), $util->get_next_treff()->date, $util->get_next_repaircafe()->date, $util->get_next_brunch()->date), $converter->convert($util->get_event_content($_GET['id'])));
$head = $util->css_link('css/main.css').$util->css_link('css/event.css'); $head = $util->css_link('css/main.css').$util->css_link('css/event.css');
} }
break; break;

View File

@ -2,4 +2,5 @@
{{ topic | raw }} {{ topic | raw }}
{{ treff | raw }} {{ treff | raw }}
{{ repaircafe | raw }} {{ repaircafe | raw }}
{{ brunch | raw }}
{{ events | raw }} {{ events | raw }}

View File

@ -90,7 +90,7 @@ class Util {
$s = scandir(__DIR__ . '/../events/', SCANDIR_SORT_DESCENDING); $s = scandir(__DIR__ . '/../events/', SCANDIR_SORT_DESCENDING);
$output = array(); $output = array();
foreach ($s as $f) { foreach ($s as $f) {
if(count(str_split($f)) >= 4 && $f != 'treff.md' && $f != 'topictreff.md' && $f != 'repaircafe.md') if(count(str_split($f)) >= 4 && $f != 'treff.md' && $f != 'topictreff.md' && $f != 'repaircafe.md' && $f != 'brunch.md')
$output[] = $f; $output[] = $f;
} }
return $output; return $output;
@ -162,7 +162,7 @@ class Util {
$diff = $now->diff(new DateTime()); $diff = $now->diff(new DateTime());
$days_until = $diff->format('%a'); $days_until = $diff->format('%a');
$output->days = $days_until; $output->days = $days_until+1;
$output->date = $now->format('Y-m-d'); $output->date = $now->format('Y-m-d');
// Return an array with the count and date of the next Friday // Return an array with the count and date of the next Friday
return $output; return $output;
@ -181,12 +181,38 @@ class Util {
$daysUntilLastThursday = $today->diff($lastThursday)->days; $daysUntilLastThursday = $today->diff($lastThursday)->days;
$output->days = $daysUntilLastThursday + 1; $output->days = $daysUntilLastThursday;
$output->date = $lastThursday->format('Y-m-d'); $output->date = $lastThursday->format('Y-m-d');
return $output; return $output;
} }
function get_next_brunch() {
$now = new DateTime();
if ($now->format('w') == 0) {
$nextSunday = clone $now;
} else {
$nextSunday = new DateTime('next Sunday');
}
$weekNumber = (int)$nextSunday->format('W');
$isEvenWeek = ($weekNumber % 2) == 0;
if ($isEvenWeek) {
$nextSunday->modify('+1 week');
}
$differenz = $nextSunday->diff($now);
$days = $differenz->days;
$output = new stdClass();
$output->date = $nextSunday->format('Y-m-d');
$output->days = $days+1;
return $output;
}
} }
?> ?>

View File

@ -4,4 +4,4 @@ require __DIR__ . '/php/util.php';
$u = new Util(); $u = new Util();
echo var_dump($u->get_next_repaircafe()); echo var_dump($u->get_next_brunch());