Added caching function

master
Tezza 2015-02-26 23:10:22 +01:00
parent 6154121d30
commit b53dae6b6a
4 changed files with 27 additions and 8 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
vendor
src/app/config.json
bootstrap-theme*
bootstrap-theme*
src/web/cache/*

View File

@ -24,4 +24,13 @@
}
static public function saveFile ( $data, $destination ) {
file_put_contents(
$destination,
$data
);
}
}

View File

@ -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 ) {

View File

@ -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;
}