Inheritance: extends GitRepo
Example #1
0
 public function run()
 {
     $G = new Github();
     $req_url = $_SERVER['REQUEST_SCHEME'] . "://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
     $path = parse_url($req_url, PHP_URL_PATH);
     $paths = explode("/", $path);
     $project_name = $paths[2] . '/' . $paths[3];
     $this->state['project_name'] = $project_name;
     $this->state['repo'] = $G->load_stored_repo($project_name);
     if ($this->state['repo']['status'] == 4) {
         if (!$this->state['repo']['public']) {
             $G->load_user();
         }
         $G->load_coin_owners($project_name);
         $this->state['date_minted'] = $G->date_minted;
         $this->state['last_commit'] = strftime("%b %d", strtotime(query_grab("SELECT max(commit_date) FROM commit_log WHERE repo = '" . $this->state['repo']['name'] . "'")));
         $this->state['asset_hash'] = $G->asset_hash;
         $this->state['cal'] = $G->schedule;
         $this->state['contributors'] = $G->contributors;
         $this->state['equity'] = $G->equity;
         $this->state['today'] = $G->today;
     } else {
         $G->load_user();
         $BTC = new Bitcoin();
         $BTC->generate_address($project_name);
         $this->state['btc_address'] = $BTC->input_address;
         $this->state['status'] = $BTC->status;
         $this->state['hash'] = $BTC->transaction_hash;
     }
     $this->_load("mint.html");
 }
Example #2
0
 public function files()
 {
     if (is_null($this->files)) {
         $github = new Github();
         $this->files = $github->requestFilesFromGist($this);
     }
     return $this->files;
 }
Example #3
0
 public function run()
 {
     $G = new Github();
     if ($_GET['code']) {
         $G->authenticate($_GET['code']);
     }
     header("Location: " . SITE_URL . '/dashboard');
     die;
 }
Example #4
0
 public function store_asset($repo)
 {
     $G = new Github();
     $G->load_repo($repo);
     $public_id = HOTWALLET_ASSET;
     // Store a temp asset id, then update it later I guess
     $qi = "INSERT INTO asset (public_id, name_short, name, contract_url, issuer, description, description_mime, type, divisibility, link_to_website, icon_url, image_url, version, date_created) VALUES \n\t\t\t\t(\n\t\t\t\t\t'" . $public_id . "',\n\t\t\t\t\t'" . escape(substr($G->json_response->name, 0, 10)) . "',\n\t\t\t\t\t'" . escape($G->json_response->full_name) . "',\n\t\t\t\t\t'" . escape(SITE_URL . '/asset/' . $G->json_response->full_name) . "',\n\t\t\t\t\t'" . escape($G->json_response->owner->login) . "',\n\t\t\t\t\t'" . escape($G->json_response->description . "\n" . $G->json_response->html_url) . "',\n\t\t\t\t\t'text/x-markdown; charset=UTF-8',\n\t\t\t\t\t'Bithub', \n\t\t\t\t\t'" . DEFAULT_DIVISIBILITY . "', \n\t\t\t\t\t'false',\n\t\t\t\t\t'" . escape($G->json_response->owner->avatar_url) . "', \n\t\t\t\t\t'" . escape($G->json_response->owner->avatar_url) . "', \n\t\t\t\t\t'1.0', \n\t\t\t\t\tNOW()\n\t\t\t\t\t)";
     query($qi);
     return mysqli_insert_id(Gbl::get('db'));
 }
Example #5
0
 protected function process_github($hub)
 {
     header("Content-type: text/plain");
     $G = new Github($hub);
     $r = $G->get_admin_repos();
     //$r = $G->get_contributors();
     print_r($G->curlinfo);
     print_r($G->header);
     print_r($G->json_response);
     print_r($G->json_error);
     die;
 }
Example #6
0
 private static function getClient()
 {
     if (!self::$_client) {
         self::$_client = new GuzzleHttp\Client(array('base_uri' => Env::get('github_api_url', 'https://api.github.com')));
     }
     return self::$_client;
 }
Example #7
0
 /**
  * Get repository's contributors
  * @param string $owner - repo's owner
  * @param string $name - repo's name
  * @return array
  */
 public static function getRepoUsers($owner, $name)
 {
     $users = Github::repo()->contributors($owner, $name);
     //check liked
     self::addLikeAttributes($users);
     return $users;
 }
 public function run()
 {
     $G = new Github();
     $G->load_user();
     $G->load_repos();
     $arr = array();
     foreach ($G->repos as $k => $v) {
         if ($v->owner->id == $_SESSION['user']['github_id']) {
             $owner = "You";
         } else {
             $owner = $v->owner->login;
         }
         $arr[] = array('id' => $v->id, 'name' => $v->name, 'fullname' => $v->full_name, 'dateraw' => strtotime($v->updated_at), 'date' => strftime("%x", strtotime($v->updated_at)), 'url' => $v->html_url, 'owner' => $owner, 'status' => $v->status, 'confirmations' => $v->confirmations, 'address' => $v->address, 'transaction_hash' => $v->transaction_hash);
     }
     usort($arr, "arrsort");
     $this->state['debug'] = print_r($G->repos, 1);
     $this->state['repos'] = $arr;
     $this->_load("dash.html");
 }
Example #9
0
 public function before()
 {
     parent::before();
     if (!Kohana::config('github')->login) {
         $msg = 'Please add your login credentials to the configuration file.<br/>';
         $msg .= 'Look here for your login credentials: ' . html::anchor('https://github.com/account');
         die($msg);
     }
     // github info can be passed by reference or set in config
     // Github::instance($format, $user, $token)
     $this->g = Github::instance();
 }
Example #10
0
 protected static function owner()
 {
     if (is_null(self::$owner)) {
         $path = APP_ROOT . '/../apiauth/github_project_owner';
         $owner = trim(file_get_contents($path));
         if ($owner) {
             self::$owner = $owner;
         } else {
             self::$owner = false;
         }
     }
     return self::$owner;
 }
Example #11
0
 public function executeView()
 {
     $pullid = (int) mfwRequest::get('pull_id');
     $pull = PullRequestDb::retrieveByPK($pullid);
     if (!$pull) {
         return $this->buildErrorPage("pull request no found (id={$pullid})");
     }
     $repo = $this->repolist[$pull->getRepoId()];
     $rawpull = Github::getSinglePullRequest($repo->getName(), $pull->getNumber());
     $comments = Github::getPullRequestComments($repo->getName(), $pull->getNumber());
     $files = Github::getPullRequestFiles($repo->getName(), $pull->getNumber());
     $alerts = PullRequestAlertDb::selectByPullRequest($pull);
     $filters = FilterDb::selectAll();
     $alert_filters = array();
     foreach ($alerts as $a) {
         $alert_filters[$a->getFileName()][] = $filters[$a->getFilterId()];
     }
     $params = array('rawpull' => $rawpull, 'comments' => $comments, 'files' => $files, 'pull' => $pull, 'repo' => $repo, 'alert_filters' => $alert_filters);
     return $this->build($params);
 }
 public function postProcess()
 {
     // Recherche d'un utilisateur
     if (Tools::isSubmit('submitSearchAccount')) {
         $this->setTemplate('comments/search.tpl');
         try {
             $accounts = Github::searchAccounts(Tools::getValue('search', Tools::getValue('term')));
             if (Tools::getIsset('term')) {
                 // Depuis ajax
                 $this->renderAjaxSearch($accounts);
             }
             $this->context->smarty->assign(array('total_count' => $accounts['total_count'], 'accounts' => $accounts['items']));
         } catch (Exception $e) {
             $this->errors[] = 'Impossible de récupérer les profils correspondant à votre recherche';
         }
     } elseif (Tools::isSubmit('submitAddComment')) {
         if (!$this->profile) {
             return $this->errors[] = 'Veuillez specifier un profil valide';
         } elseif (!Validate::isNonEmptyString($repository = Tools::getValue('repository'))) {
             return $this->errors[] = 'Veuillez specifier un nom de dépot valide';
         } elseif (!Validate::isCleanHTML($commentContent = Tools::getValue('comment'))) {
             return $this->errors[] = 'Veuillez fournir un commentaire valide';
         } elseif (!$this->isProfileRepository($repository)) {
             return $this->errors[] = "Ce dépot n'appartient pas à cet utilisateur";
         }
         $comment = new Comment();
         $comment->setUser(Auth::getUser())->setUsername($this->profile['login'])->setRepository($repository)->setComment(nl2br($commentContent));
         // @todo WYSIWYG
         if (!$comment->save()) {
             $this->errors[] = "Impossible d'enregistrer le commentaire (" . Db::getInstance()->getMsgError() . ")";
         } else {
             Flash::success('Votre commentaire a bien été ajouté!');
             Tools::redirect($this->context->link->getPageLink('comments', array('user' => $this->profile['login'])));
         }
     }
 }
Example #13
0
 /**
  * 直接向当前用户的博客源删除一个数据
  * 
  * @param sting $path    路径
  * @param sting $message 注释
  * 
  * @return \stdClass
  */
 public static function destroyUserRespos($path, $message)
 {
     $user = User::show();
     $login = $user['metadata']['login'];
     $repo = Github::showDefaultBlogRepoName($user['metadata']['login']);
     $respositories = new \Api\Github\Respositories();
     return $respositories->delete($login, $repo, $path, $message);
 }
Example #14
0
/**
 * Gists shortcode.
 * @param $atts
 * @return string
 */
function ghgists_shortcode($atts)
{
    $a = shortcode_atts(array('username' => get_option('wpgithub_defaultuser', 'seinoxygen'), 'limit' => '5'), $atts);
    // Init the cache system.
    $cache = new WpGithubCache();
    // Set custom timeout in seconds.
    $cache->timeout = get_option('wpgithub_cache_time', 600);
    $gists = $cache->get($a['username'] . '.gists.json');
    if ($gists == NULL) {
        $github = new Github($a['username']);
        $gists = $github->get_gists();
        $cache->set($a['username'] . '.gists.json', $gists);
    }
    if (is_array($gists)) {
        $gists = array_slice($gists, 0, $a['limit']);
    }
    $html = '<ul class="wp-github wpg-gists">';
    foreach ($gists as $gist) {
        $html .= '<li><a target="_blank" href="' . $gist->html_url . '" title="' . $gist->description . '">' . $gist->description . '</a></li>';
    }
    $html .= '</ul>';
    return $html;
}
Example #15
0
 /**
  * GitHubUser constructor.
  *
  * @param \GrahamCampbell\GitHub\GitHubManager $github
  * @param                                      $gitHubUser
  */
 public function __construct(\GrahamCampbell\GitHub\GitHubManager $github, $gitHubUser)
 {
     parent::__construct($github);
     $this->find($gitHubUser);
 }
 function widget($args, $instance)
 {
     extract($args);
     $title = $this->get_title($instance);
     $username = $this->get_username($instance);
     $project_count = $this->get_project_count($instance);
     echo $args['before_widget'];
     echo $args['before_title'] . $title . $args['after_title'];
     // Init the cache system.
     $cache = new WpGithubCache();
     // Set custom timeout in seconds.
     $cache->timeout = get_option('wpgithub_cache_time', 600);
     $repositories = $cache->get($username . '.repositories.json');
     if ($repositories == NULL) {
         $github = new Github($username);
         $repositories = $github->get_repositories();
         $cache->set($username . '.repositories.json', $repositories);
     }
     if ($repositories == NULL || count($repositories) == 0) {
         echo $username . ' does not have any public repositories.';
     } else {
         $repositories = array_slice($repositories, 0, $project_count);
         echo '<ul>';
         foreach ($repositories as $repository) {
             echo '<li><a target="_blank" href="' . $repository->html_url . '" title="' . $repository->description . '">' . $repository->name . '</a></li>';
         }
         echo '</ul>';
     }
     echo $args['after_widget'];
 }
Example #17
0
<?php

$plugin_info = array('pi_name' => 'Github API', 'pi_version' => '0.8', 'pi_author' => 'Pascal Kriete', 'pi_author_url' => 'http://pascalkriete.com/', 'pi_description' => 'A wrapper to Github\'s API {@link http://develop.github.com/}', 'pi_usage' => Github::usage());
/**
 * Github Class
 *
 * @package			ExpressionEngine
 * @category		Plugin
 * @author			Pascal Kriete
 * @link			@todo
 *
 * Loosely built on the twitter timeline plugin by Derek Jones
 * Saved me some fsockopen / caching / localize work
 */
class Github
{
    var $return_data;
    var $base_url = 'http://github.com/api/v2/xml/';
    // other formats are YAML or JSON
    var $cache_name = 'github_cache';
    var $cache_expired = FALSE;
    var $refresh = 30;
    // Period between cache refreshes, in minutes
    var $limit = 20;
    // @todo look up default github limit
    var $username = '';
    var $prefix = '';
    // github vars are very generic, so use this to avoid conflicts (also a parameter)
    // Used by _parse_xml to clean up the returned array
    var $ignore = array('commit', 'repository', 'tree');
    var $nested = array('author' => array('name', 'email'), 'committer' => array('name', 'email'));
Example #18
0
<?php

require_once dirname(__FILE__) . '/init.php';
var_dump(Github::getUser('jessylenne'));
 /**
  * @dataProvider xmlToTextProvider
  */
 public function testXmlToText($xml, $expected)
 {
     $translator = new Github();
     $this->assertEquals($expected, $translator->xmlToText(decorateWithRootNode($xml)));
 }
Example #20
0
<?php

require_once MODULES_PATH . '/Github.lib.php';
$G = new Github();
$G->reward_contributors();
 public function testRepositories()
 {
     $results = Github::getUserRepositories('jessylenne');
     $this->assertTrue(Validate::isNonEmptyArray($results));
     $this->assertGreaterThanOrEqual(1, sizeof($results));
 }
Example #22
0
 function widget($args, $instance)
 {
     extract($args);
     $title = $this->get_title($instance);
     $username = $this->get_username($instance);
     $gists_count = $this->get_gists_count($instance);
     echo $before_widget;
     echo $before_title . $title . $after_title;
     // Init the cache system.
     $cache = new Cache();
     // Set custom timeout in seconds.
     $cache->timeout = get_option('wpgithub_cache_time', 600);
     $gists = $cache->get($username . '.gists.json');
     if ($gists == null) {
         $github = new Github($username);
         $gists = $github->get_gists();
         $cache->set($username . '.gists.json', $gists);
     }
     if ($gists == null || count($gists) == 0) {
         echo $username . ' does not have any public gists.';
     } else {
         $gists = array_slice($gists, 0, $gists_count);
         echo '<ul>';
         foreach ($gists as $gist) {
             echo '<li><a href="' . $gist->html_url . '" title="' . $gist->description . '">' . $gist->description . '</a></li>';
         }
         echo '</ul>';
     }
     echo $after_widget;
 }
Example #23
0
 /**
  * Commit constructor.
  *
  * @param \GrahamCampbell\GitHub\GitHubManager $github
  * @param \App\Library\GitHub\Repository       $repository
  * @param                                      $sha
  */
 public function __construct(\GrahamCampbell\GitHub\GitHubManager $github, Repository $repository, $sha)
 {
     parent::__construct($github);
     $this->find($repository, $sha);
 }