diff --git a/js/customElements/skills.js b/js/customElements/skills.js index d1938b8968ad6e64e5a004386ec3a6b7edf7cfa1..2c717cb56f623db4971765adc64ba9e538876b65 100644 --- a/js/customElements/skills.js +++ b/js/customElements/skills.js @@ -1,11 +1,18 @@ class Skill extends HTMLElement { constructor() { super(); - ["python", "php", "sass", "css", "c_sharp", "html", "java", "arduino", "raspberry", "linux", "arch", "gitlab", "traefik", "proxmox"].forEach( skill => { - const image = document.createElement("img"); - image.src = "/API/getFile.php?filename=skills/" + skill + ".png"; - this.appendChild(image); - }) + let xhr = new XMLHttpRequest(); + xhr.onreadystatechange = () => { + if (xhr.readyState == 4 && xhr.status == 200) { + JSON.parse(xhr.responseText).forEach(skill => { + const image = document.createElement("img"); + image.src = "/API/getFile.php?filename=" + skill; + this.appendChild(image); + }); + } + } + xhr.open("GET", "/API/skills.php"); + xhr.send(); } } diff --git a/public/API/skills.php b/public/API/skills.php new file mode 100644 index 0000000000000000000000000000000000000000..28116e71d41379b6cb73a03a7f102e9e74d63d99 --- /dev/null +++ b/public/API/skills.php @@ -0,0 +1,24 @@ +<?php +include("./lib/config.php"); +require 'vendor/autoload.php'; + +$s3Client = new Aws\S3\S3Client([ + 'version' => 'latest', + 'region' => 'us-east-1', + 'endpoint' => $S3Server, + 'use_path_style_endpoint' => true, + 'credentials' => [ + 'key' => $S3AccessKey, + 'secret' => $S3SecretKey, + ], +]); + +$result = $s3Client->ListObjects(['Bucket' => $S3BucketName, 'Delimiter'=>'/', 'Prefix' => 'skills/']); + +$response = []; +foreach ($result["Contents"] as $skill){ + array_push($response, $skill["Key"]); +} + +header("Content-Type: application/json"); +echo json_encode($response); \ No newline at end of file