Upload files to "pages"
This commit is contained in:
165
pages/api_page.html
Normal file
165
pages/api_page.html
Normal file
@@ -0,0 +1,165 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>KittyRec — API</title>
|
||||
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/static/kittyrec_icon.png">
|
||||
<link rel="apple-touch-icon" href="/static/kittyrec_icon.png">
|
||||
<style>
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
:root {
|
||||
--bg: #06050f; --bg2: #0c0a1e; --bg3: #13102e; --bg4: #1a1640;
|
||||
--purple: #8b5cf6; --purple-l: #a78bfa; --purple-d: #6d3bef;
|
||||
--teal: #2dd4bf; --green: #34d399; --yellow: #fbbf24;
|
||||
--text: #ede9fe; --text2: #a39dc8; --text3: #5c5488;
|
||||
--card-r: 20px; --gap: 20px;
|
||||
--ease: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
html { scroll-behavior: smooth; }
|
||||
body {
|
||||
background: var(--bg); color: var(--text);
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||
font-size: 14px; line-height: 1.6;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
overflow-x: hidden; padding-bottom: 80px;
|
||||
}
|
||||
a { color: var(--purple-l); text-decoration: none; transition: var(--ease); }
|
||||
a:hover { color: var(--text); }
|
||||
|
||||
.nav-wrapper {
|
||||
position: fixed; top: 24px; left: 0; right: 0; z-index: 100;
|
||||
display: flex; justify-content: center; pointer-events: none;
|
||||
}
|
||||
.nav {
|
||||
pointer-events: auto; display: flex; align-items: center; justify-content: space-between;
|
||||
background: rgba(12,10,30,0.65); backdrop-filter: blur(24px) saturate(1.2);
|
||||
border: 1px solid rgba(255,255,255,0.05); padding: 0 24px; height: 56px;
|
||||
border-radius: 100px; width: calc(100% - 48px); max-width: 1200px;
|
||||
box-shadow: 0 12px 40px rgba(0,0,0,0.2);
|
||||
}
|
||||
.nav-brand { font-size: 16px; font-weight: 800; letter-spacing: -0.5px; color: #fff; }
|
||||
.nav-links { display: flex; gap: 28px; align-items: center; }
|
||||
.nav-links a { font-size: 13px; font-weight: 500; color: var(--text2); }
|
||||
.nav-links a:hover { color: #fff; }
|
||||
.nav-links a.active { color: #fff; }
|
||||
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
|
||||
.nav-status { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text); padding-left: 12px; border-left: 1px solid rgba(255,255,255,0.1); }
|
||||
|
||||
.page-wrap { max-width: 1200px; margin: 104px auto 0; padding: 0 24px; }
|
||||
.page-head { margin-bottom: 32px; }
|
||||
.page-title { font-size: clamp(28px, 4vw, 40px); font-weight: 700; color: #fff; letter-spacing: -0.03em; }
|
||||
.page-sub { color: var(--text2); font-size: 15px; margin-top: 8px; }
|
||||
.page-info { color: var(--text3); font-size: 13px; font-weight: 600; margin-top: 4px; }
|
||||
|
||||
.api-endpoint {
|
||||
background: var(--bg2); border: 1px solid rgba(255,255,255,0.03);
|
||||
border-radius: 16px; margin-bottom: 12px; overflow: hidden;
|
||||
}
|
||||
.api-header {
|
||||
display: flex; align-items: center; gap: 12px;
|
||||
padding: 16px 20px; cursor: pointer; transition: background 0.15s;
|
||||
}
|
||||
.api-header:hover { background: rgba(255,255,255,0.02); }
|
||||
.api-method {
|
||||
font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 6px;
|
||||
font-family: 'SF Mono', 'Fira Code', monospace;
|
||||
background: rgba(45,212,191,0.12); color: var(--teal); flex-shrink: 0;
|
||||
}
|
||||
.api-path {
|
||||
font-family: 'SF Mono', 'Fira Code', monospace;
|
||||
font-size: 13px; color: #fff; font-weight: 600;
|
||||
}
|
||||
.api-name { color: var(--text3); font-size: 12px; margin-left: auto; flex-shrink: 0; }
|
||||
.api-arrow { color: var(--text3); font-size: 12px; transition: transform 0.2s; flex-shrink: 0; }
|
||||
.api-endpoint.open .api-arrow { transform: rotate(90deg); }
|
||||
.api-body {
|
||||
display: none; padding: 0 20px 20px;
|
||||
border-top: 1px solid rgba(255,255,255,0.03);
|
||||
}
|
||||
.api-endpoint.open .api-body { display: block; }
|
||||
.api-desc { color: var(--text2); font-size: 13px; padding: 16px 0 12px; line-height: 1.5; }
|
||||
.api-params { margin-bottom: 12px; }
|
||||
.api-params-title {
|
||||
font-size: 10px; font-weight: 600; color: var(--text3);
|
||||
text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px;
|
||||
}
|
||||
.api-param { display: flex; align-items: baseline; gap: 8px; font-size: 12px; padding: 4px 0; }
|
||||
.api-param-name { font-family: 'SF Mono', 'Fira Code', monospace; color: var(--purple-l); font-weight: 600; }
|
||||
.api-param-type { color: var(--text3); }
|
||||
.api-param-desc { color: var(--text2); }
|
||||
.api-param-req { color: var(--yellow); font-size: 10px; font-weight: 600; }
|
||||
.api-response-title {
|
||||
font-size: 10px; font-weight: 600; color: var(--text3);
|
||||
text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px;
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
}
|
||||
.api-response-title button {
|
||||
background: rgba(255,255,255,0.05); border: none; color: var(--text3);
|
||||
font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 4px;
|
||||
cursor: pointer; transition: color 0.15s;
|
||||
}
|
||||
.api-response-title button:hover { color: #fff; }
|
||||
.api-response {
|
||||
background: rgba(0,0,0,0.3); border-radius: 10px; padding: 14px 16px;
|
||||
font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px;
|
||||
color: var(--text2); line-height: 1.6; overflow-x: auto; white-space: pre; max-height: 300px;
|
||||
}
|
||||
|
||||
.empty { color: var(--text3); font-size: 13px; padding: 48px 0; text-align: center; }
|
||||
.hidden { display: none !important; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="nav-wrapper">
|
||||
<nav class="nav">
|
||||
<a href="/" class="nav-brand">KittyRec.</a>
|
||||
<div class="nav-links">
|
||||
<a href="/leaderboard">Leaderboard</a>
|
||||
<a href="/recnet">RecNet</a>
|
||||
<a href="/account">Account</a>
|
||||
<a href="/api-docs" class="active">API</a>
|
||||
<div class="nav-status"><span class="dot"></span> Online</div>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<div class="page-wrap">
|
||||
<div class="page-head">
|
||||
<h1 class="page-title">Public API</h1>
|
||||
<p class="page-sub">no auth needed, just hit the endpoints</p>
|
||||
<div class="page-info" id="ep-count"></div>
|
||||
</div>
|
||||
<div id="api-docs-body">
|
||||
<div class="empty">loading docs...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function esc(s) {
|
||||
return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
|
||||
}
|
||||
|
||||
async function loadApiDocs() {
|
||||
var el = document.getElementById('api-docs-body');
|
||||
try {
|
||||
var docs = await fetch('/api/public/v1/docs').then(function(r) { return r.json(); });
|
||||
if (!docs.length) { el.innerHTML = '<div class="empty">no endpoints documented</div>'; return; }
|
||||
document.getElementById('ep-count').textContent = docs.length + ' endpoints';
|
||||
el.innerHTML = docs.map(function(ep, i) {
|
||||
var resp = typeof ep.response === 'string' ? ep.response : JSON.stringify(ep.response, null, 2);
|
||||
var params = ep.params && ep.params.length ? '<div class="api-params"><div class="api-params-title">Parameters</div>' +
|
||||
ep.params.map(function(p) {
|
||||
return '<div class="api-param"><span class="api-param-name">' + esc(p.name) + '</span><span class="api-param-type">' + esc(p.type) + '</span><span class="api-param-desc">' + esc(p.description) + '</span>' + (p.required ? '<span class="api-param-req">required</span>' : '') + '</div>';
|
||||
}).join('') + '</div>' : '';
|
||||
return '<div class="api-endpoint" id="ep-' + i + '"><div class="api-header" onclick="document.getElementById(\'ep-' + i + '\').classList.toggle(\'open\')"><span class="api-method">' + esc(ep.method) + '</span><span class="api-path">' + esc(ep.path) + '</span><span class="api-name">' + esc(ep.name) + '</span><span class="api-arrow">▶</span></div><div class="api-body"><div class="api-desc">' + esc(ep.description) + '</div>' + params + '<div class="api-response-title"><span>Response</span><button onclick="event.stopPropagation(); navigator.clipboard.writeText(document.getElementById(\'resp-' + i + '\').textContent).then(function(){this.textContent=\'copied!\'; var b=this; setTimeout(function(){b.textContent=\'copy\'},1000)}.bind(this))">copy</button></div><div class="api-response" id="resp-' + i + '">' + esc(resp) + '</div></div></div>';
|
||||
}).join('');
|
||||
} catch(e) { el.innerHTML = '<div class="empty">could not load api docs</div>'; }
|
||||
}
|
||||
|
||||
loadApiDocs();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user