Refactor git and resume
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Tyler Perkins 2022-12-22 20:08:33 -05:00
parent cbb7490069
commit bd966f576b
4 changed files with 46 additions and 35 deletions

View File

@ -1,7 +1,15 @@
<?php
function getResumeReleases() {
class Gitea {
private $giteaToken;
public function __construct(String $token) {
$this->giteaToken = $token;
}
public function getResumeReleases() : String {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://git.clortox.com/api/v1/repos/tyler/Resume/releases?per_page=1&access_token=" . getenv("GITEA_TOKEN"));
curl_setopt($curl, CURLOPT_URL, "https://git.clortox.com/api/v1/repos/tyler/Resume/releases?per_page=1&access_token=" . $this->giteaToken);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
@ -16,9 +24,9 @@ function getResumeReleases() {
}
function getRecentProjects() {
public function getRecentProjects() : array {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://git.clortox.com/api/v1/user/repos?page=1&limit=100&access_token=" . getenv("GITEA_TOKEN"));
curl_setopt($curl, CURLOPT_URL, "https://git.clortox.com/api/v1/user/repos?page=1&limit=100&access_token=" . $this->giteaToken);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
@ -44,9 +52,9 @@ function getRecentProjects() {
}
}
function datecmp($lhs, $rhs) {
return $lhs["updated_at"] < $rhs["updated_at"];
}
?>

View File

@ -2,7 +2,7 @@
<link rel="stylesheet" href="/common/header.css">
<nav class="navbar sticky">
<a href="/">Home</a>
<a href="/resume.php">Resume</a>
<a href="/resume">Resume</a>
<a href="https://git.clortox.com">Git</a>
<a href="/utilities/">Utilities</a>
<a href="https://wiki.clortox.com">Wiki</a>

View File

@ -32,7 +32,8 @@
<h3>Projects</h3>
<div>
<?php
$result = getRecentProjects();
$giteaClient = new Gitea(getenv("GITEA_TOKEN"));
$result = $giteaClient->getRecentProjects();
array_splice($result, 6, -1);
foreach($result as $item){
if($item["private"])

View File

@ -1,8 +1,10 @@
<?php
include 'common/git.php';
include '../common/git.php';
$parsed = json_decode(getResumeReleases(), true);
$giteaClient = new Gitea(getenv('GITEA_TOKEN'));
$parsed = json_decode($giteaClient->getResumeReleases(), true);
$url = $parsed[0]["assets"][0]["browser_download_url"];
if(!$url){