feat(skills): reads data from yaml file

This commit is contained in:
darkicewolf50 2025-05-05 14:27:03 -06:00
parent ae8f9db6ef
commit 8a60c5097e
4 changed files with 325 additions and 3 deletions

View File

@ -1,5 +1,5 @@
[package]
name = "darkicewolf50Cloud"
name = "darkicewolf50_cloud"
version = "0.1.0"
edition = "2024"
@ -7,3 +7,4 @@ edition = "2024"
actix-web = "4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1"
yaml-rust2 = "0.10.1"

View File

@ -0,0 +1,228 @@
---
- tech_name: Rust
tech_logo: https://www.svgrepo.com/show/374056/rust.svg
project_site: https://www.rust-lang.org
skill_level: 65
tech_cat:
- Languages
- tech_name: Python
tech_logo: https://www.svgrepo.com/show/452091/python.svg
project_site: https://www.python.org
skill_level: 50
tech_cat:
- Languages
- tech_name: YAML
tech_logo: https://yaml.org/favicon.svg
project_site: https://yaml.org
skill_level: 95
tech_cat:
- Languages
- tech_name: HTML5
tech_logo: https://www.svgrepo.com/show/452228/html-5.svg
project_site: https://google.com
skill_level: 90
tech_cat:
- Languages
- tech_name: CSS
tech_logo: https://www.svgrepo.com/show/452185/css-3.svg
project_site: https://google.com
skill_level: 65
tech_cat:
- Languages
- tech_name: JavaScript
tech_logo: https://www.svgrepo.com/show/303206/javascript-logo.svg
project_site: https://www.python.org
skill_level: 50
tech_cat:
- Languages
- tech_name: Markdown
tech_logo: https://www.svgrepo.com/show/510065/markdown.svg
project_site: https://www.markdownguide.org
skill_level: 90
tech_cat:
- Languages
- tech_name: Actix
tech_logo: https://actix.rs/img/logo.png
project_site: https://actix.rs
skill_level: 20
tech_cat:
- Backend
- tech_name: FastAPI
tech_logo: https://fastapi.tiangolo.com/img/favicon.png
project_site: https://fastapi.tiangolo.com
skill_level: 80
tech_cat:
- Backend
- tech_name: Dioxus
tech_logo: https://dioxuslabs.com/assets/smalllogo-b1926fd214dc8427.png
project_site: https://dioxuslabs.com
skill_level: 70
tech_cat:
- Backend
- Frontend
- tech_name: Diesel
tech_logo: https://res.cloudinary.com/dpgrgsh7g/image/upload/v1745443276/diesel_logo_ujtvia.png
project_site: https://diesel.rs
skill_level: 10
tech_cat:
- Backend
- tech_name: React
tech_logo: https://www.svgrepo.com/show/452092/react.svg
project_site: https://react.dev
skill_level: 70
tech_cat:
- Frontend
- tech_name: Nextjs
tech_logo: https://nextjs.org/favicon.ico
project_site: https://nextjs.org
skill_level: 10
- Frontend
- tech_name: Sqlite
tech_logo: https://www.svgrepo.com/show/374094/sqlite.svg
project_site: https://www.sqlite.org
skill_level: 10
tech_cat:
- Databases
- tech_name: PostgreSQL
tech_logo: https://www.svgrepo.com/show/303301/postgresql-logo.svg
project_site: https://www.postgresql.org
skill_level: 10
tech_cat:
- Databases
- tech_name: Mongodb
tech_logo: https://www.svgrepo.com/show/331488/mongodb.svg
project_site: https://www.mongodb.com
skill_level: 10
tech_cat:
- Databases
- tech_name: DynamoDB
tech_logo: https://www.svgrepo.com/show/473526/amazondynamodb.svg
project_site: https://aws.amazon.com/dynamodb/
skill_level: 70
tech_cat:
- Databases
- tech_name: AWS
tech_logo: https://www.svgrepo.com/show/448266/aws.svg
project_site: https://aws.amazon.com
skill_level: 30
tech_cat:
- Platforms
- tech_name: Cloudflare
tech_logo: https://qualified-production.s3.us-east-1.amazonaws.com/uploads/3b522ef84c409e4457032e4b4e3b984abbc92522c6f100f4ccc55c0ccfd3062b.png
project_site: https://www.cloudflare.com/en-ca/
skill_level: 65
tech_cat:
- Platforms
- tech_name: Vercel
tech_logo: https://www.svgrepo.com/show/361653/vercel-logo.svg
project_site: https://vercel.com/home
skill_level: 60
tech_cat:
- Platforms
- tech_name: Netlify
tech_logo: https://qualified-production.s3.us-east-1.amazonaws.com/uploads/0f63ae7280d8d193e346973a1915bf99aea8c63e254eb062bad0bde99b43a9b7.png
project_site: https://www.netlify.com
skill_level: 60
tech_cat:
- Platforms
- tech_name: Gitea
tech_logo: https://about.gitea.com/gitea.png
project_site: https://about.gitea.com
skill_level: 85
tech_cat:
- Platforms
- tech_name: Github
tech_logo: https://www.svgrepo.com/show/512317/github-142.svg
project_site: https://github.com/darkicewolf50
skill_level: 80
tech_cat:
- Platforms
- tech_name: Vs Code
tech_logo: https://www.svgrepo.com/show/452129/vs-code.svg
project_site: https://code.visualstudio.com
skill_level: 60
tech_cat:
- Tools
- tech_name: Git
tech_logo: https://www.svgrepo.com/show/452210/git.svg
project_site: https://git-scm.com
skill_level: 55
tech_cat:
- Tools
- tech_name: Prettier
tech_logo: https://prettier.io/icon.png
project_site: https://prettier.io
skill_level: 90
tech_cat:
- Tools
- tech_name: Firefox
tech_logo: https://www.svgrepo.com/show/378808/firefox-developer-edition-57-70.svg
project_site: https://www.mozilla.org/en-CA/firefox/developer/
skill_level: 80
tech_cat:
- Tools
- tech_name: Github Actions
tech_logo: https://cdn.simpleicons.org/githubactions/2088FF
project_site: https://github.com/
skill_level: 50
tech_cat:
- Tools
- tech_name: Traefik
tech_logo: https://hub.docker.com/api/media/repos_logo/v1/library%2Ftraefik
project_site: https://traefik.io/traefik/
skill_level: 60
tech_cat:
- Tools
- tech_name: Docker
tech_logo: https://www.svgrepo.com/show/448221/docker.svg
project_site: https://www.docker.com
skill_level: 70
tech_cat:
- Tools
- tech_name: Kubernetes
tech_logo: https://kubernetes.io/images/kubernetes.png
project_site: https://kubernetes.io
skill_level: 5
tech_cat:
- Tools
- tech_name: Terraform
tech_logo: https://www.svgrepo.com/show/448253/terraform.svg
project_site: https://www.terraform.io
skill_level: 15
tech_cat:
- Tools
- tech_name: Email
tech_logo: https://www.svgrepo.com/show/491226/email.svg
project_site: mailto:darkicewolf50@gmail.com
skill_level: 100
tech_cat:
- Other
- tech_name: LinkedIn
tech_logo: https://www.svgrepo.com/show/521725/linkedin.svg
project_site: https://www.linkedin.com/in/brock-tomlinson/
skill_level: 40
tech_cat:
- Other
- tech_name: Twitch
tech_logo: https://www.svgrepo.com/show/519925/twitch.svg
project_site: https://www.twitch.tv/darkicewolf50
skill_level: 60
tech_cat:
- Other
- tech_name: Youtube
tech_logo: https://www.svgrepo.com/show/521936/youtube.svg
project_site: https://www.youtube.com/@darkicewolf50
skill_level: 40
tech_cat:
- Other
- tech_name: Internet
tech_logo: https://www.svgrepo.com/show/490809/internet.svg
project_site: https://google.com
skill_level: 99
tech_cat:
- Other

78
src/lib.rs Normal file
View File

@ -0,0 +1,78 @@
use actix_web::{HttpResponse, Responder, get, post, web};
use serde::{Deserialize, Serialize};
use std::fs;
pub fn add(left: u64, right: u64) -> u64 {
left + right
}
#[get("/")]
pub async fn hello() -> impl Responder {
HttpResponse::Ok().body("Hello world!")
}
#[post("/echo")]
pub async fn echo(req_body: String) -> impl Responder {
HttpResponse::Ok().body(req_body)
}
pub async fn manual_hello() -> impl Responder {
HttpResponse::Ok().body("Hello there!\nGeneral Kenobi")
}
// the path to get to the html response
#[get("/resend")]
// function signature, data that is passed in, return type must implement the Responder trait
pub async fn resend(req_body: String) -> impl Responder {
// this returns a html response with a 200 code
// this should be used for final serialization
// possibly main functionality
HttpResponse::Ok().body(req_body)
}
#[derive(Deserialize, Serialize, Debug)]
struct TechDes {
tech_name: String,
tech_logo: String,
project_site: String,
skill_level: u8,
tech_cat: Vec<String>,
}
#[get("/skills")]
pub async fn skills_home() -> impl Responder {
let raw_yaml: String = fs::read_to_string("./src/data_txt/skill_level.yaml").unwrap();
// .expect("Cannot open file or missing file.");
let vec_yaml = yaml_rust2::YamlLoader::load_from_str(&raw_yaml).unwrap()[0].clone();
let res_vec: Vec<TechDes> = vec_yaml
.as_vec()
.unwrap_or(&vec![])
.iter()
.map(|item| TechDes {
tech_name: item["tech_name"].as_str().unwrap_or("").to_string(),
tech_logo: item["tech_logo"].as_str().unwrap_or("").to_string(),
project_site: item["project_site"].as_str().unwrap_or("").to_string(),
skill_level: item["skill_level"].as_i64().unwrap_or(0) as u8,
tech_cat: item["tech_cat"]
.as_vec()
.unwrap_or(&vec![])
.iter()
.filter_map(|item_cat| item_cat.as_str().map(|inner_cat| inner_cat.to_string()))
.collect(),
})
.collect();
// println!("{:#?}", res_vec[2]);
web::Json(res_vec)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

View File

@ -1,3 +1,18 @@
fn main() {
println!("Hello, world!");
use actix_web::{App, HttpServer, web};
use darkicewolf50_cloud::{echo, hello, manual_hello, resend, skills_home};
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.service(hello)
.service(echo)
.service(resend)
.route("/hey", web::get().to(manual_hello))
.service(web::scope("/home").service(skills_home))
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}