init
This commit is contained in:
commit
0aee105835
9 changed files with 2017 additions and 0 deletions
64
public/app.js
Normal file
64
public/app.js
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
const form = document.getElementById("job-form");
|
||||
const filesInput = document.getElementById("files");
|
||||
const promptInput = document.getElementById("prompt");
|
||||
const statusBox = document.getElementById("status");
|
||||
const resultBox = document.getElementById("result");
|
||||
const submitButton = document.getElementById("submit-button");
|
||||
const fileList = document.getElementById("file-list");
|
||||
|
||||
function setStatus(kind, message) {
|
||||
statusBox.className = `status ${kind}`;
|
||||
statusBox.textContent = message;
|
||||
}
|
||||
|
||||
function renderFiles() {
|
||||
fileList.innerHTML = "";
|
||||
|
||||
for (const file of filesInput.files) {
|
||||
const pill = document.createElement("div");
|
||||
pill.className = "file-pill";
|
||||
pill.textContent = `${file.name} (${Math.round(file.size / 1024)} KB)`;
|
||||
fileList.appendChild(pill);
|
||||
}
|
||||
}
|
||||
|
||||
filesInput.addEventListener("change", renderFiles);
|
||||
|
||||
form.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
resultBox.hidden = true;
|
||||
resultBox.innerHTML = "";
|
||||
submitButton.disabled = true;
|
||||
setStatus("busy", "Uploading files and processing them. This can take a little while.");
|
||||
|
||||
try {
|
||||
const payload = new FormData();
|
||||
for (const file of filesInput.files) {
|
||||
payload.append("files", file);
|
||||
}
|
||||
payload.append("prompt", promptInput.value.trim());
|
||||
|
||||
const response = await fetch("/api/process", {
|
||||
method: "POST",
|
||||
body: payload,
|
||||
});
|
||||
|
||||
const body = await response.json();
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(body.error || "The request failed.");
|
||||
}
|
||||
|
||||
setStatus("success", "Result ready.");
|
||||
resultBox.hidden = false;
|
||||
resultBox.innerHTML = `
|
||||
<strong>Result ready.</strong>
|
||||
<a href="${body.downloadUrl}">Download ${body.resultFile}</a>
|
||||
`;
|
||||
} catch (error) {
|
||||
setStatus("error", error.message);
|
||||
} finally {
|
||||
submitButton.disabled = false;
|
||||
}
|
||||
});
|
||||
56
public/index.html
Normal file
56
public/index.html
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Convertoor</title>
|
||||
<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=Space+Grotesk:wght@400;500;700&family=IBM+Plex+Mono:wght@400;500&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<link rel="stylesheet" href="/styles.css" />
|
||||
</head>
|
||||
<body>
|
||||
<main class="shell">
|
||||
<section class="hero">
|
||||
<p class="eyebrow">Media editing tool</p>
|
||||
<h1>Describe the media transformation you want.</h1>
|
||||
<p class="lede">
|
||||
Upload audio, video, or images, write your prompt in plain English, and the tool will produce a
|
||||
downloadable result for you.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<form id="job-form">
|
||||
<label class="field">
|
||||
<span>Files</span>
|
||||
<input id="files" name="files" type="file" multiple accept="audio/*,video/*,image/*" required />
|
||||
</label>
|
||||
|
||||
<div id="file-list" class="file-list" aria-live="polite"></div>
|
||||
|
||||
<label class="field">
|
||||
<span>Prompt</span>
|
||||
<textarea
|
||||
id="prompt"
|
||||
name="prompt"
|
||||
rows="6"
|
||||
placeholder="Example: Trim the first 15 seconds from this video, add a soft fade-in, and export as mp4."
|
||||
required
|
||||
></textarea>
|
||||
</label>
|
||||
|
||||
<button id="submit-button" type="submit">Process files</button>
|
||||
</form>
|
||||
|
||||
<div id="status" class="status idle">Waiting for a job.</div>
|
||||
<div id="result" class="result" hidden></div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<script src="/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
208
public/styles.css
Normal file
208
public/styles.css
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
:root {
|
||||
color-scheme: light;
|
||||
--bg: #f3efe6;
|
||||
--bg-accent: #ddd1bd;
|
||||
--panel: rgba(255, 251, 245, 0.86);
|
||||
--text: #1d1a17;
|
||||
--muted: #645a4e;
|
||||
--line: rgba(29, 26, 23, 0.14);
|
||||
--brand: #0c7c59;
|
||||
--brand-dark: #095740;
|
||||
--shadow: 0 24px 80px rgba(54, 36, 10, 0.16);
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
font-family: "Space Grotesk", sans-serif;
|
||||
color: var(--text);
|
||||
background:
|
||||
radial-gradient(circle at top left, rgba(255, 255, 255, 0.85), transparent 30%),
|
||||
radial-gradient(circle at bottom right, rgba(12, 124, 89, 0.18), transparent 30%),
|
||||
linear-gradient(135deg, var(--bg) 0%, var(--bg-accent) 100%);
|
||||
}
|
||||
|
||||
.shell {
|
||||
width: min(960px, calc(100vw - 2rem));
|
||||
margin: 0 auto;
|
||||
padding: 3rem 0 4rem;
|
||||
}
|
||||
|
||||
.hero {
|
||||
padding: 2rem 0 1.5rem;
|
||||
animation: rise 700ms ease;
|
||||
}
|
||||
|
||||
.eyebrow {
|
||||
margin: 0 0 0.75rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.16em;
|
||||
font-size: 0.78rem;
|
||||
color: var(--brand-dark);
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
max-width: 12ch;
|
||||
font-size: clamp(2.8rem, 9vw, 5.8rem);
|
||||
line-height: 0.95;
|
||||
}
|
||||
|
||||
.lede {
|
||||
max-width: 48rem;
|
||||
color: var(--muted);
|
||||
font-size: 1.1rem;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
code,
|
||||
textarea,
|
||||
.status,
|
||||
.file-pill {
|
||||
font-family: "IBM Plex Mono", monospace;
|
||||
}
|
||||
|
||||
.panel {
|
||||
padding: 1.5rem;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 28px;
|
||||
background: var(--panel);
|
||||
backdrop-filter: blur(18px);
|
||||
box-shadow: var(--shadow);
|
||||
animation: rise 900ms ease;
|
||||
}
|
||||
|
||||
#job-form {
|
||||
display: grid;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.field {
|
||||
display: grid;
|
||||
gap: 0.55rem;
|
||||
}
|
||||
|
||||
.field span {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
input[type="file"],
|
||||
textarea {
|
||||
width: 100%;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 18px;
|
||||
background: rgba(255, 255, 255, 0.78);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
input[type="file"] {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
textarea {
|
||||
padding: 1rem 1.1rem;
|
||||
resize: vertical;
|
||||
min-height: 9rem;
|
||||
}
|
||||
|
||||
button {
|
||||
justify-self: start;
|
||||
padding: 0.95rem 1.35rem;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
|
||||
color: white;
|
||||
font: inherit;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
transition: transform 180ms ease, box-shadow 180ms ease;
|
||||
box-shadow: 0 18px 40px rgba(12, 124, 89, 0.22);
|
||||
}
|
||||
|
||||
button:hover {
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
opacity: 0.68;
|
||||
cursor: wait;
|
||||
}
|
||||
|
||||
.file-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.65rem;
|
||||
min-height: 1.5rem;
|
||||
}
|
||||
|
||||
.file-pill {
|
||||
padding: 0.45rem 0.7rem;
|
||||
border-radius: 999px;
|
||||
background: rgba(12, 124, 89, 0.08);
|
||||
border: 1px solid rgba(12, 124, 89, 0.18);
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
.status,
|
||||
.result {
|
||||
margin-top: 1.25rem;
|
||||
padding: 1rem 1.1rem;
|
||||
border-radius: 18px;
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.status.idle {
|
||||
color: var(--muted);
|
||||
background: rgba(255, 255, 255, 0.42);
|
||||
}
|
||||
|
||||
.status.busy {
|
||||
color: #5f4309;
|
||||
background: rgba(255, 210, 117, 0.24);
|
||||
}
|
||||
|
||||
.status.error {
|
||||
color: #7a1c1c;
|
||||
background: rgba(211, 75, 75, 0.12);
|
||||
}
|
||||
|
||||
.status.success {
|
||||
color: #0b5f46;
|
||||
background: rgba(12, 124, 89, 0.12);
|
||||
}
|
||||
|
||||
.result a {
|
||||
color: var(--brand-dark);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
@keyframes rise {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(18px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.shell {
|
||||
width: min(100vw - 1rem, 100%);
|
||||
padding-top: 1.25rem;
|
||||
}
|
||||
|
||||
.panel {
|
||||
padding: 1rem;
|
||||
border-radius: 22px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue