put all events together in one vcalendar
authorAndrew Engelbrecht <andrew@fsf.org>
Fri, 18 Mar 2022 00:25:16 +0000 (20:25 -0400)
committerAndrew Engelbrecht <andrew@fsf.org>
Fri, 18 Mar 2022 00:25:16 +0000 (20:25 -0400)
generate-ics

index 5df2f794e39c19fdfbc1844300140f25702332f2..2118824c48d51a2dea3c965282edf7771f40e3cf 100755 (executable)
@@ -9,10 +9,19 @@
 //
 // "Saturday","10:00 - 10:15 EDT - Welcome address","Welcome Address by FSF","Jupiter","LibrePlanet special sessions","LibrePlanet  2022","","","http://libreplanet.org/2022/speakers/#5910"
 
+
 include 'ICS.php';
 
 $csv = array_map('str_getcsv', explode("\n", stream_get_contents(STDIN)));
 
+// print out header for vcalendar
+?>BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//FSF//lp-csv-to-ics//EN
+CALSCALE:GREGORIAN
+NAME:LibrePlanet 2022
+<?php
+
 foreach ($csv as $linenum => $line) {
 
     if (count($line) <= 1) {
@@ -54,8 +63,13 @@ foreach ($csv as $linenum => $line) {
         'url' => str_replace("http:", "https:", $line[8]),
     ));
 
-    echo $ics->to_string();
-
-    echo "\n\n";
+    // print the trimmed event string
+    $trimmed_event = array();
+    preg_match("/.*(BEGIN:VEVENT.*END:VEVENT).*/ms", $ics->to_string(), $trimmed_event);
+    echo $trimmed_event[1];
+    echo "\n";
 }
 
+// print out footer for vcalendar
+echo "END:VCALENDAR\r\n";
+