Compare commits
3 Commits
1bb33f20c1
...
1f9a136967
Author | SHA1 | Date |
---|---|---|
xoy | 1f9a136967 | |
xoy | aa3e7cadfd | |
xoy | 740c6c859b |
|
@ -4,7 +4,7 @@ Einmal in der Woche treffen wir uns regulär zum quatschen, basteln, frickeln, p
|
||||||
11:00 - 15:00
|
11:00 - 15:00
|
||||||
Chaostreff Dortmund e.V.
|
Chaostreff Dortmund e.V.
|
||||||
------------------------
|
------------------------
|
||||||
# Treff
|
# ChaosBrunch
|
||||||
|
|
||||||
Alle zwei Wochen an einem Sonntag lädt der CTDO zum **Mitbring-Brunch** in seinen Räume im Kulturzentrum [„Langer August“](/?page=treff) ein!
|
Alle zwei Wochen an einem Sonntag lädt der CTDO zum **Mitbring-Brunch** in seinen Räume im Kulturzentrum [„Langer August“](/?page=treff) ein!
|
||||||
|
|
||||||
|
|
145
index.php
145
index.php
|
@ -1,19 +1,20 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require __DIR__ . '/vendor/autoload.php';
|
require __DIR__ . '/vendor/autoload.php';
|
||||||
require __DIR__ . '/php/util.php';
|
|
||||||
|
|
||||||
use Twig\Environment;
|
use Twig\Environment;
|
||||||
use Twig\Loader\FilesystemLoader;
|
use Twig\Loader\FilesystemLoader;
|
||||||
use League\CommonMark\CommonMarkConverter;
|
use League\CommonMark\CommonMarkConverter;
|
||||||
|
|
||||||
|
require __DIR__ . '/php/util.php';
|
||||||
|
require __DIR__ . '/php/events.php';
|
||||||
|
require __DIR__ . '/php/posts.php';
|
||||||
|
|
||||||
$converter = new CommonMarkConverter([
|
$converter = new CommonMarkConverter([
|
||||||
'html_input' => 'strip',
|
'html_input' => 'strip',
|
||||||
'allow_unsafe_links' => false,
|
'allow_unsafe_links' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$util = new Util();
|
|
||||||
|
|
||||||
$pageloader = new FilesystemLoader(__DIR__ . '/pages');
|
$pageloader = new FilesystemLoader(__DIR__ . '/pages');
|
||||||
$templateloader = new FilesystemLoader(__DIR__ . '/templates');
|
$templateloader = new FilesystemLoader(__DIR__ . '/templates');
|
||||||
|
|
||||||
|
@ -22,12 +23,8 @@ $twig_templates = new Environment($templateloader);
|
||||||
|
|
||||||
$title = '';
|
$title = '';
|
||||||
$content = '';
|
$content = '';
|
||||||
$head = '';
|
|
||||||
|
|
||||||
$topictreff = $twig_templates->render('topictreff.html.twig');
|
$raumstatus_b = get_web_json('https://status.ctdo.de/api/simple/v2')["state"];
|
||||||
$nextevents = $twig_templates->render('nextevents.html.twig');
|
|
||||||
|
|
||||||
$raumstatus_b = $util->raumstatus();
|
|
||||||
$raumstatus = '<b>unbekannt</b>';
|
$raumstatus = '<b>unbekannt</b>';
|
||||||
|
|
||||||
$pages = array('index', 'about', 'treff', 'blog', 'events', 'kontakt', 'support', 'verein');
|
$pages = array('index', 'about', 'treff', 'blog', 'events', 'kontakt', 'support', 'verein');
|
||||||
|
@ -37,153 +34,99 @@ $active_page = '';
|
||||||
|
|
||||||
if(gettype($raumstatus_b) == "boolean") {
|
if(gettype($raumstatus_b) == "boolean") {
|
||||||
if($raumstatus_b)
|
if($raumstatus_b)
|
||||||
$raumstatus = $util->html_link('https://status.ctdo.de/', 'green-text', '<b>offen</b>', TRUE);
|
$raumstatus = html_link('https://status.ctdo.de/', 'green-text', '<b>offen</b>', TRUE);
|
||||||
else
|
else
|
||||||
$raumstatus = $util->html_link('https://status.ctdo.de/', 'red-text', '<b>geschlossen</b>', TRUE);
|
$raumstatus = html_link('https://status.ctdo.de/', 'red-text', '<b>geschlossen</b>', TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
$topic = $util->get_next_topic();
|
$topic = get_next_topic();
|
||||||
$topiclink = '<a href="/?page=events&id=topictreff">Topictreff</a>';
|
|
||||||
switch ($topic->days) {
|
|
||||||
case 0:
|
|
||||||
$topic_output = '<p class="topic">Der nächste '.$topiclink.' findet heute statt!</p>';
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
$topic_output = '<p class="topic">Der nächste '.$topiclink.' findet morgen statt!</p>';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$topic_output = '<p class="topic">Der nächste '.$topiclink.' findet in '.$topic->days.' Tagen ['.$topic->date.'] statt.</p>';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$treff = $util->get_next_treff();
|
$treff = get_next_treff();
|
||||||
$trefflink = '<a href="/?page=events&id=treff">Treff</a>';
|
|
||||||
switch ($treff->days) {
|
|
||||||
case 0:
|
|
||||||
$treff_output = '<p class="topic">Der nächste '.$trefflink.' findet heute statt!</p>';
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
$treff_output = '<p class="topic">Der nächste '.$trefflink.' findet morgen statt!</p>';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$treff_output = '<p class="topic">Der nächste '.$trefflink.' findet in '.$treff->days.' Tagen ['.$treff->date.'] statt.</p>';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$repaircafe = $util->get_next_repaircafe();
|
$repaircafe = get_next_repaircafe();
|
||||||
$repaircafelink = '<a href="/?page=events&id=repaircafe">RepairCafe</a>';
|
|
||||||
switch ($repaircafe->days) {
|
|
||||||
case 0:
|
|
||||||
$repaircafe_output = '<p class="topic">Das nächste '.$repaircafelink.' findet heute statt!</p>';
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
$repaircafe_output = '<p class="topic">Das nächste '.$repaircafelink.' findet morgen statt!</p>';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$repaircafe_output = '<p class="topic">Das nächste '.$repaircafelink.' findet in '.$repaircafe->days.' Tagen ['.$repaircafe->date.'] statt.</p>';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$brunch = $util->get_next_brunch();
|
$brunch = get_next_brunch();
|
||||||
$brunchlink = '<a href="/?page=events&id=brunch">ChaosBrunch</a>';
|
|
||||||
switch ($brunch->days) {
|
$css = ['main'];
|
||||||
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 = str_mass_replace(array('adresse', 'irc', 'mail'), array('kontakt', 'kontakt', 'kontakt'), $page);
|
||||||
$title = $page_names[array_search($active_page, $pages)];
|
$title = $page_names[array_search($active_page, $pages)];
|
||||||
switch ($page) {
|
switch ($page) {
|
||||||
case 'index':
|
case 'index':
|
||||||
$content = $twig_pages->render('index.html.twig', [ 'topic' => $topic_output, 'posts' => $util->generate_post_list(4) ]);
|
$content = $twig_pages->render('index.twig', [ 'topic' => $topic_output, 'posts' => generate_post_list(4) ]);
|
||||||
$head = $util->css_link('css/main.css').$util->css_link('css/home.css').$util->css_link('css/events.css');
|
$css[] = 'home';
|
||||||
|
$css[] = 'events';
|
||||||
break;
|
break;
|
||||||
case 'about':
|
case 'about':
|
||||||
$content = $twig_pages->render('about.html.twig');
|
$content = $twig_pages->render('about.twig');
|
||||||
$head = $util->css_link('css/main.css').$util->css_link('css/about.css');
|
$css[] = 'about';
|
||||||
break;
|
break;
|
||||||
case 'treff':
|
case 'treff':
|
||||||
$content = $twig_pages->render('treff.html.twig');
|
$content = $twig_pages->render('treff.twig');
|
||||||
$head = $util->css_link('css/main.css');
|
|
||||||
break;
|
break;
|
||||||
case 'blog':
|
case 'blog':
|
||||||
if(!isset($_GET['id'])) {
|
if(!isset($_GET['id'])) {
|
||||||
$content = $twig_pages->render('blog.html.twig', [ 'posts' => $util->generate_post_list() ]);
|
$content = $twig_pages->render('blog.twig', [ 'posts' => generate_post_list() ]);
|
||||||
$head = $util->css_link('css/main.css').$util->css_link('css/events.css');
|
$css[] = 'events';
|
||||||
} else {
|
} else {
|
||||||
$content = $converter->convert($util->get_post_content($_GET['id']));
|
$content = $converter->convert(get_post_content($_GET['id']));
|
||||||
$head = $util->css_link('css/main.css').$util->css_link('css/event.css');
|
$css[] = 'event';
|
||||||
}
|
}
|
||||||
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, 'brunch' => $brunch_output, 'events' => $util->generate_event_list() ]);
|
$content = $twig_pages->render('events.twig', [ 'topic' => $topic, 'treff' => $treff, 'repaircafe' => $repaircafe, 'brunch' => $brunch, 'events' => generate_event_list() ]);
|
||||||
$head = $util->css_link('css/main.css').$util->css_link('css/events.css');
|
$css[] = 'events';
|
||||||
} else {
|
} else {
|
||||||
$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'])));
|
$content = str_mass_replace(array('{{ topicdatum }}', 'Chaostreff Dortmund e.V.', '{{ treffdatum }}', '{{ repaircafedatum }}', '{{ brunchdatum }}'), array(get_next_topic()->date, html_link('/?page=treff', '', 'Chaostreff Dortmund e.V.', FALSE), get_next_treff()->date, get_next_repaircafe()->date, get_next_brunch()->date), $converter->convert(get_event_content($_GET['id'])));
|
||||||
$head = $util->css_link('css/main.css').$util->css_link('css/event.css');
|
$css[] = 'event';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'kontakt':
|
case 'kontakt':
|
||||||
$content = $twig_pages->render('kontakt.html.twig');
|
$content = $twig_pages->render('kontakt.twig');
|
||||||
$head = $util->css_link('css/main.css').$util->css_link('css/kontakt.css');
|
$css[] = 'kontakt';
|
||||||
break;
|
break;
|
||||||
case 'adresse':
|
case 'adresse':
|
||||||
$content = $twig_pages->render('kontakt/adresse.html.twig');
|
$content = $twig_pages->render('kontakt/adresse.twig');
|
||||||
$head = $util->css_link('css/main.css');
|
|
||||||
break;
|
break;
|
||||||
case 'irc':
|
case 'irc':
|
||||||
$content = $twig_pages->render('kontakt/irc.html.twig');
|
$content = $twig_pages->render('kontakt/irc.twig');
|
||||||
$head = $util->css_link('css/main.css');
|
|
||||||
break;
|
break;
|
||||||
case 'mail':
|
case 'mail':
|
||||||
$content = $twig_pages->render('kontakt/mail.html.twig');
|
$content = $twig_pages->render('kontakt/mail.twig');
|
||||||
$head = $util->css_link('css/main.css');
|
|
||||||
break;
|
break;
|
||||||
case 'tel':
|
case 'tel':
|
||||||
$content = $twig_pages->render('kontakt/tel.html.twig');
|
$content = $twig_pages->render('kontakt/tel.twig');
|
||||||
$head = $util->css_link('css/main.css');
|
|
||||||
break;
|
break;
|
||||||
case 'support':
|
case 'support':
|
||||||
$content = $twig_pages->render('support.html.twig');
|
$content = $twig_pages->render('support.twig');
|
||||||
$head = $util->css_link('css/main.css');
|
|
||||||
break;
|
break;
|
||||||
case 'verein':
|
case 'verein':
|
||||||
$content = $twig_pages->render('verein.html.twig');
|
$content = $twig_pages->render('verein.twig');
|
||||||
$head = $util->css_link('css/main.css');
|
|
||||||
break;
|
break;
|
||||||
case 'impressum':
|
case 'impressum':
|
||||||
$title = 'impressum';
|
$title = 'impressum';
|
||||||
$content = $twig_pages->render('impressum.html.twig');
|
$content = $twig_pages->render('impressum.twig');
|
||||||
$head = $util->css_link('css/main.css');
|
|
||||||
break;
|
break;
|
||||||
case 'datenschutz':
|
case 'datenschutz':
|
||||||
$title = 'datenschutz';
|
$title = 'datenschutz';
|
||||||
$content = $twig_pages->render('datenschutz.html.twig');
|
$content = $twig_pages->render('datenschutz.twig');
|
||||||
$head = $util->css_link('css/main.css');
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$content = $twig_pages->render('404.html.twig', ['page' => $_GET['page']]);
|
$content = $twig_pages->render('404.twig', ['page' => $_GET['page']]);
|
||||||
$head = $util->css_link('css/main.css');
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$active_page = 'index';
|
$active_page = 'index';
|
||||||
$title = $active_page;
|
$title = $active_page;
|
||||||
$content = $twig_pages->render('index.html.twig', [ 'topic' => $topic_output, 'posts' => $util->generate_post_list(4) ]);
|
$content = $twig_pages->render('index.twig', [ 'posts' => generate_post_list(4) ]);
|
||||||
$head = $util->css_link('css/main.css').$util->css_link('css/home.css').$util->css_link('css/events.css');
|
$css[] = 'home';
|
||||||
|
$css[] = 'events';
|
||||||
}
|
}
|
||||||
|
|
||||||
$nav = $util->generate_nav($active_page, $pages, $page_names);
|
$nav = generate_nav($active_page, $pages, $page_names);
|
||||||
|
|
||||||
echo $twig_templates->render('html5struct.html.twig', ['title' => $title, 'head' => $head, 'nav' => $nav, 'raumstatus' => $raumstatus, 'main' => $content]);
|
echo $twig_templates->render('default.twig', ['title' => $title, 'css' => $css, 'nav' => $nav, 'raumstatus' => $raumstatus, 'main' => $content]);
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
<h1>Events</h1>
|
|
||||||
{{ topic | raw }}
|
|
||||||
{{ treff | raw }}
|
|
||||||
{{ repaircafe | raw }}
|
|
||||||
{{ brunch | raw }}
|
|
||||||
{{ events | raw }}
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<h1>Events</h1>
|
||||||
|
|
||||||
|
{% if topic.days == 0 %}
|
||||||
|
<p class="topic">Der nächste <a href="/?page=events&id=topictreff">Topictreff</a> findet heute [{{ topic.date }}] statt!</p>
|
||||||
|
{% elseif topic.days == 1 %}
|
||||||
|
<p class="topic">Der nächste <a href="/?page=events&id=topictreff">Topictreff</a> findet morgen [{{ topic.date }}] statt!</p>
|
||||||
|
{% else %}
|
||||||
|
<p class="topic">Der nächste <a href="/?page=events&id=topictreff">Topictreff</a> findet in {{ topic.days }} [{{ topic.date }}] statt!</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if treff.days == 0 %}
|
||||||
|
<p class="topic">Der nächste <a href="/?page=events&id=treff">Treff</a> findet heute [{{ treff.date }}] statt!</p>
|
||||||
|
{% elseif treff.days == 1 %}
|
||||||
|
<p class="topic">Der nächste <a href="/?page=events&id=treff">Treff</a> findet morgen [{{ treff.date }}] statt!</p>
|
||||||
|
{% else %}
|
||||||
|
<p class="topic">Der nächste <a href="/?page=events&id=treff">Treff</a> findet in {{ treff.days }} [{{ treff.date }}] statt!</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if repaircafe.days == 0 %}
|
||||||
|
<p class="topic">Das nächste <a href="/?page=events&id=repaircafe">RepairCafe</a> findet heute [{{ repaircafe.date }}] statt!</p>
|
||||||
|
{% elseif repaircafe.days == 1 %}
|
||||||
|
<p class="topic">Das nächste <a href="/?page=events&id=repaircafe">RepairCafe</a> findet morgen [{{ repaircafe.date }}] statt!</p>
|
||||||
|
{% else %}
|
||||||
|
<p class="topic">Das nächste <a href="/?page=events&id=repaircafe">RepairCafe</a> findet in {{ repaircafe.days }} [{{ repaircafe.date }}] statt!</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if brunch.days == 0 %}
|
||||||
|
<p class="topic">Der nächste <a href="/?page=events&id=brunch">Brunch</a> findet heute [{{ brunch.date }}] statt!</p>
|
||||||
|
{% elseif brunch.days == 1 %}
|
||||||
|
<p class="topic">Der nächste <a href="/?page=events&id=brunch">Brunch</a> findet morgen [{{ brunch.date }}] statt!</p>
|
||||||
|
{% else %}
|
||||||
|
<p class="topic">Der nächste <a href="/?page=events&id=brunch">Brunch</a> findet in {{ brunch.days }} [{{ brunch.date }}] statt!</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{{ events | raw }}
|
|
@ -0,0 +1,129 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
function scan_for_events() {
|
||||||
|
$s = scandir(__DIR__ . '/../events/', SCANDIR_SORT_DESCENDING);
|
||||||
|
$output = array();
|
||||||
|
foreach ($s as $f) {
|
||||||
|
if(count(str_split($f)) >= 4 && $f != 'treff.md' && $f != 'topictreff.md' && $f != 'repaircafe.md' && $f != 'brunch.md')
|
||||||
|
$output[] = $f;
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function generate_event_list($limit = -1) {
|
||||||
|
$events = scan_for_events();
|
||||||
|
$output = "";
|
||||||
|
if ($limit == -1) {
|
||||||
|
foreach ($events as $event) {
|
||||||
|
$lines = file(__DIR__ . '/../events/' . $event);
|
||||||
|
$title = $lines[0];
|
||||||
|
$desc = $lines[1];
|
||||||
|
$date = $lines[2];
|
||||||
|
$veranstaltungsort = $lines[4];
|
||||||
|
$output .= '<div class="eventblock"><a href="?page=events&id='.str_replace('.md', '', $event).'"><h3 class="a">'.$veranstaltungsort.'</h3><h3 class="b">'.$date.'</h3><h2>'.$title.'</h2><p>'.$desc.'</p></a></div>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if($limit > count($events))
|
||||||
|
$limit = count($events);
|
||||||
|
for ($i = 0; $i < $limit; $i++) {
|
||||||
|
$lines = file(__DIR__ . '/../events/' . $event);
|
||||||
|
$title = $lines[0];
|
||||||
|
$desc = $lines[1];
|
||||||
|
$date = $lines[2];
|
||||||
|
$veranstaltungsort = $lines[4];
|
||||||
|
$output .= '<div class="eventblock"><a href="?page=events&id='.str_replace('.md', '', $event).'"><h3 class="a">'.$veranstaltungsort.'</h3><h3 class="b">'.$date.'</h3><h2>'.$title.'</h2><p>'.$desc.'</p></a></div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_event_content($id) {
|
||||||
|
$lines = file(__DIR__ . '/../events/' . str_replace('.', '', $id) . '.md');
|
||||||
|
$output = "";
|
||||||
|
$output .= '## Datum/Zeit'."\n\n";
|
||||||
|
$output .= $lines[2]."\n".$lines[3]."\n\n## Veranstaltungsort\n\n".$lines[4]."\n\n";
|
||||||
|
for ($i = 6; $i < count($lines); $i++)
|
||||||
|
$output .= $lines[$i] . "\n";
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_next_topic() {
|
||||||
|
$output = new stdClass();
|
||||||
|
$currentDate = new DateTime();
|
||||||
|
|
||||||
|
$next_topic = clone $currentDate;
|
||||||
|
$next_topic->modify('second Tuesday of this month +1 week');
|
||||||
|
while ($next_topic->format('N') !== '2') {
|
||||||
|
$next_topic->add(new DateInterval('P1D'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->days = $currentDate->diff($next_topic)->days+1;
|
||||||
|
$output->date = $next_topic->format('Y-m-d');
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_next_treff() {
|
||||||
|
$output = new stdClass();
|
||||||
|
// Get current date and time
|
||||||
|
$now = new DateTime();
|
||||||
|
|
||||||
|
// Find the next Friday
|
||||||
|
$now->modify('next Friday');
|
||||||
|
|
||||||
|
// Calculate the number of days until the next Friday
|
||||||
|
$diff = $now->diff(new DateTime());
|
||||||
|
$days_until = $diff->format('%a');
|
||||||
|
|
||||||
|
$output->days = $days_until+1;
|
||||||
|
$output->date = $now->format('Y-m-d');
|
||||||
|
// Return an array with the count and date of the next Friday
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_next_repaircafe() {
|
||||||
|
$output = new stdClass();
|
||||||
|
$today = new DateTime();
|
||||||
|
$lastDayOfMonth = clone $today;
|
||||||
|
$lastDayOfMonth->modify('last day of this month');
|
||||||
|
$lastThursday = clone $lastDayOfMonth;
|
||||||
|
|
||||||
|
while ($lastThursday->format('w') != 4) { // Thursday is represented by 4 (0-6, where 0 is Sunday)
|
||||||
|
$lastThursday->modify('-1 day');
|
||||||
|
}
|
||||||
|
|
||||||
|
$daysUntilLastThursday = $today->diff($lastThursday)->days;
|
||||||
|
|
||||||
|
$output->days = $daysUntilLastThursday;
|
||||||
|
$output->date = $lastThursday->format('Y-m-d');
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
function scan_for_posts() {
|
||||||
|
$s = scandir(__DIR__ . '/../posts/', SCANDIR_SORT_DESCENDING);
|
||||||
|
$output = array();
|
||||||
|
foreach ($s as $f) {
|
||||||
|
if(count(str_split($f)) >= 4)
|
||||||
|
$output[] = $f;
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function generate_post_list($limit = -1) {
|
||||||
|
$events = scan_for_posts();
|
||||||
|
$output = "";
|
||||||
|
if ($limit == -1) {
|
||||||
|
foreach ($events as $event) {
|
||||||
|
$lines = file(__DIR__ . '/../posts/' . $event);
|
||||||
|
$title = $lines[0];
|
||||||
|
$desc = $lines[1];
|
||||||
|
$date = $lines[2];
|
||||||
|
$signatur = $lines[3];
|
||||||
|
$output .= '<div class="eventblock"><h3>'.$signatur.'<br>'.$date.'</h3><a href="?page=blog&id='.str_replace('.md', '', $event).'"><h2>'.$title.'</h2><p>'.$desc.'</p></a></div>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if($limit > count($events))
|
||||||
|
$limit = count($events);
|
||||||
|
for ($i = 0; $i < $limit; $i++) {
|
||||||
|
$lines = file(__DIR__ . '/../posts/' . $events[$i]);
|
||||||
|
$title = $lines[0];
|
||||||
|
$desc = $lines[1];
|
||||||
|
$date = $lines[2];
|
||||||
|
$signatur = $lines[3];
|
||||||
|
$output .= '<div class="eventblock"><h3 class="a">'.$signatur.'</h3><h3 class="b">'.$date.'</h3><a href="?page=blog&id='.str_replace('.md', '', $events[$i]).'"><h2>'.$title.'</h2><p>'.$desc.'</p></a></div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_post_content($id) {
|
||||||
|
$lines = file(__DIR__ . '/../posts/' . str_replace('.', '', $id) . '.md');
|
||||||
|
$output = "";
|
||||||
|
for ($i = 5; $i < count($lines); $i++)
|
||||||
|
$output .= $lines[$i] . "\n";
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
206
php/util.php
206
php/util.php
|
@ -1,218 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Util {
|
function css_link($src) {
|
||||||
function css_link($src) {
|
|
||||||
return '<link rel="stylesheet" href="'.$src.'">';
|
return '<link rel="stylesheet" href="'.$src.'">';
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate_nav($active_page, $pages, $page_names) {
|
function generate_nav($active_page, $pages, $page_names) {
|
||||||
$output = '<nav><ul>';
|
$output = array();
|
||||||
foreach ($pages as $key => $page) {
|
foreach ($pages as $key => $page) {
|
||||||
if ($page == $active_page)
|
if ($page == $active_page)
|
||||||
$output .= '<li>'.$this->html_link('/?page='.$page, 'active', $page_names[$key], FALSE).'</li>';
|
$output[] = ['page' => $page, 'name' => $page_names[$key], 'active' => TRUE];
|
||||||
else
|
else
|
||||||
$output .= '<li>'.$this->html_link('/?page='.$page, '', $page_names[$key], FALSE).'</li>';
|
$output[] = ['page' => $page, 'name' => $page_names[$key], 'active' => FALSE];
|
||||||
}
|
}
|
||||||
$output .= '</ul></nav>';
|
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
function html_link($href, $class, $innerHTML, $blank) {
|
function html_link($href, $class, $innerHTML, $blank) {
|
||||||
if($blank)
|
if($blank)
|
||||||
return '<a href="'.$href.'" class="'.$class.'" target="_blank">'.$innerHTML.'</a>';
|
return '<a href="'.$href.'" class="'.$class.'" target="_blank">'.$innerHTML.'</a>';
|
||||||
else
|
else
|
||||||
return '<a href="'.$href.'" class="'.$class.'">'.$innerHTML.'</a>';
|
return '<a href="'.$href.'" class="'.$class.'">'.$innerHTML.'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function raumstatus() {
|
function get_web_json($url) {
|
||||||
$url = 'https://status.ctdo.de/api/simple/v2';
|
|
||||||
$data = json_decode(file_get_contents($url), true);
|
$data = json_decode(file_get_contents($url), true);
|
||||||
return $data['state'];
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
function str_mass_replace($searchs, $replacers, $string) {
|
function str_mass_replace($searchs, $replacers, $string) {
|
||||||
foreach ($searchs as $key => $search) {
|
foreach ($searchs as $key => $search) {
|
||||||
$string = str_replace($search, $replacers[$key], $string);
|
$string = str_replace($search, $replacers[$key], $string);
|
||||||
}
|
}
|
||||||
return $string;
|
return $string;
|
||||||
}
|
|
||||||
|
|
||||||
//Posts
|
|
||||||
function scan_for_posts() {
|
|
||||||
$s = scandir(__DIR__ . '/../posts/', SCANDIR_SORT_DESCENDING);
|
|
||||||
$output = array();
|
|
||||||
foreach ($s as $f) {
|
|
||||||
if(count(str_split($f)) >= 4)
|
|
||||||
$output[] = $f;
|
|
||||||
}
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
function generate_post_list($limit = -1) {
|
|
||||||
$events = $this->scan_for_posts();
|
|
||||||
$output = "";
|
|
||||||
if ($limit == -1) {
|
|
||||||
foreach ($events as $event) {
|
|
||||||
$lines = file(__DIR__ . '/../posts/' . $event);
|
|
||||||
$title = $lines[0];
|
|
||||||
$desc = $lines[1];
|
|
||||||
$date = $lines[2];
|
|
||||||
$signatur = $lines[3];
|
|
||||||
$output .= '<div class="eventblock"><h3>'.$signatur.'<br>'.$date.'</h3><a href="?page=blog&id='.str_replace('.md', '', $event).'"><h2>'.$title.'</h2><p>'.$desc.'</p></a></div>';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if($limit > count($events))
|
|
||||||
$limit = count($events);
|
|
||||||
for ($i = 0; $i < $limit; $i++) {
|
|
||||||
$lines = file(__DIR__ . '/../posts/' . $events[$i]);
|
|
||||||
$title = $lines[0];
|
|
||||||
$desc = $lines[1];
|
|
||||||
$date = $lines[2];
|
|
||||||
$signatur = $lines[3];
|
|
||||||
$output .= '<div class="eventblock"><h3 class="a">'.$signatur.'</h3><h3 class="b">'.$date.'</h3><a href="?page=blog&id='.str_replace('.md', '', $events[$i]).'"><h2>'.$title.'</h2><p>'.$desc.'</p></a></div>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_post_content($id) {
|
|
||||||
$lines = file(__DIR__ . '/../posts/' . str_replace('.', '', $id) . '.md');
|
|
||||||
$output = "";
|
|
||||||
for ($i = 5; $i < count($lines); $i++)
|
|
||||||
$output .= $lines[$i] . "\n";
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
//Posts end
|
|
||||||
|
|
||||||
//Events
|
|
||||||
function scan_for_events() {
|
|
||||||
$s = scandir(__DIR__ . '/../events/', SCANDIR_SORT_DESCENDING);
|
|
||||||
$output = array();
|
|
||||||
foreach ($s as $f) {
|
|
||||||
if(count(str_split($f)) >= 4 && $f != 'treff.md' && $f != 'topictreff.md' && $f != 'repaircafe.md' && $f != 'brunch.md')
|
|
||||||
$output[] = $f;
|
|
||||||
}
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
function generate_event_list($limit = -1) {
|
|
||||||
$events = $this->scan_for_events();
|
|
||||||
$output = "";
|
|
||||||
if ($limit == -1) {
|
|
||||||
foreach ($events as $event) {
|
|
||||||
$lines = file(__DIR__ . '/../events/' . $event);
|
|
||||||
$title = $lines[0];
|
|
||||||
$desc = $lines[1];
|
|
||||||
$date = $lines[2];
|
|
||||||
$veranstaltungsort = $lines[4];
|
|
||||||
$output .= '<div class="eventblock"><a href="?page=events&id='.str_replace('.md', '', $event).'"><h3 class="a">'.$veranstaltungsort.'</h3><h3 class="b">'.$date.'</h3><h2>'.$title.'</h2><p>'.$desc.'</p></a></div>';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if($limit > count($events))
|
|
||||||
$limit = count($events);
|
|
||||||
for ($i = 0; $i < $limit; $i++) {
|
|
||||||
$lines = file(__DIR__ . '/../events/' . $event);
|
|
||||||
$title = $lines[0];
|
|
||||||
$desc = $lines[1];
|
|
||||||
$date = $lines[2];
|
|
||||||
$veranstaltungsort = $lines[4];
|
|
||||||
$output .= '<div class="eventblock"><a href="?page=events&id='.str_replace('.md', '', $event).'"><h3 class="a">'.$veranstaltungsort.'</h3><h3 class="b">'.$date.'</h3><h2>'.$title.'</h2><p>'.$desc.'</p></a></div>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_event_content($id) {
|
|
||||||
$lines = file(__DIR__ . '/../events/' . str_replace('.', '', $id) . '.md');
|
|
||||||
$output = "";
|
|
||||||
$output .= '## Datum/Zeit'."\n\n";
|
|
||||||
$output .= $lines[2]."\n".$lines[3]."\n\n## Veranstaltungsort\n\n".$lines[4]."\n\n";
|
|
||||||
for ($i = 6; $i < count($lines); $i++)
|
|
||||||
$output .= $lines[$i] . "\n";
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
//Events end
|
|
||||||
|
|
||||||
function get_next_topic() {
|
|
||||||
$output = new stdClass();
|
|
||||||
$currentDate = new DateTime();
|
|
||||||
|
|
||||||
$next_topic = clone $currentDate;
|
|
||||||
$next_topic->modify('second Tuesday of this month +1 week');
|
|
||||||
while ($next_topic->format('N') !== '2') {
|
|
||||||
$next_topic->add(new DateInterval('P1D'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$output->days = $currentDate->diff($next_topic)->days;
|
|
||||||
$output->date = $next_topic->format('Y-m-d');
|
|
||||||
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_next_treff() {
|
|
||||||
$output = new stdClass();
|
|
||||||
// Get current date and time
|
|
||||||
$now = new DateTime();
|
|
||||||
|
|
||||||
// Find the next Friday
|
|
||||||
$now->modify('next Friday');
|
|
||||||
|
|
||||||
// Calculate the number of days until the next Friday
|
|
||||||
$diff = $now->diff(new DateTime());
|
|
||||||
$days_until = $diff->format('%a');
|
|
||||||
|
|
||||||
$output->days = $days_until+1;
|
|
||||||
$output->date = $now->format('Y-m-d');
|
|
||||||
// Return an array with the count and date of the next Friday
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_next_repaircafe() {
|
|
||||||
$output = new stdClass();
|
|
||||||
$today = new DateTime();
|
|
||||||
$lastDayOfMonth = clone $today;
|
|
||||||
$lastDayOfMonth->modify('last day of this month');
|
|
||||||
$lastThursday = clone $lastDayOfMonth;
|
|
||||||
|
|
||||||
while ($lastThursday->format('w') != 4) { // Thursday is represented by 4 (0-6, where 0 is Sunday)
|
|
||||||
$lastThursday->modify('-1 day');
|
|
||||||
}
|
|
||||||
|
|
||||||
$daysUntilLastThursday = $today->diff($lastThursday)->days;
|
|
||||||
|
|
||||||
$output->days = $daysUntilLastThursday;
|
|
||||||
$output->date = $lastThursday->format('Y-m-d');
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -7,14 +7,27 @@
|
||||||
|
|
||||||
<title>ctdo - {{ title }}</title>
|
<title>ctdo - {{ title }}</title>
|
||||||
|
|
||||||
{{ head | raw }}
|
{% for item in css %}
|
||||||
|
<link rel="stylesheet" href="/css/{{ item }}.css">
|
||||||
|
{% endfor %}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="newBanner"><a href="https://www.chaostreff-dortmund.de/rundgang/" target="_blank">Rundgang</a></div>
|
<div class="newBanner"><a href="https://www.chaostreff-dortmund.de/rundgang/" target="_blank">Rundgang</a></div>
|
||||||
|
|
||||||
<header>
|
<header>
|
||||||
<img src="/images/logo_ctdo.svg" alt="ctdo logo">
|
<nav>
|
||||||
{{ nav | raw }}
|
<ul>
|
||||||
|
{% for item in nav %}
|
||||||
|
<li>
|
||||||
|
{% if item.active %}
|
||||||
|
<a href="?page={{ item.page }}" class="active">{{ item.name }}</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="?page={{ item.page }}">{{ item.name }}</a>
|
||||||
|
{% endif %}
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main>
|
<main>
|
|
@ -1 +0,0 @@
|
||||||
nextevents
|
|
|
@ -1 +0,0 @@
|
||||||
topictreff
|
|
Loading…
Reference in New Issue