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

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
vendor vendor
src/app/config.json 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 ) { static public function getEvents ( $app ) {
$googleCalendar = self::getJSONCalendar( $app ); $googleCalendar = Helpers::JSON2Array( $app[ 'cache' ][ 'calendar' ][ 'json' ] );
foreach( $googleCalendar[ 'items' ] as $googleEvent ) { foreach( $googleCalendar[ 'items' ] as $googleEvent ) {

View File

@ -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; return $ctr;
} }