From 9effc1cab92950ca73c6b403e809329fbbb7ca07 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Tue, 15 Apr 2025 13:42:28 -0400 Subject: [PATCH] feat: refactor + remove trading section --- about.html | 28 +--- index.html | 36 +---- .../competitive-programming-log.html | 14 +- .../extrema-circular-buffer.html | 14 +- posts/algorithms/leetcode-daily.html | 14 +- posts/algorithms/practice-makes-perfect.html | 14 +- posts/economics/models-of-production.html | 14 +- posts/software/designing-this-website.html | 14 +- posts/software/from-github-pages-to-aws.html | 14 +- .../extrema-circular-buffer/map.cpp | 0 .../extrema-circular-buffer/monotonic.cpp | 0 .../extrema-circular-buffer/naive.cpp | 0 .../extrema-circular-buffer/ringbuffer.cpp | 0 scripts/common.js | 123 +++++++++--------- scripts/index.js | 5 +- wip.html | 26 ---- 16 files changed, 83 insertions(+), 233 deletions(-) rename posts/{trading => algorithms}/extrema-circular-buffer.html (96%) rename public/code/{trading => algorithms}/extrema-circular-buffer/map.cpp (100%) rename public/code/{trading => algorithms}/extrema-circular-buffer/monotonic.cpp (100%) rename public/code/{trading => algorithms}/extrema-circular-buffer/naive.cpp (100%) rename public/code/{trading => algorithms}/extrema-circular-buffer/ringbuffer.cpp (100%) delete mode 100644 wip.html diff --git a/about.html b/about.html index ec68d5d..4ac35a4 100644 --- a/about.html +++ b/about.html @@ -11,23 +11,7 @@ Barrett Ruth -
- -
- barrett@ruth:~$ /about - -
-
- -
+
@@ -69,15 +53,7 @@
- + diff --git a/index.html b/index.html index d24613c..c97a39c 100644 --- a/index.html +++ b/index.html @@ -10,48 +10,24 @@ Barrett Ruth -
- -
- barrett@ruth:~$ - -
-
- -
+
- + diff --git a/posts/algorithms/competitive-programming-log.html b/posts/algorithms/competitive-programming-log.html index cd37c7d..2b7ceec 100644 --- a/posts/algorithms/competitive-programming-log.html +++ b/posts/algorithms/competitive-programming-log.html @@ -17,18 +17,7 @@ Barrett Ruth -
- -
- barrett@ruth:~$ /algorithms - -
-
-
+
@@ -1145,6 +1134,7 @@
+ diff --git a/posts/trading/extrema-circular-buffer.html b/posts/algorithms/extrema-circular-buffer.html similarity index 96% rename from posts/trading/extrema-circular-buffer.html rename to posts/algorithms/extrema-circular-buffer.html index 940579b..1ee9ed5 100644 --- a/posts/trading/extrema-circular-buffer.html +++ b/posts/algorithms/extrema-circular-buffer.html @@ -17,18 +17,7 @@ Barrett Ruth -
- -
- barrett@ruth:~$ /algorithms - -
-
-
+
@@ -219,6 +208,7 @@
+ diff --git a/posts/algorithms/leetcode-daily.html b/posts/algorithms/leetcode-daily.html index f494789..2ca5d9f 100644 --- a/posts/algorithms/leetcode-daily.html +++ b/posts/algorithms/leetcode-daily.html @@ -17,18 +17,7 @@ Barrett Ruth -
- -
- barrett@ruth:~$ /algorithms - -
-
-
+
@@ -638,6 +627,7 @@
+ diff --git a/posts/algorithms/practice-makes-perfect.html b/posts/algorithms/practice-makes-perfect.html index 46a4a52..0aadf9c 100644 --- a/posts/algorithms/practice-makes-perfect.html +++ b/posts/algorithms/practice-makes-perfect.html @@ -17,18 +17,7 @@ Barrett Ruth -
- -
- barrett@ruth:~$ /algorithms - -
-
-
+
@@ -114,6 +103,7 @@
+ diff --git a/posts/economics/models-of-production.html b/posts/economics/models-of-production.html index 36544f2..33d7d7f 100644 --- a/posts/economics/models-of-production.html +++ b/posts/economics/models-of-production.html @@ -16,18 +16,7 @@ Barrett Ruth -
- -
- barrett@ruth:~$ /economics - -
-
-
+
@@ -916,6 +905,7 @@
+ diff --git a/posts/software/designing-this-website.html b/posts/software/designing-this-website.html index fd3c802..a4c14b2 100644 --- a/posts/software/designing-this-website.html +++ b/posts/software/designing-this-website.html @@ -10,18 +10,7 @@ Barrett Ruth -
- -
- barrett@ruth:~$ /software - -
-
-
+
@@ -99,6 +88,7 @@
+ diff --git a/posts/software/from-github-pages-to-aws.html b/posts/software/from-github-pages-to-aws.html index b299751..dcac281 100644 --- a/posts/software/from-github-pages-to-aws.html +++ b/posts/software/from-github-pages-to-aws.html @@ -10,18 +10,7 @@ Barrett Ruth -
- -
- barrett@ruth:~$ /software - -
-
-
+
@@ -148,6 +137,7 @@
+ diff --git a/public/code/trading/extrema-circular-buffer/map.cpp b/public/code/algorithms/extrema-circular-buffer/map.cpp similarity index 100% rename from public/code/trading/extrema-circular-buffer/map.cpp rename to public/code/algorithms/extrema-circular-buffer/map.cpp diff --git a/public/code/trading/extrema-circular-buffer/monotonic.cpp b/public/code/algorithms/extrema-circular-buffer/monotonic.cpp similarity index 100% rename from public/code/trading/extrema-circular-buffer/monotonic.cpp rename to public/code/algorithms/extrema-circular-buffer/monotonic.cpp diff --git a/public/code/trading/extrema-circular-buffer/naive.cpp b/public/code/algorithms/extrema-circular-buffer/naive.cpp similarity index 100% rename from public/code/trading/extrema-circular-buffer/naive.cpp rename to public/code/algorithms/extrema-circular-buffer/naive.cpp diff --git a/public/code/trading/extrema-circular-buffer/ringbuffer.cpp b/public/code/algorithms/extrema-circular-buffer/ringbuffer.cpp similarity index 100% rename from public/code/trading/extrema-circular-buffer/ringbuffer.cpp rename to public/code/algorithms/extrema-circular-buffer/ringbuffer.cpp diff --git a/scripts/common.js b/scripts/common.js index 5929478..726da65 100644 --- a/scripts/common.js +++ b/scripts/common.js @@ -1,73 +1,72 @@ const TERMINAL_PROMPT = "barrett@ruth:~$ "; let clearing = false; -document.addEventListener("DOMContentLoaded", function () { - const header = document.querySelector("header"); - if (header) { - let headerLinks = header.querySelector(".header-links"); - if (!headerLinks) { - headerLinks = document.createElement("div"); - headerLinks.className = "header-links"; - header.appendChild(headerLinks); +// Define the Header component +class SiteHeader extends HTMLElement { + connectedCallback() { + const path = window.location.pathname; + const isHome = path === "/" || path === "/index.html"; + const topic = this.getTopic(); + + const promptText = isHome + ? "barrett@ruth:~$" + : `barrett@ruth:~$ ${topic}`; + + const clickHandler = isHome + ? "refresh(event)" + : "goHome(event)"; + + this.innerHTML = ` +
+ +
+ ${promptText} + +
+
+ +
+ `; + } + + getTopic() { + const pathname = window.location.pathname.split("/"); + if (pathname.includes("about.html")) { + return "/about"; + } else if (pathname.length >= 3) { + return `/${pathname[1]}`; } - - headerLinks.innerHTML = ""; - - const resumeLink = document.createElement("a"); - resumeLink.href = "/public/resume.pdf"; - resumeLink.target = "_blank"; - resumeLink.textContent = "Resume"; - headerLinks.appendChild(resumeLink); - - const transcriptLink = document.createElement("a"); - transcriptLink.href = "/public/transcript.pdf"; - transcriptLink.target = "_blank"; - transcriptLink.textContent = "Transcript"; - headerLinks.appendChild(transcriptLink); - - const aboutLink = document.createElement("a"); - aboutLink.href = "/about.html"; - aboutLink.textContent = "About"; - headerLinks.appendChild(aboutLink); + return ""; } +} - const existingFooter = document.querySelector("footer"); - if (existingFooter) { - existingFooter.remove(); +// Define the Footer component +class SiteFooter extends HTMLElement { + connectedCallback() { + this.innerHTML = ` + + `; } +} - const footer = document.createElement("footer"); - - const deltaSpan = document.createElement("span"); - deltaSpan.className = "greek-delta"; - deltaSpan.innerHTML = "Δ"; - - const footerLinks = document.createElement("div"); - footerLinks.className = "footer-links"; - - const githubLink = document.createElement("a"); - githubLink.href = "https://github.com/barrett-ruth/"; - githubLink.target = "_blank"; - githubLink.textContent = "GitHub"; - footerLinks.appendChild(githubLink); - - const linkedinLink = document.createElement("a"); - linkedinLink.href = "https://www.linkedin.com/in/barrett-ruth/"; - linkedinLink.target = "_blank"; - linkedinLink.textContent = "LinkedIn"; - footerLinks.appendChild(linkedinLink); - - const emailLink = document.createElement("a"); - emailLink.href = "mailto:br.barrettruth@gmail.com"; - emailLink.target = "_blank"; - emailLink.textContent = "Email"; - footerLinks.appendChild(emailLink); - - footer.appendChild(deltaSpan); - footer.appendChild(footerLinks); - - document.body.appendChild(footer); +// Register the custom elements +customElements.define('site-header', SiteHeader); +customElements.define('site-footer', SiteFooter); +// Add styles once when DOM is loaded +document.addEventListener("DOMContentLoaded", function () { + // Add dynamic styles if they don't exist if (!document.querySelector("style#dynamic-styles")) { const style = document.createElement("style"); style.id = "dynamic-styles"; @@ -129,8 +128,6 @@ const getTopicColor = (topicName) => { return "#0073e6"; case "economics": return "#009975"; - case "trading": - return "#d50032"; case "algorithms": return "#6a0dad"; default: diff --git a/scripts/index.js b/scripts/index.js index ecf3db4..4c179b1 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -11,10 +11,6 @@ const postMapping = new Map([ "Economics", [{ name: "models of production", link: "models-of-production" }], ], - [ - "Trading", - [{ name: "extrema circular buffer", link: "extrema-circular-buffer" }], - ], [ "Algorithms", [ @@ -24,6 +20,7 @@ const postMapping = new Map([ }, { name: "leetcode daily", link: "leetcode-daily" }, { name: "practice makes perfect", link: "practice-makes-perfect" }, + { name: "extrema circular buffer", link: "extrema-circular-buffer" }, ], ], ]); diff --git a/wip.html b/wip.html deleted file mode 100644 index 50b0d25..0000000 --- a/wip.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - Barrett Ruth - - -
-
- wip -
-
- -