This repository has been archived by the owner on Feb 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39a7541
commit 3400f8a
Showing
6 changed files
with
174 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a:3:{i:0;a:19:{s:5:"login";s:10:"samsonasik";s:2:"id";i:459648;s:10:"avatar_url";s:50:"https://avatars.githubusercontent.com/u/459648?v=3";s:11:"gravatar_id";s:0:"";s:3:"url";s:39:"https://api.github.com/users/samsonasik";s:8:"html_url";s:29:"https://github.com/samsonasik";s:13:"followers_url";s:49:"https://api.github.com/users/samsonasik/followers";s:13:"following_url";s:62:"https://api.github.com/users/samsonasik/following{/other_user}";s:9:"gists_url";s:55:"https://api.github.com/users/samsonasik/gists{/gist_id}";s:11:"starred_url";s:62:"https://api.github.com/users/samsonasik/starred{/owner}{/repo}";s:17:"subscriptions_url";s:53:"https://api.github.com/users/samsonasik/subscriptions";s:17:"organizations_url";s:44:"https://api.github.com/users/samsonasik/orgs";s:9:"repos_url";s:45:"https://api.github.com/users/samsonasik/repos";s:10:"events_url";s:56:"https://api.github.com/users/samsonasik/events{/privacy}";s:19:"received_events_url";s:55:"https://api.github.com/users/samsonasik/received_events";s:4:"type";s:4:"User";s:10:"site_admin";b:0;s:13:"contributions";i:168;s:9:"user_info";a:30:{s:5:"login";s:10:"samsonasik";s:2:"id";i:459648;s:10:"avatar_url";s:50:"https://avatars.githubusercontent.com/u/459648?v=3";s:11:"gravatar_id";s:0:"";s:3:"url";s:39:"https://api.github.com/users/samsonasik";s:8:"html_url";s:29:"https://github.com/samsonasik";s:13:"followers_url";s:49:"https://api.github.com/users/samsonasik/followers";s:13:"following_url";s:62:"https://api.github.com/users/samsonasik/following{/other_user}";s:9:"gists_url";s:55:"https://api.github.com/users/samsonasik/gists{/gist_id}";s:11:"starred_url";s:62:"https://api.github.com/users/samsonasik/starred{/owner}{/repo}";s:17:"subscriptions_url";s:53:"https://api.github.com/users/samsonasik/subscriptions";s:17:"organizations_url";s:44:"https://api.github.com/users/samsonasik/orgs";s:9:"repos_url";s:45:"https://api.github.com/users/samsonasik/repos";s:10:"events_url";s:56:"https://api.github.com/users/samsonasik/events{/privacy}";s:19:"received_events_url";s:55:"https://api.github.com/users/samsonasik/received_events";s:4:"type";s:4:"User";s:10:"site_admin";b:0;s:4:"name";s:18:"Abdul Malik Ikhsan";s:7:"company";s:19:"Sitrun Technologies";s:4:"blog";s:31:"http://samsonasik.wordpress.com";s:8:"location";s:7:"Bandung";s:5:"email";s:20:"samsonasik@gmail.com";s:8:"hireable";b:1;s:3:"bio";N;s:12:"public_repos";i:117;s:12:"public_gists";i:42;s:9:"followers";i:143;s:9:"following";i:54;s:10:"created_at";s:20:"2010-10-29T15:22:08Z";s:10:"updated_at";s:20:"2014-12-14T13:45:40Z";}}i:1;a:19:{s:5:"login";s:7:"acelaya";s:2:"id";i:2719332;s:10:"avatar_url";s:51:"https://avatars.githubusercontent.com/u/2719332?v=3";s:11:"gravatar_id";s:0:"";s:3:"url";s:36:"https://api.github.com/users/acelaya";s:8:"html_url";s:26:"https://github.com/acelaya";s:13:"followers_url";s:46:"https://api.github.com/users/acelaya/followers";s:13:"following_url";s:59:"https://api.github.com/users/acelaya/following{/other_user}";s:9:"gists_url";s:52:"https://api.github.com/users/acelaya/gists{/gist_id}";s:11:"starred_url";s:59:"https://api.github.com/users/acelaya/starred{/owner}{/repo}";s:17:"subscriptions_url";s:50:"https://api.github.com/users/acelaya/subscriptions";s:17:"organizations_url";s:41:"https://api.github.com/users/acelaya/orgs";s:9:"repos_url";s:42:"https://api.github.com/users/acelaya/repos";s:10:"events_url";s:53:"https://api.github.com/users/acelaya/events{/privacy}";s:19:"received_events_url";s:52:"https://api.github.com/users/acelaya/received_events";s:4:"type";s:4:"User";s:10:"site_admin";b:0;s:13:"contributions";i:35;s:9:"user_info";a:30:{s:5:"login";s:7:"acelaya";s:2:"id";i:2719332;s:10:"avatar_url";s:51:"https://avatars.githubusercontent.com/u/2719332?v=3";s:11:"gravatar_id";s:0:"";s:3:"url";s:36:"https://api.github.com/users/acelaya";s:8:"html_url";s:26:"https://github.com/acelaya";s:13:"followers_url";s:46:"https://api.github.com/users/acelaya/followers";s:13:"following_url";s:59:"https://api.github.com/users/acelaya/following{/other_user}";s:9:"gists_url";s:52:"https://api.github.com/users/acelaya/gists{/gist_id}";s:11:"starred_url";s:59:"https://api.github.com/users/acelaya/starred{/owner}{/repo}";s:17:"subscriptions_url";s:50:"https://api.github.com/users/acelaya/subscriptions";s:17:"organizations_url";s:41:"https://api.github.com/users/acelaya/orgs";s:9:"repos_url";s:42:"https://api.github.com/users/acelaya/repos";s:10:"events_url";s:53:"https://api.github.com/users/acelaya/events{/privacy}";s:19:"received_events_url";s:52:"https://api.github.com/users/acelaya/received_events";s:4:"type";s:4:"User";s:10:"site_admin";b:0;s:4:"name";s:16:"Alejandro Celaya";s:7:"company";s:20:"Wonnova gamification";s:4:"blog";s:30:"http://www.alejandrocelaya.com";s:8:"location";s:8:"Zaragoza";s:5:"email";s:0:"";s:8:"hireable";b:1;s:3:"bio";N;s:12:"public_repos";i:19;s:12:"public_gists";i:1;s:9:"followers";i:21;s:9:"following";i:36;s:10:"created_at";s:20:"2012-11-04T09:37:53Z";s:10:"updated_at";s:20:"2014-12-14T12:34:07Z";}}i:2;a:19:{s:5:"login";s:12:"mockiemockiz";s:2:"id";i:1708946;s:10:"avatar_url";s:51:"https://avatars.githubusercontent.com/u/1708946?v=3";s:11:"gravatar_id";s:0:"";s:3:"url";s:41:"https://api.github.com/users/mockiemockiz";s:8:"html_url";s:31:"https://github.com/mockiemockiz";s:13:"followers_url";s:51:"https://api.github.com/users/mockiemockiz/followers";s:13:"following_url";s:64:"https://api.github.com/users/mockiemockiz/following{/other_user}";s:9:"gists_url";s:57:"https://api.github.com/users/mockiemockiz/gists{/gist_id}";s:11:"starred_url";s:64:"https://api.github.com/users/mockiemockiz/starred{/owner}{/repo}";s:17:"subscriptions_url";s:55:"https://api.github.com/users/mockiemockiz/subscriptions";s:17:"organizations_url";s:46:"https://api.github.com/users/mockiemockiz/orgs";s:9:"repos_url";s:47:"https://api.github.com/users/mockiemockiz/repos";s:10:"events_url";s:58:"https://api.github.com/users/mockiemockiz/events{/privacy}";s:19:"received_events_url";s:57:"https://api.github.com/users/mockiemockiz/received_events";s:4:"type";s:4:"User";s:10:"site_admin";b:0;s:13:"contributions";i:33;s:9:"user_info";a:30:{s:5:"login";s:12:"mockiemockiz";s:2:"id";i:1708946;s:10:"avatar_url";s:51:"https://avatars.githubusercontent.com/u/1708946?v=3";s:11:"gravatar_id";s:0:"";s:3:"url";s:41:"https://api.github.com/users/mockiemockiz";s:8:"html_url";s:31:"https://github.com/mockiemockiz";s:13:"followers_url";s:51:"https://api.github.com/users/mockiemockiz/followers";s:13:"following_url";s:64:"https://api.github.com/users/mockiemockiz/following{/other_user}";s:9:"gists_url";s:57:"https://api.github.com/users/mockiemockiz/gists{/gist_id}";s:11:"starred_url";s:64:"https://api.github.com/users/mockiemockiz/starred{/owner}{/repo}";s:17:"subscriptions_url";s:55:"https://api.github.com/users/mockiemockiz/subscriptions";s:17:"organizations_url";s:46:"https://api.github.com/users/mockiemockiz/orgs";s:9:"repos_url";s:47:"https://api.github.com/users/mockiemockiz/repos";s:10:"events_url";s:58:"https://api.github.com/users/mockiemockiz/events{/privacy}";s:19:"received_events_url";s:57:"https://api.github.com/users/mockiemockiz/received_events";s:4:"type";s:4:"User";s:10:"site_admin";b:0;s:4:"name";s:13:"muhamad rifki";s:7:"company";s:0:"";s:4:"blog";s:10:"mockie.net";s:8:"location";s:9:"Indonesia";s:5:"email";s:25:"rifkimuhammad89@gmail.com";s:8:"hireable";b:1;s:3:"bio";N;s:12:"public_repos";i:6;s:12:"public_gists";i:19;s:9:"followers";i:3;s:9:"following";i:3;s:10:"created_at";s:20:"2012-05-05T16:33:57Z";s:10:"updated_at";s:20:"2014-12-08T16:18:53Z";}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
module/Application/src/Application/Controller/ConsoleController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<?php | ||
|
||
namespace Application\Controller; | ||
|
||
use Zend\Mvc\Controller\AbstractConsoleController; | ||
use Zend\Console\Adapter\AdapterInterface as Console; | ||
use Zend\Console\ColorInterface as Color; | ||
use Zend\Http\Client as HttpClient; | ||
|
||
/** | ||
* Console controller to get contributor list | ||
* inspired and some code copied from https://github.com/zendframework/zf-web/blob/master/module/Application/src/Application/Controller/ConsoleController.php | ||
*/ | ||
class ConsoleController extends AbstractConsoleController | ||
{ | ||
/** | ||
* @var Console | ||
*/ | ||
protected $console; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $config; | ||
|
||
/** | ||
* Construct console and config property | ||
*/ | ||
public function __construct(Console $console, array $config) | ||
{ | ||
$this->console = $console; | ||
$this->config = $config; | ||
} | ||
|
||
protected function reportError($width, $length, $message, $e = null) | ||
{ | ||
if (($length + 9) > $width) { | ||
$this->console->writeLine(''); | ||
$length = 0; | ||
} | ||
$spaces = $width - $length - 9; | ||
$this->console->writeLine(str_repeat('.', $spaces).'[ ERROR ]', Color::RED); | ||
$this->console->writeLine($message); | ||
if ($e) { | ||
$this->console->writeLine($e->getTraceAsString()); | ||
} | ||
} | ||
|
||
protected function reportSuccess($width, $length) | ||
{ | ||
if (($length + 8) > $width) { | ||
$this->console->writeLine(''); | ||
$length = 0; | ||
} | ||
$spaces = $width - $length - 8; | ||
$this->console->writeLine(str_repeat('.', $spaces).'[ DONE ]', Color::GREEN); | ||
} | ||
|
||
/** | ||
* route : get contributors | ||
*/ | ||
public function getcontributorsAction() | ||
{ | ||
$width = $this->console->getWidth(); | ||
$this->console->writeLine('Fetching GitHub Contributors', Color::GREEN); | ||
|
||
$client = new HttpClient(); | ||
$client->setAdapter('Zend\Http\Client\Adapter\Curl'); | ||
$client->setUri('https://api.github.com/repos/sitrunlab/LearnZF2/contributors'); | ||
|
||
$response = $client->send(); | ||
if (!$response->isSuccess()) { | ||
// report failure | ||
$message = $response->getStatusCode().': '.$response->getReasonPhrase(); | ||
$this->reportError($width, 0, $message); | ||
|
||
return; | ||
} | ||
|
||
$body = $response->getBody(); | ||
$contributors = json_decode($body, true); | ||
$total = count($contributors); | ||
|
||
foreach ($contributors as $i => $contributor) { | ||
$message = sprintf(' Processing %d/%d', $i, $total); | ||
$this->console->write($message); | ||
$client->setUri("https://api.github.com/users/{$contributor['login']}"); | ||
$response = $client->send(); | ||
if (!$response->isSuccess()) { | ||
// report failure | ||
$error = $response->getStatusCode().': '.$response->getReasonPhrase(); | ||
$this->reportError($width, strlen($message), $error); | ||
} | ||
$body = $response->getBody(); | ||
$userInfo = json_decode($body, 1); | ||
$contributors[$i]['user_info'] = $userInfo; | ||
$this->reportSuccess($width, strlen($message)); | ||
} | ||
|
||
$this->console->writeLine(str_repeat('-', $width)); | ||
$message = 'Writing file'; | ||
$this->console->write($message, Color::BLUE); | ||
$path = $this->config['console']['contributors']['output']; | ||
file_put_contents($path, serialize($contributors)); | ||
$this->reportSuccess($width, strlen($message)); | ||
$this->console->writeLine(sprintf('File written to %s', $path)); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
module/Application/src/Application/Factory/Controller/ConsoleControllerFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Application\Factory\Controller; | ||
|
||
use Application\Controller\ConsoleController; | ||
use Zend\ServiceManager\FactoryInterface; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
|
||
class ConsoleControllerFactory implements FactoryInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function createService(ServiceLocatorInterface $serviceLocator) | ||
{ | ||
$services = $serviceLocator->getServiceLocator(); | ||
|
||
return new ConsoleController( | ||
$services->get('Console'), | ||
$services->get('Config') | ||
); | ||
} | ||
} |
122 changes: 17 additions & 105 deletions
122
module/Application/view/application/contributors/index.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,120 +1,32 @@ | ||
<?php | ||
$contributors = unserialize(file_get_contents('./data/contributors/contributors.pson')); | ||
?> | ||
<div class="col-lg-9"> | ||
<h1>Thanks to :</h1> | ||
<ul class="row contributor-gallery"> | ||
<?php foreach ($contributors as $i => $contributor): ?> | ||
<li class="col-lg-3 col-md-2 col-sm-3 col-xs-4"> | ||
<img class="avatar" src="https://avatars1.githubusercontent.com/u/10071238?v=3&s=200" /> | ||
<img class="avatar" src="<?php echo $contributor['avatar_url'] ?>" /> | ||
<div class="icon-con "> | ||
<div class="github "> | ||
<a href=""> | ||
<img src="<?php echo $this->basePath('img/github.png') ?>" /> | ||
<a href="<?php echo $contributor['user_info']['html_url'] ?>"> | ||
github | ||
</a> | ||
</div> | ||
<?php if (isset($contributor['user_info']['blog'])): ?> | ||
<div class="blog "> | ||
<a href=""> | ||
<img src="<?php echo $this->basePath('img/link.png') ?>" /> | ||
</a> | ||
</div> | ||
</div> | ||
</li> | ||
<li class="col-lg-3 col-md-2 col-sm-3 col-xs-4"> | ||
<img class="avatar" src="https://avatars1.githubusercontent.com/u/10071238?v=3&s=200" /> | ||
<div class="icon-con "> | ||
<div class="github "> | ||
<a href=""> | ||
<img src="<?php echo $this->basePath('img/github.png') ?>" /> | ||
</a> | ||
</div> | ||
<div class="blog "> | ||
<a href=""> | ||
<img src="<?php echo $this->basePath('img/link.png') ?>" /> | ||
</a> | ||
</div> | ||
</div> | ||
</li> | ||
<li class="col-lg-3 col-md-2 col-sm-3 col-xs-4"> | ||
<img class="avatar" src="https://avatars1.githubusercontent.com/u/10071238?v=3&s=200" /> | ||
<div class="icon-con "> | ||
<div class="github "> | ||
<a href=""> | ||
<img src="<?php echo $this->basePath('img/github.png') ?>" /> | ||
</a> | ||
</div> | ||
<div class="blog "> | ||
<a href=""> | ||
<img src="<?php echo $this->basePath('img/link.png') ?>" /> | ||
</a> | ||
</div> | ||
</div> | ||
</li> | ||
<li class="col-lg-3 col-md-2 col-sm-3 col-xs-4"> | ||
<img class="avatar" src="https://avatars1.githubusercontent.com/u/10071238?v=3&s=200" /> | ||
<div class="icon-con "> | ||
<div class="github "> | ||
<a href=""> | ||
<img src="<?php echo $this->basePath('img/github.png') ?>" /> | ||
</a> | ||
</div> | ||
<div class="blog "> | ||
<a href=""> | ||
<img src="<?php echo $this->basePath('img/link.png') ?>" /> | ||
</a> | ||
</div> | ||
</div> | ||
</li> | ||
<li class="col-lg-3 col-md-2 col-sm-3 col-xs-4"> | ||
<img class="avatar" src="https://avatars1.githubusercontent.com/u/10071238?v=3&s=200" /> | ||
<div class="icon-con "> | ||
<div class="github "> | ||
<a href=""> | ||
<img src="<?php echo $this->basePath('img/github.png') ?>" /> | ||
</a> | ||
</div> | ||
<div class="blog "> | ||
<a href=""> | ||
<img src="<?php echo $this->basePath('img/link.png') ?>" /> | ||
</a> | ||
</div> | ||
</div> | ||
</li> | ||
<li class="col-lg-3 col-md-2 col-sm-3 col-xs-4"> | ||
<img class="avatar" src="<?php echo $this->basePath('img/link.png') ?>" /> | ||
<div class="icon-con "> | ||
<div class="blog "> | ||
<a href=""> | ||
<img src="<?php echo $this->basePath('img/link.png') ?>" /> | ||
</a> | ||
</div> | ||
</div> | ||
</li> | ||
<li class="col-lg-3 col-md-2 col-sm-3 col-xs-4"> | ||
<img class="avatar" src="<?php echo $this->basePath('img/github.png') ?>" /> | ||
<div class="icon-con "> | ||
<div class="blog "> | ||
<a href=""> | ||
<img src="<?php echo $this->basePath('img/link.png') ?>" /> | ||
</a> | ||
</div> | ||
</div> | ||
</li> | ||
<li class="col-lg-3 col-md-2 col-sm-3 col-xs-4"> | ||
<img class="avatar" src="<?php echo $this->basePath('img/cup.png') ?>" /> | ||
<div class="icon-con "> | ||
<div class="blog "> | ||
<a href=""> | ||
<img src="<?php echo $this->basePath('img/link.png') ?>" /> | ||
</a> | ||
</div> | ||
</div> | ||
</li> | ||
<li class="col-lg-3 col-md-2 col-sm-3 col-xs-4"> | ||
<img class="avatar" src="<?php echo $this->basePath('img/download.png') ?>" /> | ||
<div class="icon-con "> | ||
<div class="blog "> | ||
<a href=""> | ||
<img src="<?php echo $this->basePath('img/link.png') ?>" /> | ||
<?php | ||
if ('http:' !== substr($contributor['user_info']['blog'],0,5)) { | ||
$contributor['user_info']['blog'] = 'http://' . $contributor['user_info']['blog']; | ||
} | ||
?> | ||
<a href="<?php echo $contributor['user_info']['blog'] ?>"> | ||
blog | ||
</a> | ||
</div> | ||
<?php endif; ?> | ||
</div> | ||
</li> | ||
<?php endforeach; ?> | ||
</ul> | ||
</div> |