Added caching function
parent
6154121d30
commit
b53dae6b6a
|
@ -1,3 +1,4 @@
|
||||||
vendor
|
vendor
|
||||||
src/app/config.json
|
src/app/config.json
|
||||||
bootstrap-theme*
|
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 ) {
|
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 ) {
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
return $app['twig']->render(
|
return $app['twig']->render(
|
||||||
'level2.twig',
|
'level2.twig',
|
||||||
array(
|
array(
|
||||||
'page' => 'home',
|
'page' => 'home',
|
||||||
'level2' => Level2::getStatus( $app ),
|
'level2' => Level2::getStatus( $app ),
|
||||||
'events' => array_slice(
|
'events' => array_slice(
|
||||||
Level2::getEvents( $app ),
|
Level2::getEvents( $app ),
|
||||||
0,
|
0,
|
||||||
1
|
1
|
||||||
|
@ -33,9 +33,9 @@
|
||||||
return $app['twig']->render(
|
return $app['twig']->render(
|
||||||
'level2.twig',
|
'level2.twig',
|
||||||
array(
|
array(
|
||||||
'page' => 'events',
|
'page' => 'events',
|
||||||
'level2' => Level2::getStatus( $app ),
|
'level2' => Level2::getStatus( $app ),
|
||||||
'events' => array_slice(
|
'events' => array_slice(
|
||||||
Level2::getEvents( $app ),
|
Level2::getEvents( $app ),
|
||||||
0,
|
0,
|
||||||
10
|
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;
|
return $ctr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue