From c0098f4efa6486b6752c308df4c2e3a953bab701 Mon Sep 17 00:00:00 2001 From: Sachith Date: Sun, 25 Feb 2024 20:04:00 +0530 Subject: [PATCH] Set max prompt limit and refactoring --- src/base/banner.rs | 20 ++------- src/base/prompt.rs | 2 +- src/base/prompt/general.rs | 9 +++- src/fetch.rs | 86 +++----------------------------------- src/fetch/formats.rs | 4 +- src/fetch/structs.rs | 78 ++++++++++++++++++++++++++++++++++ src/lib.rs | 7 +++- src/texts.rs | 8 ++-- styles/styles.css | 10 ++--- 9 files changed, 110 insertions(+), 114 deletions(-) create mode 100644 src/fetch/structs.rs diff --git a/src/base/banner.rs b/src/base/banner.rs index 231eadb..15be919 100644 --- a/src/base/banner.rs +++ b/src/base/banner.rs @@ -1,28 +1,14 @@ use leptos::{component, view, IntoView}; -pub const HELP: &str = r#" ________________ __ _____________ __ ________ - /_ __/ ____/ __ \/ |/ / ____/ __ \/ / / _/ __ \ - / / / __/ / /_/ / /|_/ / /_ / / / / / / // / / / - / / / /___/ _, _/ / / / __/ / /_/ / /____/ // /_/ / -/_/ /_____/_/ |_/_/ /_/_/ \____/_____/___/\____/ - -Hello, welcome to Termfolio. Type one of these commands - - - about - View about me - github - View about Github profile - repos - View about my pinned repos / projects - links - View contact info and links - help - View this help section - theme - Cycle through themes - credits - View credits and repo"#; - #[component] pub fn Banner() -> impl IntoView { + let banner = termfolio::banner(); + view! {

"user@termfolio:~$ "

"help"

-            
+
} } diff --git a/src/base/prompt.rs b/src/base/prompt.rs index 1e0cc92..fbf2eb8 100644 --- a/src/base/prompt.rs +++ b/src/base/prompt.rs @@ -78,7 +78,7 @@ pub fn Prompt(

"user@termfolio:~$ "

diff --git a/src/base/prompt/general.rs b/src/base/prompt/general.rs
index f8d7f07..fb35389 100644
--- a/src/base/prompt/general.rs
+++ b/src/base/prompt/general.rs
@@ -51,9 +51,14 @@ pub async fn general_commands(
         }
     });
 
+    // Clears if max limit is reached
     submitter.update(|prompts| {
-        if *prompts < u8::MAX {
-            *prompts += 1;
+        if *prompts == u8::MAX {
+            *prompts = 0;
         }
     });
+
+    submitter.update(|prompts| {
+        *prompts += 1;
+    });
 }
diff --git a/src/fetch.rs b/src/fetch.rs
index 8e8348a..ade57ff 100644
--- a/src/fetch.rs
+++ b/src/fetch.rs
@@ -1,14 +1,17 @@
-use serde::{Deserialize, Serialize};
 use std::sync::OnceLock;
 use tokio::sync::OnceCell;
 use tokio::try_join;
 
+// Formnatting functions and error messages
 mod formats;
 use crate::texts::{FETCH_GITHUB_ERROR, READ_JSON_ERROR};
 use formats::*;
 
-// Config JSON
+// Structs for JSON Parsing
+mod structs;
+use structs::*;
 
+// Config JSON
 const JSON: &str = include_str!("../configs/config.json");
 
 // Once statics
@@ -18,85 +21,6 @@ static GITHUB: OnceCell = OnceCell::const_new();
 static REPOS: OnceCell = OnceCell::const_new();
 static CONTACTS: OnceLock = OnceLock::new();
 
-// Structs
-
-#[derive(Deserialize, Serialize, Clone)]
-pub struct Config {
-    pub github: String,
-    pub about: About,
-    pub links: Links,
-}
-
-#[derive(Deserialize, Serialize, Clone)]
-pub struct About {
-    pub name: String,
-    pub intro: String,
-    pub interests: Vec,
-    pub langs: Vec,
-    pub experience: Vec,
-    pub education: Vec,
-}
-
-#[derive(Deserialize, Serialize, Clone)]
-pub struct Experience {
-    pub title: String,
-    pub description: Vec,
-}
-
-#[derive(Deserialize, Serialize, Clone)]
-pub struct Education {
-    pub institute: String,
-    pub course: String,
-    pub duration: String,
-}
-
-#[derive(Deserialize, Serialize, Clone)]
-pub struct Links {
-    pub github: String,
-    pub email: Option,
-    pub linkedin: Option,
-    pub twitter: Option,
-}
-
-#[derive(Deserialize, Serialize, Clone)]
-pub struct UserInfo {
-    pub name: Option,
-    pub bio: Option,
-    pub public_repos: u16,
-    pub company: Option,
-    pub location: Option,
-    pub followers: u16,
-    pub following: u16,
-    pub created_at: String,
-}
-
-#[derive(Deserialize, Serialize, Clone)]
-pub struct UserStats {
-    pub stars: u16,
-    pub forks: u16,
-}
-
-#[derive(Deserialize, Serialize)]
-pub struct ApiResponse {
-    pub response: Vec,
-}
-
-#[derive(Deserialize, Serialize, Clone)]
-pub struct Repository {
-    pub name: String,
-    pub repo: String,
-    pub description: String,
-    pub language: Language,
-    pub stars: u16,
-    pub forks: u16,
-}
-
-#[derive(Deserialize, Serialize, Clone)]
-pub struct Language {
-    pub name: String,
-    pub color: String,
-}
-
 // Once Functions
 
 fn read_config() -> Option {
diff --git a/src/fetch/formats.rs b/src/fetch/formats.rs
index 163d149..e905d95 100644
--- a/src/fetch/formats.rs
+++ b/src/fetch/formats.rs
@@ -169,7 +169,7 @@ pub fn format_repos(username: String, repos: Vec) -> String {
             format!(
                 r#"
{}
-
{}
+
{}
"#, lang_icon(&repo.language.name), text @@ -187,7 +187,7 @@ pub fn format_repos(username: String, repos: Vec) -> String { let all = format!( r#"
{}
-
{}
+
{}
"#, PLACEHOLDER, all_link ); diff --git a/src/fetch/structs.rs b/src/fetch/structs.rs new file mode 100644 index 0000000..a5352ff --- /dev/null +++ b/src/fetch/structs.rs @@ -0,0 +1,78 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Deserialize, Serialize, Clone)] +pub struct Config { + pub github: String, + pub about: About, + pub links: Links, +} + +#[derive(Deserialize, Serialize, Clone)] +pub struct About { + pub name: String, + pub intro: String, + pub interests: Vec, + pub langs: Vec, + pub experience: Vec, + pub education: Vec, +} + +#[derive(Deserialize, Serialize, Clone)] +pub struct Experience { + pub title: String, + pub description: Vec, +} + +#[derive(Deserialize, Serialize, Clone)] +pub struct Education { + pub institute: String, + pub course: String, + pub duration: String, +} + +#[derive(Deserialize, Serialize, Clone)] +pub struct Links { + pub github: String, + pub email: Option, + pub linkedin: Option, + pub twitter: Option, +} + +#[derive(Deserialize, Serialize, Clone)] +pub struct UserInfo { + pub name: Option, + pub bio: Option, + pub public_repos: u16, + pub company: Option, + pub location: Option, + pub followers: u16, + pub following: u16, + pub created_at: String, +} + +#[derive(Deserialize, Serialize, Clone)] +pub struct UserStats { + pub stars: u16, + pub forks: u16, +} + +#[derive(Deserialize, Serialize)] +pub struct ApiResponse { + pub response: Vec, +} + +#[derive(Deserialize, Serialize, Clone)] +pub struct Repository { + pub name: String, + pub repo: String, + pub description: String, + pub language: Language, + pub stars: u16, + pub forks: u16, +} + +#[derive(Deserialize, Serialize, Clone)] +pub struct Language { + pub name: String, + pub color: String, +} diff --git a/src/lib.rs b/src/lib.rs index 38a98fc..ec55c87 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -103,7 +103,8 @@ pub fn autocomplete(inp: &str) -> &str { let inp = inp.trim(); let comms = [ - "help", "history", "about", "github", "repos", "links", "theme", "credits", "neofetch", + "help", "history", "about", "github", "repos", "links", "theme", "wal", "credits", + "neofetch", ]; if !inp.is_empty() { @@ -116,3 +117,7 @@ pub fn autocomplete(inp: &str) -> &str { inp } + +pub fn banner() -> String { + String::from(texts::HELP) +} diff --git a/src/texts.rs b/src/texts.rs index f03854d..c3b2b7e 100644 --- a/src/texts.rs +++ b/src/texts.rs @@ -4,7 +4,6 @@ pub const HELP: &str = r#" ________________ __ ___ / / / /___/ _, _/ / / / __/ / /_/ / /____/ // /_/ / /_/ /_____/_/ |_/_/ /_/_/ \____/_____/___/\____/ - Hello, welcome to Termfolio. Type one of these commands - about - View about me @@ -22,7 +21,8 @@ pub const CREDITS: &str = r#" _____ ______________ _________ | | | |___| |\ \| | | || | \ \_/ / |_____| |_\ \_/ / \_/ \____/\_| \_\_| |_/\_| \___/\_____/\___/ \___/ -Terminal style portfolio website, made in Leptos, Rust. +Terminal style portfolio website, +made using Leptos - Rust and WASM (WebAssembly). Made by Sachith C Shetty Github: github.com/shettysach @@ -44,7 +44,9 @@ Made by Sachith C Shetty * Total stars and forks - idealclover/GitHub-Star-Counter"#; + class="blu semibold">Total stars and forks - idealclover/GitHub-Star-Counter + +"#; pub const READ_JSON_ERROR: &str = r#"Error reading config.json"#; pub const FETCH_GITHUB_ERROR: &str = diff --git a/styles/styles.css b/styles/styles.css index 7cc54dd..9a60f1d 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -13,9 +13,11 @@ * { font-family: "IBM Plex Mono"; - font-size: 20px; + font-size: 19px; background: var(--black); color: var(--white); + text-underline-offset: 8px; + text-decoration-thickness: 2px; /* text-shadow: 0px 5px 10px currentColor; */ } @@ -114,9 +116,3 @@ form { font-size: 35px; } -/* Links */ - -a { - text-decoration-thickness: 2px; - text-underline-offset: 8px; -}