AparnaVelvet commited on
Commit
7867f84
·
verified ·
1 Parent(s): 988db6f

Add static index.html

Browse files
Files changed (1) hide show
  1. index.html +142 -17
index.html CHANGED
@@ -1,19 +1,144 @@
1
  <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
  <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
6
+ <title>Aparna Video Queue Helper</title>
7
+ <style>
8
+ body { font-family: system-ui, sans-serif; max-width: 740px; margin: 24px auto; padding: 0 16px; background: #0f1117; color: #f1f5f9; }
9
+ label { display: block; margin-top: 14px; font-weight: 600; font-size: 14px; }
10
+ input, textarea { width: 100%; box-sizing: border-box; margin-top: 6px; padding: 10px; border-radius: 8px; border: 1px solid #334155; background: #1e293b; color: #f8fafc; font-size: 14px; }
11
+ .radios { display: flex; gap: 18px; margin-top: 8px; }
12
+ .radios label { display: flex; align-items: center; gap: 6px; margin-top: 0; font-weight: 500; cursor: pointer; }
13
+ .radios input { width: auto; margin: 0; }
14
+ .url-row { display: flex; gap: 8px; align-items: stretch; margin-top: 6px; }
15
+ .url-row input { margin-top: 0; flex: 1; }
16
+ .btn-sec { padding: 10px 14px; border: 1px solid #475569; border-radius: 8px; background: #334155; color: #f8fafc; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; }
17
+ .btn-pri { margin-top: 18px; width: 100%; padding: 12px; border: 0; border-radius: 8px; background: #e11d48; color: #fff; font-weight: 700; font-size: 16px; cursor: pointer; }
18
+ button:disabled { opacity: 0.6; cursor: wait; }
19
+ #status { margin-top: 14px; padding: 12px; border-radius: 8px; background: #1e293b; border: 1px solid #334155; white-space: pre-wrap; font-family: monospace; }
20
+ </style>
21
+ </head>
22
+ <body>
23
+ <h2>Aparna Nurse Psalms — Queue Helper</h2>
24
+
25
+ <label>Video Type</label>
26
+ <div class="radios">
27
+ <label><input type="radio" name="video_type" value="shorts" checked /> shorts</label>
28
+ <label><input type="radio" name="video_type" value="longform" /> longform</label>
29
+ </div>
30
+
31
+ <label for="access_key">Access Key</label>
32
+ <input id="access_key" type="text" placeholder="Enter your HF write token (hf_...)" />
33
+
34
+ <label for="video_title">Video Title</label>
35
+ <input id="video_title" type="text" placeholder="Enter catchy clickable YouTube title..." />
36
+
37
+ <label for="audio_url">Audio URL</label>
38
+ <div class="url-row">
39
+ <input id="audio_url" type="url" placeholder="https://..." />
40
+ <button id="paste_btn" class="btn-sec" type="button">Paste from Clipboard</button>
41
+ </div>
42
+
43
+ <div id="thumb_wrap">
44
+ <label for="thumb_prompt">Thumbnail Prompt (Longform Only)</label>
45
+ <textarea id="thumb_prompt" rows="4" placeholder="Detailed descriptive visual prompt with bold hook text (longform only)..."></textarea>
46
+ </div>
47
+
48
+ <label for="transcript">Raw Transcript</label>
49
+ <textarea id="transcript" rows="9" placeholder="Paste raw spoken transcript (without [SPOKEN WORD])..."></textarea>
50
+
51
+ <button id="save_btn" class="btn-pri" type="button">Save Entry</button>
52
+ <div id="status">Ready.</div>
53
+
54
+ <script type="module">
55
+ import { uploadFile } from "https://cdn.jsdelivr.net/npm/@huggingface/hub/+esm";
56
+
57
+ const keyEl = document.getElementById("access_key");
58
+ const titleEl = document.getElementById("video_title");
59
+ const urlEl = document.getElementById("audio_url");
60
+ const pasteBtn = document.getElementById("paste_btn");
61
+ const thumbWrap = document.getElementById("thumb_wrap");
62
+ const thumbEl = document.getElementById("thumb_prompt");
63
+ const trEl = document.getElementById("transcript");
64
+ const btnEl = document.getElementById("save_btn");
65
+ const stEl = document.getElementById("status");
66
+ const savedFingerprints = new Set();
67
+
68
+ const savedKey = localStorage.getItem("aparna_hf_key") || "";
69
+ if (savedKey) keyEl.value = savedKey;
70
+
71
+ function toggleThumb() {
72
+ const vt = document.querySelector('input[name="video_type"]:checked')?.value || "shorts";
73
+ thumbWrap.style.display = vt === "longform" ? "block" : "none";
74
+ }
75
+ document.querySelectorAll('input[name="video_type"]').forEach(r => r.addEventListener("change", toggleThumb));
76
+ toggleThumb();
77
+
78
+ pasteBtn.addEventListener("click", async () => {
79
+ try {
80
+ const txt = (await navigator.clipboard.readText() || "").trim();
81
+ if (!txt) { stEl.textContent = "Clipboard is empty."; return; }
82
+ urlEl.value = txt;
83
+ stEl.textContent = "Pasted URL from clipboard.";
84
+ } catch (err) {
85
+ stEl.textContent = "Clipboard blocked: " + (err?.message || err);
86
+ urlEl.focus();
87
+ }
88
+ });
89
+
90
+ btnEl.addEventListener("click", async () => {
91
+ const token = keyEl.value.trim();
92
+ const vtype = document.querySelector('input[name="video_type"]:checked')?.value || "shorts";
93
+ const title = titleEl.value.replace(/[\r\n]+/g, " ").trim();
94
+ const url = urlEl.value.trim();
95
+ const thumbPrompt = vtype === "longform" ? thumbEl.value.replace(/[\r\n]+/g, " ").trim() : "";
96
+ let raw = trEl.value.replace(/\[\s*SPOKEN\s+WORD\s*\]/gi, "").replace(/\s+/g, " ").trim();
97
+
98
+ if (!token) { stEl.textContent = "ERROR: Please enter Access Key."; return; }
99
+ if (title.length < 3) { stEl.textContent = "ERROR: Please enter a Video Title."; return; }
100
+ if (!/^https?:\/\/\S+$/i.test(url)) { stEl.textContent = "ERROR: Please enter a valid http/https Audio URL."; return; }
101
+ if (vtype === "longform" && thumbPrompt.length < 10) {
102
+ stEl.textContent = "ERROR: Please enter a detailed Thumbnail Prompt for longform videos.";
103
+ return;
104
+ }
105
+ if (raw.length < 5) { stEl.textContent = "ERROR: Transcript is empty."; return; }
106
+
107
+ const fpInput = `${vtype}|${url.toLowerCase()}|${raw.toLowerCase()}`;
108
+ const buf = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(fpInput));
109
+ const fp = Array.from(new Uint8Array(buf)).map(b => b.toString(16).padStart(2, "0")).join("").slice(0, 8);
110
+
111
+ if (savedFingerprints.has(fp)) {
112
+ stEl.textContent = "SKIPPED: Duplicate entry already saved in this session.";
113
+ return;
114
+ }
115
+
116
+ localStorage.setItem("aparna_hf_key", token);
117
+ btnEl.disabled = true;
118
+ stEl.textContent = "Saving...";
119
+
120
+ try {
121
+ const now = new Date();
122
+ const p = (n) => String(n).padStart(2, "0");
123
+ const dateStr = `${now.getUTCFullYear()}${p(now.getUTCMonth()+1)}${p(now.getUTCDate())}`;
124
+ const prefix = vtype === "longform" ? "long" : "short";
125
+ const repoPath = `${vtype}/${prefix}_${dateStr}_${fp}.txt`;
126
+ const body = `TITLE: ${title}\n\nURL: ${url}\n\nTHUMBNAIL_PROMPT:\n${thumbPrompt}\n\nTRANSCRIPT:\n${raw}\n`;
127
+
128
+ await uploadFile({
129
+ repo: { type: "dataset", name: "AparnaVelvet/Storage" },
130
+ accessToken: token,
131
+ file: { path: repoPath, content: new Blob([body], { type: "text/plain" }) },
132
+ commitTitle: `Queue ${repoPath} via Iris Queue Space`,
133
+ });
134
+ savedFingerprints.add(fp);
135
+ stEl.textContent = `SUCCESS: Saved ${repoPath}`;
136
+ } catch (err) {
137
+ stEl.textContent = `ERROR: ${err?.message || err}`;
138
+ } finally {
139
+ btnEl.disabled = false;
140
+ }
141
+ });
142
+ </script>
143
+ </body>
144
  </html>