diff --git a/README.MD b/README.MD index dfe7709..5545ce2 100644 --- a/README.MD +++ b/README.MD @@ -22,20 +22,22 @@ Datei im Eventverzeichnis Anlegen: *YYYY-MM-DD.html* ``` -title: Event Titel -date: Event Datum -desc: Event Beschreibung +Blogpost Titel +Blogpost Beschreibung +Blogpost Datum +Blogpost Autor ------------------------ -#Content below here! +# Content below here! ``` Strukturierung: - Header ``` -title: Event Titel -date: Event Datum -desc: Event Beschreibung +Blogpost Titel +Blogpost Beschreibung +Blogpost Datum +Blogpost Autor ``` - Trenner zwischen Header und Content @@ -43,15 +45,13 @@ desc: Event Beschreibung ------------------------ ``` -- Kommentar +- Content ``` -#Content below here! +# Content below here! ``` -Unter dem Trenner kann HTML verwendet werden. +Unter dem Trenner kann Markdown verwendet werden. -Eigenes CSS kann in der Datei *events_custom.css* hinzugefügt werden. - -Neue Bilder kommen in das Verzeichnis */images/* +Bilder für Posts kommen in das Verzeichnis */images/posts/* [Event Dokumentation](https://git.ctdo.de/xoy/ctdo.de/src/branch/master/EVENT.MD) \ No newline at end of file diff --git a/css/event.css b/css/event.css new file mode 100644 index 0000000..27452e9 --- /dev/null +++ b/css/event.css @@ -0,0 +1,4 @@ +img { + display: block; + margin: auto; +} \ No newline at end of file diff --git a/css/events.css b/css/events.css index 78fe957..852d59f 100644 --- a/css/events.css +++ b/css/events.css @@ -16,7 +16,17 @@ div.eventblock a:hover { } div.eventblock h3 { - right: 10px; - top: 0; - position: absolute; + margin: 0; +} + +div.eventblock h3.a { + text-align: left; + width: 50%; + display: inline-block; +} + +div.eventblock h3.b { + text-align: right; + width: 50%; + display: inline-block; } \ No newline at end of file diff --git a/css/main.css b/css/main.css index 8751df7..b82cad1 100644 --- a/css/main.css +++ b/css/main.css @@ -183,7 +183,7 @@ a.green-text { nav ul li { display: block; font-size: 200%; - padding: 20px 20px 20px 0; + padding: 30px 100px 30px 0; text-align: right; } diff --git a/events/2023-12-24.md b/events/2023-12-24.md deleted file mode 100644 index 69034c7..0000000 --- a/events/2023-12-24.md +++ /dev/null @@ -1,6 +0,0 @@ -Weihnachten -Weihnachten halt. ------------------------- -# Weihnachten - -Ist halt Weihnachten. \ No newline at end of file diff --git a/images/posts/DORTBUNT.nebenan_Banner-fuer-Anmeldende-768x154.png b/images/posts/DORTBUNT.nebenan_Banner-fuer-Anmeldende-768x154.png new file mode 100644 index 0000000..cbeb604 Binary files /dev/null and b/images/posts/DORTBUNT.nebenan_Banner-fuer-Anmeldende-768x154.png differ diff --git a/index.php b/index.php index 2ffdca4..58f5d75 100644 --- a/index.php +++ b/index.php @@ -30,8 +30,8 @@ $nextevents = $twig_templates->render('nextevents.html.twig'); $raumstatus_b = $util->raumstatus(); $raumstatus = 'unbekannt'; -$pages = array('index', 'about', 'treff', 'events', 'kontakt', 'support', 'verein'); -$page_names = array('index', 'über uns', 'zeiten & location', 'events', 'kontakt', 'support', 'verein'); +$pages = array('index', 'about', 'treff', 'blog', 'events', 'kontakt', 'support', 'verein'); +$page_names = array('index', 'über uns', 'zeiten & location', 'blog', 'events', 'kontakt', 'support', 'verein'); $active_page = ''; @@ -42,13 +42,26 @@ if(gettype($raumstatus_b) == "boolean") { $raumstatus = $util->html_link('https://status.ctdo.de/', 'red-text', 'geschlossen', TRUE); } +$topic = $util->get_next_topic(); +switch ($topic->days) { + case 0: + $topic_output = '

Der nächste Topictreff findet heute statt!

'; + break; + case 1: + $topic_output = '

Der nächste Topictreff findet morgen statt!

'; + break; + default: + $topic_output = '

Der nächste Topictreff findet in '.$topic->days.' Tagen ['.$topic->date.'] statt.

'; + break; +} + if(isset($_GET['page'])) { $page = $_GET['page']; $active_page = $util->str_mass_replace(array('adresse', 'irc', 'mail'), array('kontakt', 'kontakt', 'kontakt'), $page); $title = $page_names[array_search($active_page, $pages)]; switch ($page) { case 'index': - $content = $twig_pages->render('index.html.twig'); + $content = $twig_pages->render('index.html.twig', [ 'topic' => $topic_output, 'posts' => $util->generate_post_list(4) ]); $head = $util->css_link('css/main.css').$util->css_link('css/home.css').$util->css_link('css/events.css'); break; case 'about': @@ -59,13 +72,22 @@ if(isset($_GET['page'])) { $content = $twig_pages->render('treff.html.twig'); $head = $util->css_link('css/main.css'); break; - case 'events': - if(!isset($_GET['e'])) { - $content = $twig_pages->render('events.html.twig', [ 'events' => $util->generate_event_list() ]); + case 'blog': + if(!isset($_GET['id'])) { + $content = $twig_pages->render('blog.html.twig', [ 'posts' => $util->generate_post_list() ]); $head = $util->css_link('css/main.css').$util->css_link('css/events.css'); } else { - $content = $converter->convert($util->get_event_content($_GET['e'])); - $head = $util->css_link('css/main.css'); + $content = $converter->convert($util->get_post_content($_GET['id'])); + $head = $util->css_link('css/main.css').$util->css_link('css/event.css'); + } + break; + case 'events': + if(!isset($_GET['e'])) { + $content = $twig_pages->render('events.html.twig', [ 'topic' => $topic_output, 'events' => $util->generate_post_list() ]); + $head = $util->css_link('css/main.css').$util->css_link('css/events.css'); + } else { + $content = $converter->convert($util->get_post_content($_GET['e'])); + $head = $util->css_link('css/main.css').$util->css_link('css/event.css'); } break; case 'kontakt': @@ -113,7 +135,7 @@ if(isset($_GET['page'])) { } else { $active_page = 'index'; $title = $active_page; - $content = $twig_pages->render('index.html.twig'); + $content = $twig_pages->render('index.html.twig', [ 'topic' => $topic_output, 'posts' => $util->generate_post_list(4) ]); $head = $util->css_link('css/main.css').$util->css_link('css/home.css').$util->css_link('css/events.css'); } diff --git a/pages/blog.html.twig b/pages/blog.html.twig new file mode 100644 index 0000000..72d5716 --- /dev/null +++ b/pages/blog.html.twig @@ -0,0 +1,2 @@ +

Blog

+ {{ posts | raw }} \ No newline at end of file diff --git a/pages/events.html.twig b/pages/events.html.twig index a55f40e..c0a3f2c 100644 --- a/pages/events.html.twig +++ b/pages/events.html.twig @@ -1,3 +1,3 @@

Events

- !TOPICTREFF + {{ topic | raw }} {{ events | raw }} \ No newline at end of file diff --git a/pages/index.html.twig b/pages/index.html.twig index eb0a1a9..c26b6cb 100644 --- a/pages/index.html.twig +++ b/pages/index.html.twig @@ -12,4 +12,6 @@ Wenn du mehr über uns wissen möchtest, schau hier: über uns

-

Die nächsten Events

\ No newline at end of file +

Die nächsten Events

+ {{ topic | raw }} + {{ posts | raw }} \ No newline at end of file diff --git a/php/util.php b/php/util.php index 94a3c55..26ec256 100644 --- a/php/util.php +++ b/php/util.php @@ -38,33 +38,47 @@ class Util { return $string; } - function scan_for_events() { - $s = scandir('events/'); + function scan_for_posts() { + $s = scandir(__DIR__ . '/../posts/', SCANDIR_SORT_DESCENDING); $output = array(); foreach ($s as $f) { - if(count(str_split($f)) == 13) + if(count(str_split($f)) >= 4) $output[] = $f; } return $output; } - function generate_event_list() { - $events = $this->scan_for_events(); + function generate_post_list($limit = -1) { + $events = $this->scan_for_posts(); $output = ""; - foreach ($events as $event) { - $date = str_replace('.md', '', $event); - $lines = file(__DIR__ . '/../events/' . $event); - $title = $lines[0]; - $desc = $lines[1]; - $output .= '

'.$date.'

'.$title.'

'.$desc.'

'; + 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 .= '

'.$signatur.'
'.$date.'

'.$title.'

'.$desc.'

'; + } + } 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 .= '

'.$signatur.'

'.$date.'

'.$title.'

'.$desc.'

'; + } } return $output; } - function get_event_content($date) { - $lines = file(__DIR__ . '/../events/' . $date . '.md'); + function get_post_content($id) { + $lines = file(__DIR__ . '/../posts/' . str_replace('.', '', $id) . '.md'); $output = ""; - for ($i = 3; $i < count($lines); $i++) + for ($i = 5; $i < count($lines); $i++) $output .= $lines[$i] . "\n"; return $output; } @@ -73,15 +87,14 @@ class Util { $output = new stdClass(); $currentDate = new DateTime(); - // Find the next fourth Tuesday - $nextFourthTuesday = clone $currentDate; - $nextFourthTuesday->modify('next Tuesday')->modify('next Tuesday')->modify('next Tuesday'); - while ($nextFourthTuesday->format('N') !== '2') { - $nextFourthTuesday->add(new DateInterval('P1D')); + $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($nextFourthTuesday)->days+1; - $output->date = $nextFourthTuesday->format('Y-m-d'); + $output->days = $currentDate->diff($next_topic)->days+1; + $output->date = $next_topic->format('Y-m-d'); return $output; } diff --git a/posts/0.md b/posts/0.md new file mode 100644 index 0000000..d651a33 --- /dev/null +++ b/posts/0.md @@ -0,0 +1,14 @@ +ChaosBrunch am Sonntag, 02.04.2023 +Alle zwei Wochen an einem Sonntag lädt der CTDO zum Mitbring-Brunch in seinen Räume im Kulturzentrum „Langer August“ ein! +2023-05-01 +starcalc +------------------------ +# ChaosBrunch am Sonntag, 02.04.2023 + +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! \ No newline at end of file diff --git a/posts/1.md b/posts/1.md new file mode 100644 index 0000000..bd3aa63 --- /dev/null +++ b/posts/1.md @@ -0,0 +1,14 @@ +Bunt, Bunter, Chaostreff Dortmund +Wir öffnen unsere Türen und laden Euch herzlich in unseren Chaostreff im Langen August ein. +2023-05-02 +Fisch +------------------------ +# Bunt, Bunter, Chaostreff Dortmundchten + +![DORTBUND](/images/events/DORTBUNT.nebenan_Banner-fuer-Anmeldende-768x154.png) + +Wir öffnen unsere Türen und laden Euch herzlich in unseren Chaostreff im [Langen August](/?page=treff) ein. + +Am 5. und 6. Mai zwischen 14 und 20 Uhr könnt ihr einfach vorbeikommen und erhaltet einen Einblick in unseren Space, unsere Vereinsräume mitsamt allen Werkstätten. Um das ganze netter zu gestalten, gibt es kalte Getränke, Waffeln und auch der Grill wird angemacht. + +Wir freuen uns auf Euch, egal ob jung, alt, groß, klein, laut oder leise. Hauptsache bunt! \ No newline at end of file diff --git a/tester.php b/tester.php index 44b5567..70aa55f 100644 --- a/tester.php +++ b/tester.php @@ -4,4 +4,4 @@ require __DIR__ . '/php/util.php'; $u = new Util(); -echo var_dump($u->get_next_topic()); \ No newline at end of file +echo var_dump($u->scan_for_posts()); \ No newline at end of file