diff --git a/sql/0-initdatabase.sql b/sql/0-initdatabase.sql new file mode 100644 index 0000000..78c97e3 --- /dev/null +++ b/sql/0-initdatabase.sql @@ -0,0 +1,28 @@ +-- 22-12-22 +-- Init the database + +START TRANSACTION; + +CREATE DATABASE [IF NOT EXISTS] site; +USE site; + +CREATE TABLE post( + ID INT AUTO_INCREMENT PRIMARY KEY, + author VARCHAR(32) NOT NULL, + created TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + title VARCHAR(64) NOT NULL, +); + +CREATE TABLE tag( + ID INT AUTO_INCREMENT PRIMARY KEY, + title VARCHAR(32) +); + +CREATE TABLE post_tag( + tag_id INT NOT NULL, + post_id INT NOT NULL, + FOREIGN KEY (tag_id) REFERENCES tag(ID) ON DELETE CASCADE, + FOREIGN KEY (post_id) REFERENCES post(ID) ON DELETE CASCADE +); + +COMMIT; diff --git a/src/common/article.php b/src/common/article.php new file mode 100644 index 0000000..fe6cee0 --- /dev/null +++ b/src/common/article.php @@ -0,0 +1,44 @@ +client = mysqli_connect($host, $user, $pass, $db); + } + + public function getAllPosts() { + $result = mysqli_query($this->client, 'SELECT * FROM post'); + return mysqli_fetch_all($result); + } + + public function getMostRecentPosts($limit){ + $result = mysqli_query($this->client, 'SELECT * FROM post ORDER BY created DESC LIMIT ' . $limit); + return mysqli_fetch_all($result); + } + + public function getPostData($postId) { + $result = mysqli_query($this->client, 'SELECT * FROM post WHERE ID = ' . $postId); + return mysqli_fetch_all($result); + } + +} +?> diff --git a/src/common/git.php b/src/common/git.php index ca31a3a..898e2d1 100644 --- a/src/common/git.php +++ b/src/common/git.php @@ -1,52 +1,60 @@ giteaToken = $token; } - curl_close($curl); + 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=" . $this->giteaToken); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - return $result; + $result = curl_exec($curl); + if(!$result){ + header('HTTP/1.1 500 Internal Server Error'); + die(); + } -} + curl_close($curl); -function getRecentProjects() { - $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_RETURNTRANSFER, 1); + return $result; - $result = curl_exec($curl); - if(!$result){ - header('HTTP/1.1 500 Internal Server Error'); - die(); } - curl_close($curl); - //now we need to parse out the results into a nice array containing the - //most recent items + 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=" . $this->giteaToken); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - $parsed = json_decode($result, true); + $result = curl_exec($curl); + if(!$result){ + header('HTTP/1.1 500 Internal Server Error'); + die(); + } - $ret = array(); + curl_close($curl); + //now we need to parse out the results into a nice array containing the + //most recent items + + $parsed = json_decode($result, true); + + $ret = array(); + + foreach($parsed as $item){ + array_push($ret, $item); + } + + usort($ret, "datecmp"); + return $ret; - foreach($parsed as $item){ - array_push($ret, $item); } - usort($ret, "datecmp"); - return $ret; - } function datecmp($lhs, $rhs) { return $lhs["updated_at"] < $rhs["updated_at"]; } - - ?> diff --git a/src/common/header.php b/src/common/header.php index 27974dd..9c667a5 100644 --- a/src/common/header.php +++ b/src/common/header.php @@ -2,7 +2,7 @@ Home - Resume + Resume Git Utilities Wiki diff --git a/src/index.css b/src/index.css index e712b35..3a90120 100644 --- a/src/index.css +++ b/src/index.css @@ -31,7 +31,7 @@ text-decoration: none; } -.git-clickable-div { +.list-clickable-div { display: block; width: calc(100% - 10px - 3px); height: auto; @@ -42,16 +42,31 @@ background-color: rgba(0,0,0,0.4); margin: 5px; } -.git-clickable-div p { + +.list-clickable-div p { margin: 15px 5px; } -.git-clickable-div:hover { +.list-clickable-div:hover { text-decoration: underline 0.15em rgba(255,255,255,1); background-color: rgba(0,0,0,0.85); } +.clickable-header { + display: block; + text-decoration-color: rgba(255,255,255,0) !important; +} + +.clickable-header h3 { + text-decoration: underline 0.15em rgba(255,255,255,0) !important; + transition: 300ms; +} + +.clickable-header h3:hover { + text-decoration: underline 0.15em rgba(255,255,255,1); +} + .single-column { grid-template-columns: 1fr !important; } @@ -84,6 +99,7 @@ .index-column { display: grid; grid-template-rows: 10em 1fr; + width: calc(100% - 3em); } diff --git a/src/index.php b/src/index.php index d53ab00..421f050 100644 --- a/src/index.php +++ b/src/index.php @@ -3,6 +3,7 @@ + Tyler Perkins - Home @@ -32,7 +33,8 @@ Projects getRecentProjects(); array_splice($result, 6, -1); foreach($result as $item){ if($item["private"]) @@ -44,7 +46,7 @@ $description = $item["description"]; //build out the html - echo ''; + echo ''; echo '' . $name . ' - ' . $description . ''; echo ''; } @@ -53,7 +55,25 @@ Articles - To be implemented + + getMostRecentPosts(5); + + foreach($posts as $post){ + if($post == null) + continue; + + $id = $post[0]; + $author = $post[1]; + $title = $post[3]; + + echo ''; + echo '(' . $author . ') ' . $title . ''; + echo ''; + } + ?> + diff --git a/src/resume.php b/src/resume/index.php similarity index 76% rename from src/resume.php rename to src/resume/index.php index d74cc35..2d6da5c 100644 --- a/src/resume.php +++ b/src/resume/index.php @@ -1,8 +1,10 @@ getResumeReleases(), true); $url = $parsed[0]["assets"][0]["browser_download_url"]; if(!$url){
' . $name . ' - ' . $description . '
To be implemented
(' . $author . ') ' . $title . '