Added caching function
parent
6154121d30
commit
b53dae6b6a
|
@ -1,3 +1,4 @@
|
|||
vendor
|
||||
src/app/config.json
|
||||
bootstrap-theme*
|
||||
src/web/cache/*
|
||||
|
|
|
@ -24,4 +24,13 @@
|
|||
|
||||
}
|
||||
|
||||
static public function saveFile ( $data, $destination ) {
|
||||
|
||||
file_put_contents(
|
||||
$destination,
|
||||
$data
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@
|
|||
|
||||
static public function getEvents ( $app ) {
|
||||
|
||||
$googleCalendar = self::getJSONCalendar( $app );
|
||||
$googleCalendar = Helpers::JSON2Array( $app[ 'cache' ][ 'calendar' ][ 'json' ] );
|
||||
|
||||
foreach( $googleCalendar[ 'items' ] as $googleEvent ) {
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
return $app['twig']->render(
|
||||
'level2.twig',
|
||||
array(
|
||||
'page' => 'home',
|
||||
'level2' => Level2::getStatus( $app ),
|
||||
'events' => array_slice(
|
||||
'page' => 'home',
|
||||
'level2' => Level2::getStatus( $app ),
|
||||
'events' => array_slice(
|
||||
Level2::getEvents( $app ),
|
||||
0,
|
||||
1
|
||||
|
@ -33,9 +33,9 @@
|
|||
return $app['twig']->render(
|
||||
'level2.twig',
|
||||
array(
|
||||
'page' => 'events',
|
||||
'level2' => Level2::getStatus( $app ),
|
||||
'events' => array_slice(
|
||||
'page' => 'events',
|
||||
'level2' => Level2::getStatus( $app ),
|
||||
'events' => array_slice(
|
||||
Level2::getEvents( $app ),
|
||||
0,
|
||||
10
|
||||
|
@ -45,6 +45,15 @@
|
|||
|
||||
});
|
||||
|
||||
$ctr->get('/scrape', function() use ( $app ) {
|
||||
|
||||
Helpers::saveFile ( json_encode( Level2::getJSONCalendar( $app ) ), 'cache/calendar.json' );
|
||||
Helpers::saveFile ( file_get_contents( $app[ 'google' ][ 'ical' ] ) , 'cache/calendar.ics' );
|
||||
|
||||
return true;
|
||||
|
||||
});
|
||||
|
||||
return $ctr;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue