Blog und Events sind jetzt getrennt, Blog ist

soweit funktionell und README wurde aktualisiert.
This commit is contained in:
xoy 2023-05-06 16:34:12 +02:00
parent 5dd4e6ad65
commit 1944320a50
14 changed files with 131 additions and 56 deletions

View File

@ -22,20 +22,22 @@
Datei im Eventverzeichnis Anlegen: *YYYY-MM-DD.html* Datei im Eventverzeichnis Anlegen: *YYYY-MM-DD.html*
``` ```
title: Event Titel Blogpost Titel
date: Event Datum Blogpost Beschreibung
desc: Event Beschreibung Blogpost Datum
Blogpost Autor
------------------------ ------------------------
#Content below here! # Content below here!
``` ```
Strukturierung: Strukturierung:
- Header - Header
``` ```
title: Event Titel Blogpost Titel
date: Event Datum Blogpost Beschreibung
desc: Event Beschreibung Blogpost Datum
Blogpost Autor
``` ```
- Trenner zwischen Header und Content - 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. Bilder für Posts kommen in das Verzeichnis */images/posts/*
Neue Bilder kommen in das Verzeichnis */images/*
[Event Dokumentation](https://git.ctdo.de/xoy/ctdo.de/src/branch/master/EVENT.MD) [Event Dokumentation](https://git.ctdo.de/xoy/ctdo.de/src/branch/master/EVENT.MD)

4
css/event.css Normal file
View File

@ -0,0 +1,4 @@
img {
display: block;
margin: auto;
}

View File

@ -16,7 +16,17 @@ div.eventblock a:hover {
} }
div.eventblock h3 { div.eventblock h3 {
right: 10px; margin: 0;
top: 0; }
position: absolute;
div.eventblock h3.a {
text-align: left;
width: 50%;
display: inline-block;
}
div.eventblock h3.b {
text-align: right;
width: 50%;
display: inline-block;
} }

View File

@ -183,7 +183,7 @@ a.green-text {
nav ul li { nav ul li {
display: block; display: block;
font-size: 200%; font-size: 200%;
padding: 20px 20px 20px 0; padding: 30px 100px 30px 0;
text-align: right; text-align: right;
} }

View File

@ -1,6 +0,0 @@
Weihnachten
Weihnachten halt.
------------------------
# Weihnachten
Ist halt Weihnachten.

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@ -30,8 +30,8 @@ $nextevents = $twig_templates->render('nextevents.html.twig');
$raumstatus_b = $util->raumstatus(); $raumstatus_b = $util->raumstatus();
$raumstatus = '<b>unbekannt</b>'; $raumstatus = '<b>unbekannt</b>';
$pages = array('index', 'about', 'treff', 'events', 'kontakt', 'support', 'verein'); $pages = array('index', 'about', 'treff', 'blog', 'events', 'kontakt', 'support', 'verein');
$page_names = array('index', 'über uns', 'zeiten & location', 'events', 'kontakt', 'support', 'verein'); $page_names = array('index', 'über uns', 'zeiten & location', 'blog', 'events', 'kontakt', 'support', 'verein');
$active_page = ''; $active_page = '';
@ -42,13 +42,26 @@ if(gettype($raumstatus_b) == "boolean") {
$raumstatus = $util->html_link('https://status.ctdo.de/', 'red-text', '<b>geschlossen</b>', TRUE); $raumstatus = $util->html_link('https://status.ctdo.de/', 'red-text', '<b>geschlossen</b>', TRUE);
} }
$topic = $util->get_next_topic();
switch ($topic->days) {
case 0:
$topic_output = '<p class="topic">Der nächste Topictreff findet heute statt!</p>';
break;
case 1:
$topic_output = '<p class="topic">Der nächste Topictreff findet morgen statt!</p>';
break;
default:
$topic_output = '<p class="topic">Der nächste Topictreff findet in '.$topic->days.' Tagen ['.$topic->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);
$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'); $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'); $head = $util->css_link('css/main.css').$util->css_link('css/home.css').$util->css_link('css/events.css');
break; break;
case 'about': case 'about':
@ -59,13 +72,22 @@ if(isset($_GET['page'])) {
$content = $twig_pages->render('treff.html.twig'); $content = $twig_pages->render('treff.html.twig');
$head = $util->css_link('css/main.css'); $head = $util->css_link('css/main.css');
break; break;
case 'events': case 'blog':
if(!isset($_GET['e'])) { if(!isset($_GET['id'])) {
$content = $twig_pages->render('events.html.twig', [ 'events' => $util->generate_event_list() ]); $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'); $head = $util->css_link('css/main.css').$util->css_link('css/events.css');
} else { } else {
$content = $converter->convert($util->get_event_content($_GET['e'])); $content = $converter->convert($util->get_post_content($_GET['id']));
$head = $util->css_link('css/main.css'); $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; break;
case 'kontakt': case 'kontakt':
@ -113,7 +135,7 @@ if(isset($_GET['page'])) {
} else { } else {
$active_page = 'index'; $active_page = 'index';
$title = $active_page; $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'); $head = $util->css_link('css/main.css').$util->css_link('css/home.css').$util->css_link('css/events.css');
} }

2
pages/blog.html.twig Normal file
View File

@ -0,0 +1,2 @@
<h1>Blog</h1>
{{ posts | raw }}

View File

@ -1,3 +1,3 @@
<h1>Events</h1> <h1>Events</h1>
!TOPICTREFF {{ topic | raw }}
{{ events | raw }} {{ events | raw }}

View File

@ -13,3 +13,5 @@
</p> </p>
<h2>Die nächsten Events</h2> <h2>Die nächsten Events</h2>
{{ topic | raw }}
{{ posts | raw }}

View File

@ -38,33 +38,47 @@ class Util {
return $string; return $string;
} }
function scan_for_events() { function scan_for_posts() {
$s = scandir('events/'); $s = scandir(__DIR__ . '/../posts/', SCANDIR_SORT_DESCENDING);
$output = array(); $output = array();
foreach ($s as $f) { foreach ($s as $f) {
if(count(str_split($f)) == 13) if(count(str_split($f)) >= 4)
$output[] = $f; $output[] = $f;
} }
return $output; return $output;
} }
function generate_event_list() { function generate_post_list($limit = -1) {
$events = $this->scan_for_events(); $events = $this->scan_for_posts();
$output = ""; $output = "";
foreach ($events as $event) { if ($limit == -1) {
$date = str_replace('.md', '', $event); foreach ($events as $event) {
$lines = file(__DIR__ . '/../events/' . $event); $lines = file(__DIR__ . '/../posts/' . $event);
$title = $lines[0]; $title = $lines[0];
$desc = $lines[1]; $desc = $lines[1];
$output .= '<div class="eventblock"><h3>'.$date.'</h3><a href="?page=events&e='.$date.'"><h2>'.$title.'</h2><p>'.$desc.'</p></a></div>'; $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', '', $event).'"><h2>'.$title.'</h2><p>'.$desc.'</p></a></div>';
}
} }
return $output; return $output;
} }
function get_event_content($date) { function get_post_content($id) {
$lines = file(__DIR__ . '/../events/' . $date . '.md'); $lines = file(__DIR__ . '/../posts/' . str_replace('.', '', $id) . '.md');
$output = ""; $output = "";
for ($i = 3; $i < count($lines); $i++) for ($i = 5; $i < count($lines); $i++)
$output .= $lines[$i] . "\n"; $output .= $lines[$i] . "\n";
return $output; return $output;
} }
@ -73,15 +87,14 @@ class Util {
$output = new stdClass(); $output = new stdClass();
$currentDate = new DateTime(); $currentDate = new DateTime();
// Find the next fourth Tuesday $next_topic = clone $currentDate;
$nextFourthTuesday = clone $currentDate; $next_topic->modify('second Tuesday of this month +1 week');
$nextFourthTuesday->modify('next Tuesday')->modify('next Tuesday')->modify('next Tuesday'); while ($next_topic->format('N') !== '2') {
while ($nextFourthTuesday->format('N') !== '2') { $next_topic->add(new DateInterval('P1D'));
$nextFourthTuesday->add(new DateInterval('P1D'));
} }
$output->days = $currentDate->diff($nextFourthTuesday)->days+1; $output->days = $currentDate->diff($next_topic)->days+1;
$output->date = $nextFourthTuesday->format('Y-m-d'); $output->date = $next_topic->format('Y-m-d');
return $output; return $output;
} }

14
posts/0.md Normal file
View File

@ -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!

14
posts/1.md Normal file
View File

@ -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!

View File

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