diff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.php index bf4ed310..825b70d8 100644 --- a/app/controllers/HomeController.php +++ b/app/controllers/HomeController.php @@ -81,48 +81,14 @@ public function aeromodelling_club($page="about") return View::make('club.aero.video'); else return View::make('club.aero.home'); } - public function electronics_club($page="about") + public function electronics_club($request) { - if($page=='about') - return View::make('club.elec.home'); - else if($page=='team'){ - $data = $this->update_script("Electronics Club"); - $managers = $data[0]; - $conveners = $data[1]; - $cl = 'elec'; - return View::make('club.club_team',compact('cl','managers','conveners')); - } - else if($page=='vision') - return View::make('club.elec.vision'); - else if($page=='event'){ + $sig_check = 'sha1=' . hash_hmac('sha1', $request->getContent(), $_ENV['GITHUB_ELEC_CLUB_SECRET']]); + if ($sig_check !== $request->header('x-hub-signature')) + return response(['error' => 'Unauthorized'], 401); - $file = fopen("https://docs.google.com/spreadsheets/d/1YiD_vHJwYnQYWU58DOJEBonDiWgXDvUM2GjtiDx5c1c/export?format=csv","r"); - // $events=array(); - while(!feof($file)){ - $csv = fgetcsv($file); - if($csv[0]!="Event Name"&&$csv[0]!=""){ - $csv[4]=$this->get_image_link($csv[4]); - $events[]=$csv; - } - } - - - return View::make('club.elec.event',compact('events')); - } - else if ($page=='gallery') { - - $pics=$this->get_images("elec"); - $cl='elec'; - return View::make('script_gallery',compact('cl','pics')); - } - else if ($page=='video') - return View::make('club.elec.video'); - else if($page=='line-follower-registration') - return View::make('club.elec.lf-register'); - else if($page=='club-initiatives') - return View::make('club.elec.club_initiative'); - else - return View::make('club.elec.home'); + exec("./ecupdate.sh"); + return response(['status' => 'OK'], 200); } public function krittika($page="about") { diff --git a/app/routes.php b/app/routes.php index 9e6eb4a4..b1fc36d1 100644 --- a/app/routes.php +++ b/app/routes.php @@ -98,7 +98,7 @@ Route::get('/',array('as'=>'stab.home' , 'uses'=>'HomeController@home')); // Clubs URLs Route::get('aeromodelling-club',array('as'=>'aeromodelling-club','uses'=>'HomeController@aeromodelling_club')); -Route::get('electronics-club',array('as'=>'electronics-club','uses'=>'HomeController@electronics_club')); +//Route::get('electronics-club',array('as'=>'electronics-club','uses'=>'HomeController@electronics_club')); Route::get('krittika',array('as'=>'krittika','uses'=>'HomeController@krittika')); Route::get('math-and-physics-club',array('as'=>'MnP','uses'=>'HomeController@MnP')); Route::get('robotics-club',array('as'=>'robotics-club','uses'=>'HomeController@robotics_club')); @@ -107,12 +107,15 @@ // Clubs Pages Route::get('aeromodelling-club/{page}','HomeController@aeromodelling_club'); -Route::get('electronics-club/{page}','HomeController@electronics_club'); +//Route::get('electronics-club/{page}','HomeController@electronics_club'); Route::get('krittika/{page}','HomeController@krittika'); Route::get('robotics-club/{page}','HomeController@robotics_club'); Route::get('math-and-physics-club/{page}','HomeController@MnP'); Route::get('wncc/{page}','HomeController@wncc'); +//Github Webhook update +Route::post('electronics-club/update','HomeController@electronics_club'); + //CLub Events // Route::get('electronics-club/event/CMOS-Design-Challenege-solution',array('as'=>'electronics-club.CMOS','uses'=>'EventController@elec_CMOS_Challenge_show')); // Route::get('electronics-club/event/CMOS-Design-Challenege-solution/all',array('as'=>'electronics-club.CMOS.all','uses'=>'EventController@elec_CMOS_Challenge_all')); diff --git a/ecupdate.sh b/ecupdate.sh new file mode 100755 index 00000000..935c16a1 --- /dev/null +++ b/ecupdate.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +git clone --depth 1 --branch master git://github.com/elec-club-iitb/elec-club-iitb.github.io _tmp_elec_site + +cd _tmp_elec_site +bundle exec jekyll build -d ../public/electronics-club/ +cd .. + +rm -rf _tmp_elec_site