From 988f1931e0acdc7cff69a2c3cab9e791d73a7b51 Mon Sep 17 00:00:00 2001 From: ShettySach Date: Sun, 25 Aug 2024 17:30:41 +0530 Subject: [PATCH] Temp fix, need to revamp --- configs/lang_icons/github.txt | 15 ++++++++ .../lang_icons/{pythons.txt => python.txt} | 0 configs/lang_icons/{ferris.txt => rust.txt} | 0 configs/neofetch.txt | 38 +++++++++---------- sans.txt | 21 ++++++++++ src/base/prompt/keyboard.rs | 3 +- src/commands.rs | 2 +- src/commands/fetch.rs | 19 ++++------ src/commands/fetch/formats.rs | 37 +++++------------- src/commands/fetch/structs.rs | 13 ++----- src/commands/texts.rs | 2 +- styles/styles.css | 6 +-- 12 files changed, 80 insertions(+), 76 deletions(-) create mode 100644 configs/lang_icons/github.txt rename configs/lang_icons/{pythons.txt => python.txt} (100%) rename configs/lang_icons/{ferris.txt => rust.txt} (100%) create mode 100644 sans.txt diff --git a/configs/lang_icons/github.txt b/configs/lang_icons/github.txt new file mode 100644 index 0000000..1b5c620 --- /dev/null +++ b/configs/lang_icons/github.txt @@ -0,0 +1,15 @@ + @@@@@@@@@@@@@@@@@@# + @@@@@@@@@@@@@@@@@@@@@@@@@@, + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + @@@@@@@ @@@@@@@@@@@@/ @@@@@@@ + @@@@@@@, @@@@@@@@ + @@@@@@@@ @@@@@@@@ + @@@@@@@ @@@@@@@ +@@@@@@@@ @@@@@@@ +@@@@@@@@ @@@@@@@ + @@@@@@@@ @@@@@@@@ + @@@@@@@@@@ @@@@@@@@@@ + @@@@% @@@@@@ @@@@@@@@@@@@@ + @@@@ @@@@@@@@@@@ + @@@@@@@@% @@@@@@@@@ + ,@@@@% @@@@@. diff --git a/configs/lang_icons/pythons.txt b/configs/lang_icons/python.txt similarity index 100% rename from configs/lang_icons/pythons.txt rename to configs/lang_icons/python.txt diff --git a/configs/lang_icons/ferris.txt b/configs/lang_icons/rust.txt similarity index 100% rename from configs/lang_icons/ferris.txt rename to configs/lang_icons/rust.txt diff --git a/configs/neofetch.txt b/configs/neofetch.txt index 5537e06..ec2c0ac 100644 --- a/configs/neofetch.txt +++ b/configs/neofetch.txt @@ -1,21 +1,17 @@ - ___ - ,o88888 - ,o8888888' - ,:o:o:oooooo. ,8O88Pd8888" - ,.::.::o:ooooOoOoO. ,oO8O8Pd888'" - ,.:.::o:ooOoOoOO8O8OOo.8OOPd8O8O" - , ..:.::o:ooOoOOOO8OOOOo.FdO8O8" - , ..:.::o:ooOoOO8O888O8O,COCOO" - , . ..:.::o:ooOoOOOO8OOOOCOCO" - . ..:.::o:ooOoOoOO8O8OCCCC"o - . ..:.::o:ooooOoCoCCC"o:o - . ..:.::o:o:,cooooCo"oo:o: - ` . . ..:.:cocoooo"'o:o:::' - .` . ..::ccccoc"'o:o:o:::' - :.:. ,c:cccc"':.:.:.:.:.' - ..:.:"'`::::c:"'..:.:.:.:.:.' - ...:.'.:.::::"' . . . . .' - .. . ....:."' ` . . . '' - . . . ...."' - .. . ."' - . +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⡤⠔⠒⠂⠀⠀⠀⠐⠒⠂⠤⢄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠔⢊⡥⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠑⠢⢄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠚⢁⡴⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠲⢄⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡰⠁⡰⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠱⡄⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡰⠁⢸⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠤⠘⡄⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⢠⠀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⢸⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠙⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡀⠀⠀⠀⠀⠀⡸⠁⠀⠀⠀⠀⠸⡇⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⠀⢀⣼⣿⣿⣷⣦⣄⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠈⠀⠀⠀⠀⢰⡅⠀⠀⠀⠀⠀⢰⠇⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⡀⠸⠷⠿⠿⢿⣿⡿⠀⠀⠀⠀⠀⠀⢀⣤⣶⣶⣶⣤⡀⠀⠀⠸⡇⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⡟⠀⠀⠀⠀⠀⠉⠀⠀⢀⠀⠀⠀⠀⢸⣯⣿⣿⣿⣿⡿⠀⠀⠀⠙⠤⡀⠀⠀⠀⡏⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡼⠟⠀⠀⣢⠀⠀⠀⠀⠀⠶⣿⡄⠀⠀⠀⠀⠀⠀⠀⠈⠉⠀⠀⠀⠀⠀⠀⡟⠀⠀⡜⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢳⠀⠀⠙⡏⠑⢤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⢸⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⢀⡴⠒⠉⠉⠺⣧⡀⠀⠘⢦⡇⠈⠉⢲⠤⣀⡀⠀⠀⠀⠀⠀⣀⣤⠀⠀⠀⠀⠀⠸⣀⡼⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⣿⠀⠰⣤⠀⠀⠈⠻⣦⣀⠀⠈⠓⠤⢎⡀⠀⠀⡝⠉⠉⢙⣋⡠⠛⠁⠀⠀⠀⠀⣸⣋⣠⣤⣤⡀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⢀⠤⠒⠛⠣⣀⠻⣧⠀⠀⠀⠈⢿⣿⠑⠢⢄⣀⡈⠉⠉⠙⠒⠉⠉⠁⠀⠀⠀⠀⣀⣤⣾⡿⠟⠉⠉⠀⠈⢢⡀⠀⠀⠀⠀⠀ +⣀⣼⠃⠀⠀⠀⠀⠈⢹⣿⣧⣄⣀⣀⣴⣿⣆⠀⠠⢉⠛⠱⠷⠲⠒⠀⣲⣶⣶⣶⡶⢿⣫⠥⠋⠀⣠⣴⠞⠀⠀⣸⠿⠀⠀⠀⠀⠀ +⠀⠘⠇⠀⠀⣀⣀⣠⣾⠥⠾⣿⡀⠀⣾⣿⠈⠑⠢⠤⣈⣑⣢⣄⣀⣰⣿⡿⠿⢿⣟⣉⣀⣠⠤⠾⠭⠥⠖⠒⠉⠉⠳⡀⠀⠀⠀⠀ diff --git a/sans.txt b/sans.txt new file mode 100644 index 0000000..e54fd22 --- /dev/null +++ b/sans.txt @@ -0,0 +1,21 @@ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⡤⠔⠒⠂⠀⠀⠀⠐⠒⠂⠤⢄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠔⢊⡥⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠑⠢⢄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠚⢁⡴⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠲⢄⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡰⠁⡰⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠱⡄⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡰⠁⢸⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠤⠘⡄⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⢠⠀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⢸⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠙⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡀⠀⠀⠀⠀⠀⡸⠁⠀⠀⠀⠀⠸⡇⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⠀⢀⣼⣿⣿⣷⣦⣄⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠈⠀⠀⠀⠀⢰⡅⠀⠀⠀⠀⠀⢰⠇⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⡀⠸⠷⠿⠿⢿⣿⡿⠀⠀⠀⠀⠀⠀⢀⣤⣶⣶⣶⣤⡀⠀⠀⠸⡇⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⡟⠀⠀⠀⠀⠀⠉⠀⠀⢀⠀⠀⠀⠀⢸⣯⣿⣿⣿⣿⡿⠀⠀⠀⠙⠤⡀⠀⠀⠀⡏⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡼⠟⠀⠀⣢⠀⠀⠀⠀⠀⠶⣿⡄⠀⠀⠀⠀⠀⠀⠀⠈⠉⠀⠀⠀⠀⠀⠀⡟⠀⠀⡜⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢳⠀⠀⠙⡏⠑⢤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⢸⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⢀⡴⠒⠉⠉⠺⣧⡀⠀⠘⢦⡇⠈⠉⢲⠤⣀⡀⠀⠀⠀⠀⠀⣀⣤⠀⠀⠀⠀⠀⠸⣀⡼⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⣿⠀⠰⣤⠀⠀⠈⠻⣦⣀⠀⠈⠓⠤⢎⡀⠀⠀⡝⠉⠉⢙⣋⡠⠛⠁⠀⠀⠀⠀⣸⣋⣠⣤⣤⡀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⢀⠤⠒⠛⠣⣀⠻⣧⠀⠀⠀⠈⢿⣿⠑⠢⢄⣀⡈⠉⠉⠙⠒⠉⠉⠁⠀⠀⠀⠀⣀⣤⣾⡿⠟⠉⠉⠀⠈⢢⡀⠀⠀⠀⠀⠀ +⣀⣼⠃⠀⠀⠀⠀⠈⢹⣿⣧⣄⣀⣀⣴⣿⣆⠀⠠⢉⠛⠱⠷⠲⠒⠀⣲⣶⣶⣶⡶⢿⣫⠥⠋⠀⣠⣴⠞⠀⠀⣸⠿⠀⠀⠀⠀⠀ +⠀⠘⠇⠀⠀⣀⣀⣠⣾⠥⠾⣿⡀⠀⣾⣿⠈⠑⠢⠤⣈⣑⣢⣄⣀⣰⣿⡿⠿⢿⣟⣉⣀⣠⠤⠾⠭⠥⠖⠒⠉⠉⠳⡀⠀⠀⠀⠀ +⠤⠶⠶⢶⣶⡇⣶⡄⣀⣀⣀⣠⡇⢸⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢦⠀⠀⠀ +⠀⠀⠀⠀⣿⡇⢘⣽⡏⠀⠀⠁⢠⣾⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⢯⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣆⠀⠀ +⠀⠀⠀⠀⢹⣿⠈⠛⠛⢚⡆⠀⢸⣯⡟⠀⠀⠀⠀⠀⡀⠀⠀⠀⡾⣾⠛⢦⣀⡀⠀⠀⠀⠀⠀⣰⣄⡀⠀⠀⠀⠀⠐⠛⠁⠀⠑⡄ +⠀⠀⠀⠀⠼⢿⣤⣀⠀⠀⢀⣤⣿⣿⠀⠀⠤⠒⣨⠟⡇⠀⠀⣸⣿⡏⠉⠉⠙⠛⠛⠛⠛⠩⠉⡹⠻⠭⠍⠙⠳⠲⣄⠀⠀⠀⠀⢘ diff --git a/src/base/prompt/keyboard.rs b/src/base/prompt/keyboard.rs index ff02217..4d8c1cf 100644 --- a/src/base/prompt/keyboard.rs +++ b/src/base/prompt/keyboard.rs @@ -30,11 +30,10 @@ pub fn keyboard_commands( "ArrowDown" => { if index > 1 { inp.set_value(&hist[index - 2]); - set_history_index.update(|history_index| *history_index -= 1); } else if index == 1 { inp.set_value(""); - set_history_index.update(|history_index| *history_index -= 1); } + set_history_index.update(|history_index| *history_index -= 1); } //Autocomplete "Tab" => { diff --git a/src/commands.rs b/src/commands.rs index ec55c87..c3b219b 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -32,7 +32,7 @@ impl Command { Self::Repos => fetch::get_repos().await, Self::Links => fetch::get_contacts().to_string(), Self::Credits => String::from(texts::CREDITS), - Self::Bash(bash) => Bash::printout(&bash), + Self::Bash(bash) => Bash::printout(bash), } } diff --git a/src/commands/fetch.rs b/src/commands/fetch.rs index a55b784..f1d9ef0 100644 --- a/src/commands/fetch.rs +++ b/src/commands/fetch.rs @@ -24,7 +24,7 @@ static CONTACTS: OnceLock = OnceLock::new(); // Once Functions fn read_config() -> Option { - CONFIG.get_or_init(|| match serde_json::from_str::(&JSON) { + CONFIG.get_or_init(|| match serde_json::from_str::(JSON) { Ok(config) => Some(config), Err(_) => None, }); @@ -40,7 +40,7 @@ pub fn get_about() -> String { } pub async fn get_github() -> String { - GITHUB.get_or_init(|| fetch_github()).await; + GITHUB.get_or_init(fetch_github).await; match GITHUB.get() { Some(user) => user.to_string(), @@ -49,7 +49,7 @@ pub async fn get_github() -> String { } pub async fn get_repos() -> String { - REPOS.get_or_init(|| fetch_repos()).await; + REPOS.get_or_init(fetch_repos).await; match REPOS.get() { Some(repos) => repos.to_string(), @@ -102,21 +102,18 @@ async fn fetch_github() -> String { async fn fetch_repos() -> String { match read_config() { Some(config) => { - let repos_url = format!( - "https://gh-pinned-repos-api.ysnirix.xyz/api/get/?username={}", - config.github - ); + let repos_url = format!("https://pinned.thrzl.xyz/{}", config.github); match reqwest::get(&repos_url).await { Ok(response) => { - let api_response: ApiResponse = response.json().await.unwrap(); let repos = Repos { - username: config.github, - repos: api_response.response, + repos: response.json().await.unwrap(), }; repos.formatter() } - Err(_) => String::from(FETCH_GITHUB_ERROR), + Err(e) => { + format!("Error fetching data: {:#?}", e) + } } } None => String::from(READ_JSON_ERROR), diff --git a/src/commands/fetch/formats.rs b/src/commands/fetch/formats.rs index 4a2007e..03da50d 100644 --- a/src/commands/fetch/formats.rs +++ b/src/commands/fetch/formats.rs @@ -5,10 +5,9 @@ use std::collections::HashMap; const NEOFETCH: &str = include_str!("../../../configs/neofetch.txt"); // Language icons for repos -const RUST: &str = include_str!("../../../configs/lang_icons/ferris.txt"); -const PYTHON: &str = include_str!("../../../configs/lang_icons/pythons.txt"); -const JAVASCRIPT: &str = include_str!("../../../configs/lang_icons/javascript.txt"); -const PLACEHOLDER: &str = include_str!("../../../configs/lang_icons/octocat.txt"); +const RUST: &str = include_str!("../../../configs/lang_icons/rust.txt"); +const PYTHON: &str = include_str!("../../../configs/lang_icons/python.txt"); +const GITHUB: &str = include_str!("../../../configs/lang_icons/github.txt"); pub trait Formatter { fn formatter(self) -> String; @@ -109,7 +108,7 @@ impl Formatter for Account { let created_on = &self.info.created_at[..10]; let text = format!( - r#"{}@github + r#"{}@termfolio ---------------------- Name: {} Bio: {} @@ -164,11 +163,11 @@ impl Formatter for Repos { Forks: {} "#, - repo.repo, + repo.link, repo.name, repo.description, - repo.language.color, - repo.language.name, + repo.language_color, + repo.language, repo.stars, repo.forks ); @@ -178,28 +177,13 @@ impl Formatter for Repos {
{}
{}
"#, - lang_icon(&repo.language.name), + lang_icon(&repo.language), text ) }) .collect(); - let all_link = format!( - r#"All repos - -Description: All my Github repositories."#, - self.username - ); - - let all = format!( - r#"
-
{}
-
{}
-
"#, - PLACEHOLDER, all_link - ); - - format!("{}\n{}", res.join("\n"), all) + res.join("\n") } } @@ -278,8 +262,7 @@ fn lang_icon(lang: &str) -> &str { match lang { "Rust" => RUST, "Python" | "Jupyter Notebook" => PYTHON, - "CSS" | "HTML" | "JavaScript" => JAVASCRIPT, - _ => PLACEHOLDER, + _ => GITHUB, } } diff --git a/src/commands/fetch/structs.rs b/src/commands/fetch/structs.rs index a4f7927..f97338b 100644 --- a/src/commands/fetch/structs.rs +++ b/src/commands/fetch/structs.rs @@ -71,22 +71,17 @@ pub struct ApiResponse { #[derive(Deserialize, Serialize)] pub struct Repos { - pub username: String, pub repos: Vec, } #[derive(Deserialize, Serialize, Clone)] pub struct Repository { + pub full_name: String, pub name: String, - pub repo: String, pub description: String, - pub language: Language, + pub link: String, pub stars: u16, pub forks: u16, -} - -#[derive(Deserialize, Serialize, Clone)] -pub struct Language { - pub name: String, - pub color: String, + pub language: String, + pub language_color: String, } diff --git a/src/commands/texts.rs b/src/commands/texts.rs index f9e3d89..6e06dd8 100644 --- a/src/commands/texts.rs +++ b/src/commands/texts.rs @@ -1,4 +1,4 @@ -pub const HELP: &str = r#" ________________ __ _____________ __ ________ +pub const HELP: &str = r#" ________________ __ _____________ __ ________ /_ __/ ____/ __ \/ |/ / ____/ __ \/ / / _/ __ \ / / / __/ / /_/ / /|_/ / /_ / / / / / / // / / / / / / /___/ _, _/ / / / __/ / /_/ / /____/ // /_/ / diff --git a/styles/styles.css b/styles/styles.css index 9ab84f1..1fb4d4d 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -1,8 +1,8 @@ :root { --white: #c0caf5; --black: #17171e; - --green: #4fd6be; - --red: #c53b53; + --green: #2ac3de; + --red: #bb9af7; --blue: #7aa2f7; --yellow: #ffc777; --orange: #ff757f; @@ -76,7 +76,6 @@ form { float: left; } - /* About */ .acols { @@ -115,4 +114,3 @@ form { .blocks { font-size: 35px; } -