Spaces:
Sleeping
Sleeping
Update static/index.html
Browse files- static/index.html +63 -171
static/index.html
CHANGED
|
@@ -4,218 +4,110 @@
|
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>Aditya | DevLog</title>
|
| 7 |
-
<link
|
| 8 |
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 9 |
-
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300;400;500;700&display=swap" rel="stylesheet">
|
| 10 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/base16/ia-dark.min.css">
|
| 11 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
|
| 12 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/11.1.1/marked.min.js"></script>
|
| 13 |
<style>
|
| 14 |
-
:root {
|
| 15 |
-
|
| 16 |
-
--text-color: #f3f2ec;
|
| 17 |
-
--accent-color: #e0e0e0;
|
| 18 |
-
--shadow-color: #f3f2ec;
|
| 19 |
-
--border-weight: 1px;
|
| 20 |
-
}
|
| 21 |
-
|
| 22 |
-
.light-mode {
|
| 23 |
-
--bg-color: #f3f2ec;
|
| 24 |
-
--text-color: #1c1c1c;
|
| 25 |
-
--accent-color: #333;
|
| 26 |
-
--shadow-color: #1c1c1c;
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
* { margin: 0; padding: 0; box-sizing: border-box; }
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
line-height: 1.6;
|
| 36 |
-
transition: background-color 0.4s ease, color 0.4s ease;
|
| 37 |
}
|
| 38 |
-
|
| 39 |
.container { max-width: 800px; margin: 0 auto; padding: 60px 24px; }
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
h1 { font-size: 2.5rem; text-transform: uppercase; font-weight: 700; letter-spacing: -2px; margin-bottom: 8px; }
|
| 48 |
-
.subtitle { font-size: 1rem; opacity: 0.8; margin-bottom: 32px; }
|
| 49 |
-
|
| 50 |
-
nav { display: flex; justify-content: space-between; align-items: center; }
|
| 51 |
-
.nav-links { display: flex; gap: 24px; }
|
| 52 |
-
nav a { color: var(--text-color); text-decoration: none; font-weight: 700; font-size: 0.9rem; text-transform: uppercase; padding: 4px 0; border-bottom: 2px solid transparent; }
|
| 53 |
-
nav a.active { border-bottom: 2px solid var(--text-color); }
|
| 54 |
-
|
| 55 |
-
.theme-toggle {
|
| 56 |
-
background: none; border: var(--border-weight) solid var(--text-color);
|
| 57 |
-
color: var(--text-color); padding: 4px 12px; cursor: pointer;
|
| 58 |
-
font-family: inherit; font-size: 0.8rem; text-transform: uppercase;
|
| 59 |
}
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
padding: 32px; margin-bottom: 32px; background: transparent;
|
| 64 |
-
cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease;
|
| 65 |
}
|
| 66 |
-
|
| 67 |
-
.
|
| 68 |
-
.
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
.back-btn {
|
| 72 |
-
display: inline-block; color: var(--text-color); text-decoration: none;
|
| 73 |
-
margin-bottom: 40px; font-weight: 700; text-transform: uppercase; font-size: 0.8rem; cursor: pointer;
|
| 74 |
-
}
|
| 75 |
-
|
| 76 |
-
.article-content { font-size: 1.05rem; }
|
| 77 |
-
.article-content h1, .article-content h2 { margin: 40px 0 20px; text-transform: uppercase; }
|
| 78 |
-
.article-content p { margin-bottom: 20px; }
|
| 79 |
-
|
| 80 |
-
pre {
|
| 81 |
-
background: #000 !important; color: #fff !important;
|
| 82 |
-
padding: 24px; border: var(--border-weight) solid var(--text-color);
|
| 83 |
-
overflow-x: auto; margin: 24px 0;
|
| 84 |
-
}
|
| 85 |
-
|
| 86 |
-
.loading { text-align: center; padding: 40px; text-transform: uppercase; opacity: 0.6; }
|
| 87 |
-
|
| 88 |
-
@media (max-width: 600px) {
|
| 89 |
-
.container { padding: 40px 16px; }
|
| 90 |
-
nav { flex-direction: column; gap: 24px; align-items: flex-start; }
|
| 91 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
</style>
|
| 93 |
</head>
|
| 94 |
<body>
|
| 95 |
<div class="container">
|
| 96 |
<header>
|
| 97 |
<h1>Aditya</h1>
|
| 98 |
-
<p
|
| 99 |
<nav>
|
| 100 |
-
<
|
| 101 |
-
<a href="/" class="active">/Articles</a>
|
| 102 |
-
</div>
|
| 103 |
<button class="theme-toggle" id="themeToggle">Switch_Mode</button>
|
| 104 |
</nav>
|
| 105 |
</header>
|
| 106 |
-
|
| 107 |
<main>
|
| 108 |
-
<div id="
|
| 109 |
-
<div id="
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
<div id="
|
| 114 |
-
<span class="back-btn" id="backBtn">← Return_to_List</span>
|
| 115 |
-
<div id="articleContent"></div>
|
| 116 |
-
</div>
|
| 117 |
</div>
|
| 118 |
</main>
|
| 119 |
</div>
|
| 120 |
-
|
| 121 |
<script>
|
| 122 |
-
const
|
| 123 |
|
| 124 |
-
// Theme Toggle
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
const toggleTheme = () => {
|
| 129 |
-
const isLight = body.classList.toggle('light-mode');
|
| 130 |
localStorage.setItem('theme', isLight ? 'light' : 'dark');
|
| 131 |
-
themeToggle.textContent = isLight ? 'Mode:Dark' : 'Mode:Light';
|
| 132 |
};
|
|
|
|
| 133 |
|
| 134 |
-
themeToggle.addEventListener('click', toggleTheme);
|
| 135 |
-
if (localStorage.getItem('theme') === 'light') {
|
| 136 |
-
body.classList.add('light-mode');
|
| 137 |
-
themeToggle.textContent = 'Mode:Dark';
|
| 138 |
-
}
|
| 139 |
-
|
| 140 |
-
// Fetch and Render Articles
|
| 141 |
async function loadArticles() {
|
| 142 |
-
const
|
| 143 |
try {
|
| 144 |
-
const
|
| 145 |
-
const
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
listElement.innerHTML = articles.map(article => `
|
| 153 |
-
<div class="article-card" onclick="loadSingleArticle('${article.slug}')">
|
| 154 |
-
<div class="article-meta">
|
| 155 |
-
${new Date(article.created_at).toLocaleDateString()} // ${article.tags.join(', ')}
|
| 156 |
-
</div>
|
| 157 |
-
<h2>${article.title}</h2>
|
| 158 |
-
<p class="article-excerpt">${article.excerpt || 'Read the full entry...'}</p>
|
| 159 |
</div>
|
| 160 |
`).join('');
|
| 161 |
-
} catch
|
| 162 |
-
listElement.innerHTML = '<div class="loading">✗ Error_Connection_Failed</div>';
|
| 163 |
-
}
|
| 164 |
}
|
| 165 |
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
const
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
listPage.style.display = 'none';
|
| 173 |
-
fullPage.style.display = 'block';
|
| 174 |
-
contentDiv.innerHTML = '<div class="loading">Decoding_Buffer...</div>';
|
| 175 |
-
|
| 176 |
try {
|
| 177 |
-
|
| 178 |
-
const
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
throw new Error(`Server responded with ${response.status}`);
|
| 184 |
-
}
|
| 185 |
-
|
| 186 |
-
const article = await response.json();
|
| 187 |
-
|
| 188 |
-
contentDiv.innerHTML = `
|
| 189 |
-
<div class="article-meta">${new Date(article.created_at).toLocaleDateString()}</div>
|
| 190 |
-
<h1 style="margin-bottom: 30px; text-transform: uppercase;">${article.title}</h1>
|
| 191 |
-
<div class="article-content">${marked.parse(article.content)}</div>
|
| 192 |
`;
|
| 193 |
-
|
| 194 |
-
// Syntax highlighting
|
| 195 |
-
contentDiv.querySelectorAll('pre code').forEach((block) => {
|
| 196 |
-
hljs.highlightElement(block);
|
| 197 |
-
});
|
| 198 |
-
|
| 199 |
-
// Scroll to top
|
| 200 |
window.scrollTo(0, 0);
|
| 201 |
-
|
| 202 |
-
} catch (error) {
|
| 203 |
-
console.error("Frontend Fetch Error:", error);
|
| 204 |
-
contentDiv.innerHTML = `
|
| 205 |
-
<div class="loading">
|
| 206 |
-
✗ ERROR_DECODING_FAILED<br>
|
| 207 |
-
<span style="font-size: 0.7rem; opacity: 0.5;">[ ${error.message} ]</span>
|
| 208 |
-
</div>`;
|
| 209 |
-
}
|
| 210 |
}
|
| 211 |
|
| 212 |
-
// Back Button Logic
|
| 213 |
-
document.getElementById('backBtn').addEventListener('click', () => {
|
| 214 |
-
document.getElementById('articleList').style.display = 'block';
|
| 215 |
-
document.getElementById('articleFull').style.display = 'none';
|
| 216 |
-
});
|
| 217 |
-
|
| 218 |
-
// Initialize on load
|
| 219 |
loadArticles();
|
| 220 |
</script>
|
| 221 |
</body>
|
|
|
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>Aditya | DevLog</title>
|
| 7 |
+
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;700&display=swap" rel="stylesheet">
|
|
|
|
|
|
|
| 8 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/base16/ia-dark.min.css">
|
| 9 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
|
| 10 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/11.1.1/marked.min.js"></script>
|
| 11 |
<style>
|
| 12 |
+
:root { --bg-color: #1A1A1D; --text-color: #f3f2ec; --shadow-color: #f3f2ec; }
|
| 13 |
+
.light-mode { --bg-color: #f3f2ec; --text-color: #1c1c1c; --shadow-color: #1c1c1c; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
* { margin: 0; padding: 0; box-sizing: border-box; }
|
| 15 |
+
body {
|
| 16 |
+
font-family: "Roboto Mono", monospace;
|
| 17 |
+
background-color: var(--bg-color);
|
| 18 |
+
color: var(--text-color);
|
| 19 |
+
transition: 0.4s;
|
| 20 |
line-height: 1.6;
|
|
|
|
| 21 |
}
|
|
|
|
| 22 |
.container { max-width: 800px; margin: 0 auto; padding: 60px 24px; }
|
| 23 |
+
header { border-bottom: 1px solid var(--text-color); padding-bottom: 30px; margin-bottom: 50px; }
|
| 24 |
+
h1 { font-size: 2.5rem; text-transform: uppercase; letter-spacing: -2px; }
|
| 25 |
+
nav { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }
|
| 26 |
+
.theme-toggle {
|
| 27 |
+
background: none; border: 1px solid var(--text-color);
|
| 28 |
+
color: var(--text-color); padding: 4px 12px; cursor: pointer;
|
| 29 |
+
text-transform: uppercase; font-size: 0.7rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
}
|
| 31 |
+
.article-card {
|
| 32 |
+
border: 1px solid var(--text-color); padding: 30px; margin-bottom: 30px;
|
| 33 |
+
cursor: pointer; transition: 0.2s;
|
|
|
|
|
|
|
| 34 |
}
|
| 35 |
+
.article-card:hover { transform: translate(-4px, -4px); box-shadow: 6px 6px 0 var(--shadow-color); }
|
| 36 |
+
.meta { font-size: 0.8rem; opacity: 0.6; text-transform: uppercase; margin-bottom: 8px; }
|
| 37 |
+
.back-btn {
|
| 38 |
+
cursor: pointer; text-transform: uppercase; font-weight: 700;
|
| 39 |
+
font-size: 0.8rem; margin-bottom: 40px; display: inline-block;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
}
|
| 41 |
+
pre { background: #000 !important; padding: 20px; border: 1px solid var(--text-color); overflow-x: auto; margin: 24px 0; }
|
| 42 |
+
.loading { text-align: center; padding: 50px; opacity: 0.6; text-transform: uppercase; }
|
| 43 |
+
.markdown-body { font-size: 1.1rem; }
|
| 44 |
+
.markdown-body h1, .markdown-body h2 { margin: 40px 0 20px; text-transform: uppercase; }
|
| 45 |
</style>
|
| 46 |
</head>
|
| 47 |
<body>
|
| 48 |
<div class="container">
|
| 49 |
<header>
|
| 50 |
<h1>Aditya</h1>
|
| 51 |
+
<p>// AI Research & Backend Engineer</p>
|
| 52 |
<nav>
|
| 53 |
+
<a href="/" style="color: var(--text-color); text-decoration: none; font-weight: 700;">/Articles</a>
|
|
|
|
|
|
|
| 54 |
<button class="theme-toggle" id="themeToggle">Switch_Mode</button>
|
| 55 |
</nav>
|
| 56 |
</header>
|
|
|
|
| 57 |
<main>
|
| 58 |
+
<div id="listView">
|
| 59 |
+
<div id="articleContainer" class="loading">Initializing_Buffer...</div>
|
| 60 |
+
</div>
|
| 61 |
+
<div id="singleView" style="display: none;">
|
| 62 |
+
<span class="back-btn" onclick="location.reload()">← Return_to_List</span>
|
| 63 |
+
<div id="articleContent"></div>
|
|
|
|
|
|
|
|
|
|
| 64 |
</div>
|
| 65 |
</main>
|
| 66 |
</div>
|
|
|
|
| 67 |
<script>
|
| 68 |
+
const API = '/api';
|
| 69 |
|
| 70 |
+
// Theme Toggle
|
| 71 |
+
document.getElementById('themeToggle').onclick = () => {
|
| 72 |
+
const isLight = document.body.classList.toggle('light-mode');
|
|
|
|
|
|
|
|
|
|
| 73 |
localStorage.setItem('theme', isLight ? 'light' : 'dark');
|
|
|
|
| 74 |
};
|
| 75 |
+
if(localStorage.getItem('theme') === 'light') document.body.classList.add('light-mode');
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
async function loadArticles() {
|
| 78 |
+
const container = document.getElementById('articleContainer');
|
| 79 |
try {
|
| 80 |
+
const res = await fetch(`${API}/articles`);
|
| 81 |
+
const data = await res.json();
|
| 82 |
+
if(data.length === 0) { container.innerHTML = "// NO_ENTRIES_FOUND"; return; }
|
| 83 |
+
container.innerHTML = data.map(a => `
|
| 84 |
+
<div class="article-card" onclick="loadSingle('${a.slug}')">
|
| 85 |
+
<div class="meta">${new Date(a.created_at).toLocaleDateString()} // ${a.tags.join(' ')}</div>
|
| 86 |
+
<h2 style="text-transform: uppercase;">${a.title}</h2>
|
| 87 |
+
<p style="opacity: 0.7; margin-top: 10px;">${a.excerpt || 'READ_MORE...'}</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
</div>
|
| 89 |
`).join('');
|
| 90 |
+
} catch { container.innerHTML = "✗ ERROR_LOADING_STREAM"; }
|
|
|
|
|
|
|
| 91 |
}
|
| 92 |
|
| 93 |
+
async function loadSingle(slug) {
|
| 94 |
+
document.getElementById('listView').style.display = 'none';
|
| 95 |
+
document.getElementById('singleView').style.display = 'block';
|
| 96 |
+
const content = document.getElementById('articleContent');
|
| 97 |
+
content.innerHTML = '<div class="loading">Decoding...</div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
try {
|
| 99 |
+
const res = await fetch(`${API}/articles/${encodeURIComponent(slug)}`);
|
| 100 |
+
const a = await res.json();
|
| 101 |
+
content.innerHTML = `
|
| 102 |
+
<div class="meta">${new Date(a.created_at).toLocaleDateString()}</div>
|
| 103 |
+
<h1 style="text-transform: uppercase; margin-bottom: 20px;">${a.title}</h1>
|
| 104 |
+
<div class="markdown-body">${marked.parse(a.content)}</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
`;
|
| 106 |
+
content.querySelectorAll('pre code').forEach(el => hljs.highlightElement(el));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
window.scrollTo(0, 0);
|
| 108 |
+
} catch { content.innerHTML = '<div class="loading">✗ ERROR_DECODING_FAILED</div>'; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
}
|
| 110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
loadArticles();
|
| 112 |
</script>
|
| 113 |
</body>
|