Skip to content

Commit

Permalink
Add webhook to update elec club website
Browse files Browse the repository at this point in the history
  • Loading branch information
udiboy1209 committed Mar 19, 2016
1 parent 37a4563 commit 29cba40
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 42 deletions.
46 changes: 6 additions & 40 deletions app/controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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")
{
Expand Down
7 changes: 5 additions & 2 deletions app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -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'));
Expand Down
9 changes: 9 additions & 0 deletions ecupdate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

git clone --depth 1 --branch master git://github.com/elec-club-iitb/website _tmp_elec_site

cd _tmp_elec_site
bundle exec jekyll build -d ../public/electronics-club/
cd ..

rm -rf _tmp_elec_site

0 comments on commit 29cba40

Please sign in to comment.