extract number of slots from some iCal fields
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 2 Oct 2011 19:01:13 +0000 (21:01 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 2 Oct 2011 19:01:13 +0000 (21:01 +0200)
This allows us to store additional meta-data inside iCal using
human-readable format

angular-server.pl

index 44be86e..7cf3436 100755 (executable)
@@ -257,6 +257,18 @@ get '/reservations/get/(*url)' => sub {
                }
        }
 
+       @events = map {
+               foreach my $check_slot ( qw(
+                       LOCATION
+                       STATUS
+                       SUMMARY
+               )) {
+                       next unless exists $_->{$check_slot};
+                       $_->{slots} = $1 if $_->{$check_slot} =~ m/(\d+)\s*mjesta/s;
+               }
+               $_;
+       } @events;
+
        $ical->{events} = [ sort {
                                        $a->{DTSTART} cmp $b->{DTSTART}
        } @events ];