Skip to content

Commit

Permalink
font change, few fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shettysach committed Aug 25, 2024
1 parent d0a121f commit 3664c5f
Show file tree
Hide file tree
Showing 11 changed files with 208 additions and 223 deletions.
17 changes: 0 additions & 17 deletions configs/lang_icons/javascript.txt

This file was deleted.

35 changes: 19 additions & 16 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<title>Termfolio</title>
<link data-trunk rel="icon" href="./styles/favicon.ico" type="image/ico" />

<head>
<title>Termfolio</title>
<link data-trunk rel="icon" href="./styles/favicon.ico" type="image/ico" />
<meta
http-equiv="Permissions-Policy"
content="interest-cohort=(), user-id=()"
/>
<meta name="viewport" content="width=device-width, initial-scale=1" />

<meta http-equiv="Permissions-Policy" content="interest-cohort=(), user-id=()" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link data-trunk rel="css" href="./styles/styles.css" />
<link data-trunk rel="css" href="./styles/themes.css" />

<link data-trunk rel="css" href="./styles/styles.css">
<link data-trunk rel="css" href="./styles/themes.css">

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&display=swap" rel="stylesheet">
</head>

<body>
</body>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&display=swap"
rel="stylesheet"
/>
</head>

<body></body>
</html>
4 changes: 2 additions & 2 deletions src/base/banner.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::commands::banner;
use crate::commands::{banner, get_prompt};
use leptos::{component, view, IntoView};

#[component]
pub fn Banner() -> impl IntoView {
let banner = banner();

view! {
<p class="inline">"user@termfolio:~$ "</p>
<p class="inline">{get_prompt}</p>
<p style="display:inline;padding:2px;">"help"</p>
<pre>
<div class="output" inner_html={banner}></div>
Expand Down
23 changes: 12 additions & 11 deletions src/base/prompt.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
use leptos::ev::SubmitEvent;
use leptos::html::{Form, Input};
use leptos::{
component, create_effect, create_node_ref, create_signal, spawn_local, view, IntoView, NodeRef,
ReadSignal, WriteSignal,
};
use std::collections::VecDeque;

mod general;
use general::general_commands;
mod keyboard;
use keyboard::keyboard_commands;
mod themes;

use crate::commands::get_prompt;
use general::general_commands;
use keyboard::keyboard_commands;
use leptos::{
component, create_effect, create_node_ref, create_signal,
ev::SubmitEvent,
html::{Form, Input},
spawn_local, view, IntoView, NodeRef, ReadSignal, WriteSignal,
};
use std::collections::VecDeque;
use themes::theme_changer;

#[component]
Expand Down Expand Up @@ -75,7 +76,7 @@ pub fn Prompt(
<form
id="prompt-form"
on:submit=on_submit node_ref=form_element>
<p class="inline">"user@termfolio:~$ "</p>
<p class="inline">{get_prompt()}</p>
<input
id="prompt-form" autocomplete="off"
class="inp" type="text" maxlength=38 spellcheck="false"
Expand Down
18 changes: 10 additions & 8 deletions src/base/prompt/keyboard.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use crate::commands::autocomplete;
use leptos::ev::{keydown, KeyboardEvent};
use leptos::html::Input;
use leptos::{NodeRef, ReadSignal, SignalGetUntracked, SignalUpdate, WriteSignal};
use leptos::{
ev::{keydown, KeyboardEvent},
html::Input,
{NodeRef, ReadSignal, SignalGetUntracked, SignalUpdate, WriteSignal},
};
use leptos_use::use_event_listener;
use std::collections::VecDeque;
use std::{cmp::Ordering, collections::VecDeque};

pub fn keyboard_commands(
input_element: NodeRef<Input>,
Expand All @@ -28,10 +30,10 @@ pub fn keyboard_commands(
}
//Next command in history
"ArrowDown" => {
if index > 1 {
inp.set_value(&hist[index - 2]);
} else if index == 1 {
inp.set_value("");
match index.cmp(&1) {
Ordering::Greater => inp.set_value(&hist[index - 2]),
Ordering::Equal => inp.set_value(""),
Ordering::Less => (), // No action needed if index < 1
}
set_history_index.update(|history_index| *history_index -= 1);
}
Expand Down
5 changes: 3 additions & 2 deletions src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod fetch;
mod texts;
pub use fetch::get_prompt;

pub enum Command {
Help,
Expand All @@ -17,7 +18,7 @@ impl Command {
"help" | "termfolio" => Self::Help,
"about" => Self::About,
"github" | "neofetch" => Self::Github,
"repos" | "projects" => Self::Repos,
"repos" | "onefetch" => Self::Repos,
"links" => Self::Links,
"credits" => Self::Credits,
_ => Command::Bash(Bash::from(inp0, inp1)),
Expand Down Expand Up @@ -104,7 +105,7 @@ pub fn autocomplete(inp: &str) -> &str {

let comms = [
"help", "history", "about", "github", "repos", "links", "theme", "wal", "credits",
"neofetch",
"onefetch", "neofetch",
];

if !inp.is_empty() {
Expand Down
38 changes: 20 additions & 18 deletions src/commands/fetch.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
use super::texts::{FETCH_GITHUB_ERROR, READ_JSON_ERROR};
use formats::*;
use std::sync::OnceLock;
use structs::*;
use tokio::sync::OnceCell;
use tokio::try_join;

// Formnatting functions and error messages
mod formats;
use super::texts::{FETCH_GITHUB_ERROR, READ_JSON_ERROR};
use formats::*;

// Structs for JSON Parsing
mod structs;
use structs::*;

// Config JSON
const JSON: &str = include_str!("../../configs/config.json");

// Once statics

static CONFIG: OnceLock<Option<Config>> = OnceLock::new();
static PROMPT: OnceLock<String> = OnceLock::new();
static GITHUB: OnceCell<String> = OnceCell::const_new();
static REPOS: OnceCell<String> = OnceCell::const_new();
static CONTACTS: OnceLock<String> = OnceLock::new();
Expand All @@ -32,9 +29,18 @@ fn read_config() -> Option<Config> {
CONFIG.get().cloned()?
}

pub fn get_prompt() -> String {
PROMPT.get_or_init(|| match read_config() {
Some(config) => format!("{}@termfolio~$ ", config.github),
_ => String::from("user@termfolio~$ "),
});

PROMPT.get().cloned().unwrap()
}

pub fn get_about() -> String {
match read_config() {
Some(config) => config.about.formatter(),
Some(config) => format_about(config.about),
_ => String::from(READ_JSON_ERROR),
}
}
Expand All @@ -59,7 +65,7 @@ pub async fn get_repos() -> String {

pub fn get_contacts() -> &'static String {
CONTACTS.get_or_init(|| match read_config() {
Some(config) => config.links.formatter(),
Some(config) => format_links(config.links),
_ => String::from(READ_JSON_ERROR),
})
}
Expand All @@ -80,14 +86,14 @@ async fn fetch_github() -> String {
}) {
Ok((info_response, stats_response)) => {
if info_response.status().is_success() && stats_response.status().is_success() {
let account = Account {
let profile = Profile {
username: config.github,
langs: config.about.langs,
info: info_response.json().await.unwrap(),
stats: stats_response.json().await.unwrap(),
};

account.formatter()
format_profile(profile)
} else {
String::from(FETCH_GITHUB_ERROR)
}
Expand All @@ -106,14 +112,10 @@ async fn fetch_repos() -> String {

match reqwest::get(&repos_url).await {
Ok(response) => {
let repos = Repos {
repos: response.json().await.unwrap(),
};
repos.formatter()
}
Err(e) => {
format!("Error fetching data: {:#?}", e)
let repos: Vec<Repository> = response.json().await.unwrap();
format_repos(&repos)
}
Err(_) => String::from(FETCH_GITHUB_ERROR),
}
}
None => String::from(READ_JSON_ERROR),
Expand Down
Loading

0 comments on commit 3664c5f

Please sign in to comment.