1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Equalify Iris — Try it</title>
<style>
:root {
--fg: #14161a;
--bg: #ffffff;
--muted: #4a4f57;
--accent: #0b4f9c; /* >= 4.5:1 on white */
--accent-fg: #ffffff;
--border: #6b7280;
--ok: #156534;
--err: #a31515;
--panel: #f3f5f8;
}
@media (prefers-color-scheme: dark) {
:root {
--fg: #f2f4f8; --bg: #14161a; --muted: #c2c8d2; --accent: #7db4ff;
--accent-fg: #08182e; --border: #8a93a3; --ok: #6ee7a0; --err: #ff9a9a; --panel: #1d2128;
}
}
* { box-sizing: border-box; }
body {
margin: 0; font: 1.05rem/1.6 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
color: var(--fg); background: var(--bg);
}
.skip-link {
position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-fg);
padding: .6rem 1rem; z-index: 10;
}
.skip-link:focus { left: 0; }
header, main, footer { max-width: 60rem; margin: 0 auto; padding: 0 1.25rem; }
header { padding-top: 2rem; }
h1 { font-size: 2rem; margin: 0 0 .25rem; }
.tagline { color: var(--muted); margin: 0 0 1.5rem; font-size: 1.15rem; }
main { padding-bottom: 3rem; }
section { background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
padding: 1.25rem 1.5rem; margin: 1.25rem 0; }
h2 { font-size: 1.3rem; margin: 0 0 .75rem; }
h2:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
p { margin: .5rem 0; }
label { display: block; font-weight: 600; margin: 1rem 0 .35rem; }
.hint { color: var(--muted); font-weight: 400; font-size: .95rem; margin: 0 0 .35rem; }
input[type=file], input[type=number], input[type=text], textarea {
font: inherit; width: 100%; max-width: 32rem; padding: .55rem .65rem;
border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--fg);
}
textarea { min-height: 5rem; }
button {
font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent;
border-radius: 8px; padding: .6rem 1.1rem; background: var(--accent); color: var(--accent-fg);
}
button.secondary { background: transparent; color: var(--accent); border-color: var(--accent); }
button.linkish { background: none; border: 0; color: var(--accent); text-decoration: underline;
cursor: pointer; font: inherit; padding: 0; }
button[disabled] { opacity: .55; cursor: not-allowed; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.code {
display: inline-block; font: 700 1.6rem ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: .12em; background: var(--bg); border: 2px dashed var(--accent);
padding: .4rem .8rem; border-radius: 8px;
}
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }
.status { font-weight: 600; }
#error:not(:empty) {
background: var(--err); color: #fff; padding: .75rem 1rem; border-radius: 8px; margin: 1rem 0;
}
.built { border-left: 4px solid var(--accent); padding-left: .9rem; }
iframe { width: 100%; height: 32rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
pre { overflow: auto; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
padding: 1rem; max-height: 24rem; }
.spinner { display: inline-block; width: 1rem; height: 1rem; border: 3px solid var(--border);
border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
footer { border-top: 1px solid var(--border); padding-top: 1.25rem; padding-bottom: 2rem; color: var(--muted); }
.visually-hidden { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0; }
</style>
</head>
<body>
<a class="skip-link" href="#main">Skip to main content</a>
<header>
<h1>Equalify Iris</h1>
<p class="tagline">Turn images of document pages into accessible HTML.</p>
<p id="account" class="hint" hidden>Signed in as <strong id="account-name"></strong> ·
<button id="signout-btn" type="button" class="linkish">Sign out</button></p>
</header>
<main id="main">
<!-- live regions -->
<div id="error" role="alert" aria-live="assertive"></div>
<div id="live" class="visually-hidden" role="status" aria-live="polite"></div>
<!-- Step 1: sign in -->
<section id="auth-section" aria-labelledby="step1-h">
<h2 id="step1-h" tabindex="-1">Sign in</h2>
<p class="hint">Sign in with GitHub to convert documents. If Iris meets content that warrants a new
agent, it may open a public “agent suggestion” issue on the project repo under your account.</p>
<div class="row">
<button id="signin-btn" type="button">Sign in with GitHub</button>
<span id="whoami" class="status"></span>
</div>
<div id="device-instructions" hidden>
<h3 id="device-h" tabindex="-1">Enter this code on GitHub</h3>
<ol>
<li>
<span id="code-intro">Code:</span>
<strong id="user-code" class="code">––––</strong>
<button id="copy-code" type="button" class="secondary">Copy</button>
<span id="copy-status" role="status" aria-live="polite"></span>
</li>
<li><a id="verify-link" href="#" target="_blank" rel="noopener">Open GitHub</a>, enter the code, Authorize.</li>
<li>Come back here — you’ll be signed in automatically.</li>
</ol>
<p class="status">
<span class="spinner" id="auth-spinner" aria-hidden="true" hidden></span>
<span id="auth-status" role="status" aria-live="polite"></span>
</p>
</div>
</section>
<!-- Step 2: upload -->
<section id="upload-section" aria-labelledby="step2-h" hidden>
<h2 id="step2-h" tabindex="-1">Upload your pages</h2>
<form id="upload-form">
<label for="images">Pages (images or PDF)</label>
<p class="hint" id="images-hint">A PDF, or images (PNG, JPEG, TIFF, WebP) in reading order. A PDF is split into one page per image.</p>
<input id="images" name="images" type="file" accept="image/png,image/jpeg,image/tiff,image/webp,application/pdf" multiple aria-describedby="images-hint" required>
<label for="iterations">Review passes</label>
<p class="hint" id="iter-hint">1 is fast; higher is more thorough but much slower (each pass re-runs the reviewer). 1–5.</p>
<input id="iterations" name="iterations" type="number" min="1" max="5" value="1" aria-describedby="iter-hint">
<div class="row">
<button id="convert-btn" type="submit" disabled>Convert to accessible HTML</button>
</div>
</form>
</section>
<!-- Step 3: progress -->
<section id="status-section" aria-labelledby="step3-h" hidden>
<h2 id="step3-h" tabindex="-1">Converting…</h2>
<p id="status-live" class="status" role="status" aria-live="polite"><span class="spinner" aria-hidden="true"></span> Starting…</p>
<p class="hint">This can take a minute or two.</p>
</section>
<!-- Step 4: result -->
<section id="result-section" aria-labelledby="step4-h" hidden>
<h2 id="step4-h" tabindex="-1">Your accessible HTML</h2>
<p id="built-agents" class="built" hidden></p>
<p>Your document was converted to accessible HTML.</p>
<div class="row">
<button id="view-btn" type="button">View converted document</button>
<button id="download-btn" type="button" class="secondary">Download HTML</button>
<button id="restart-btn" type="button" class="secondary">Convert another document</button>
</div>
<p class="hint">Opens in a new browser tab.</p>
<form id="feedback-form">
<label for="feedback-text">Not quite right? Tell Iris what to fix</label>
<p class="hint" id="fb-hint">Iris will re-run the conversion with your feedback applied (for example: “Keep footnotes separate from body text”).</p>
<input id="feedback-text" type="text" aria-describedby="fb-hint">
<div class="row">
<button id="feedback-btn" type="submit" class="secondary">Re-run with this feedback</button>
</div>
</form>
</section>
</main>
<footer>
<h2 class="visually-hidden">About</h2>
<p><strong>Equalify Iris is Open Source.</strong> Sustainability is key to sustaining its growth.
With that in mind, we hope you use and alter the codebase.</p>
<p>Iris is hosted by <a href="https://equalify.app/"><strong>Equalify Inc</strong></a>.
Continued support and development are paid for when you hire us to host or support any instance.
Please consider hiring us.</p>
<p><a href="https://github.com/EqualifyEverything/equalify-iris">View the source on GitHub</a>.</p>
</footer>
<script>
const API = '/v1';
let token = localStorage.getItem('iris_token') || null;
let sessionId = null;
let sourceBase = 'document';
let currentUserCode = null;
let currentBlobUrl = null;
const $ = (id) => document.getElementById(id);
const show = (id) => { $(id).hidden = false; };
const hide = (id) => { $(id).hidden = true; };
const announce = (msg) => { $('status-live').textContent = msg; };
const live = (msg) => { $('live').textContent = msg; };
const setError = (msg) => { $('error').textContent = msg || ''; };
const focusHeading = (id) => { $(id).focus(); };
// Spell a code out so screen readers announce each character clearly,
// e.g. "WXYZ-1234" -> "W X Y Z dash 1 2 3 4".
const spellCode = (code) => code.split('').map((c) => (c === '-' ? 'dash' : c)).join(' ');
// Copy text to the clipboard. Prefers the async Clipboard API (needs a
// secure context: HTTPS or localhost); falls back to execCommand('copy'),
// which also works over plain HTTP.
async function copyText(text) {
if (navigator.clipboard && window.isSecureContext) {
await navigator.clipboard.writeText(text);
return;
}
const ta = document.createElement('textarea');
ta.value = text;
ta.setAttribute('readonly', '');
ta.style.position = 'fixed';
ta.style.top = '0';
ta.style.opacity = '0';
document.body.appendChild(ta);
ta.focus();
ta.select();
const ok = document.execCommand('copy');
document.body.removeChild(ta);
if (!ok) throw new Error('copy command failed');
}
async function api(path, opts = {}) {
const headers = Object.assign({}, opts.headers);
if (token) headers['Authorization'] = 'Bearer ' + token;
return fetch(API + path, Object.assign({}, opts, { headers }));
}
async function errMessage(res) {
try { const j = await res.json(); return (j.error && j.error.message) || res.statusText; }
catch { return res.statusText; }
}
// ----- Step 1: GitHub device flow -----
$('signin-btn').addEventListener('click', startDeviceFlow);
async function startDeviceFlow() {
setError('');
$('signin-btn').disabled = true;
try {
const res = await fetch(API + '/auth/github/device', { method: 'POST' });
if (!res.ok) throw new Error(await errMessage(res));
const d = await res.json();
currentUserCode = d.user_code;
const codeEl = $('user-code');
codeEl.textContent = d.user_code; // shown to sighted users
codeEl.setAttribute('aria-label', spellCode(d.user_code)); // read clearly aloud
$('verify-link').href = d.verification_uri;
$('copy-status').textContent = '';
show('device-instructions');
$('signin-btn').textContent = 'Get a new code';
$('signin-btn').disabled = false;
// Move focus to the new instructions so screen-reader users land on the
// code and steps instead of being left on the button with no feedback.
focusHeading('device-h');
show('auth-spinner');
$('auth-status').textContent = 'Waiting for you to authorize on GitHub…';
pollDevice(d.device_code, (d.interval || 5));
} catch (e) {
setError('Could not start sign-in: ' + e.message);
$('signin-btn').disabled = false;
}
}
function pollDevice(deviceCode, interval) {
const tick = async () => {
try {
const res = await fetch(API + '/auth/github/device/poll', {
method: 'POST', headers: { 'content-type': 'application/json' },
body: JSON.stringify({ device_code: deviceCode }),
});
if (res.status === 200) {
const d = await res.json();
token = d.access_token;
localStorage.setItem('iris_token', token);
await onSignedIn();
return;
}
setTimeout(tick, interval * 1000); // still pending
} catch (e) {
setTimeout(tick, interval * 1000);
}
};
setTimeout(tick, interval * 1000);
}
$('copy-code').addEventListener('click', async () => {
if (!currentUserCode) return;
try {
await copyText(currentUserCode);
$('copy-status').textContent = 'Code copied to your clipboard.';
} catch {
$('copy-status').textContent = 'Copy failed — please select the code above and copy it manually.';
}
});
async function onSignedIn() {
const res = await api('/me');
if (!res.ok) { token = null; localStorage.removeItem('iris_token'); setError('Sign-in failed. Please try again.'); return; }
const me = await res.json();
$('whoami').textContent = 'Signed in as ' + me.github_login;
$('account-name').textContent = me.github_login;
show('account');
$('auth-status').textContent = '';
hide('auth-spinner');
live('Signed in as ' + me.github_login + '. Continue to step 2 to upload your document pages.');
hide('auth-section');
show('upload-section');
updateConvertButton();
focusHeading('step2-h');
}
// ----- Step 2: upload -----
function updateConvertButton() {
$('convert-btn').disabled = $('images').files.length === 0;
}
$('images').addEventListener('change', updateConvertButton);
$('upload-form').addEventListener('submit', async (ev) => {
ev.preventDefault();
setError('');
const files = $('images').files;
if (!files.length) { setError('Please choose at least one image.'); return; }
// Output download name mirrors the uploaded file.
sourceBase = (files[0].name.replace(/\.[^.]+$/, '').replace(/[^A-Za-z0-9._-]/g, '_')) || 'document';
const fd = new FormData();
for (const f of files) fd.append('images', f);
const iters = $('iterations').value;
if (iters) fd.append('config', JSON.stringify({ max_review_iterations: Number(iters) }));
const btn = $('convert-btn');
btn.disabled = true; btn.setAttribute('aria-busy', 'true');
try {
const res = await api('/sessions', { method: 'POST', body: fd });
if (!res.ok) throw new Error(await errMessage(res));
const d = await res.json();
sessionId = d.session_id;
hide('upload-section'); show('status-section'); focusHeading('step3-h');
announce('Starting… ' + d.image_count + ' page(s) uploaded.');
pollStatus();
} catch (e) {
setError('Upload failed: ' + e.message);
} finally {
btn.removeAttribute('aria-busy');
updateConvertButton();
}
});
// ----- Step 3: poll status -----
const PHASE_LABEL = {
triage: 'reading each page', extraction: 'extracting content',
reconciliation: 'stitching pages together', assembly: 'assembling the document',
review: 'reviewing for accessibility', done: 'finishing up',
};
async function pollStatus() {
let d = null;
try {
const res = await api('/sessions/' + sessionId);
if (res.ok) d = await res.json();
} catch (e) {
// transient network error — fall through and keep polling
}
if (d && d.status === 'ready_for_review') {
announce('Done! Your accessible HTML is ready.');
try {
await showResult(d);
} catch (e) {
setError('The conversion finished, but the result could not be displayed: ' + e.message);
}
return; // terminal — stop polling
}
if (d && d.status === 'failed') {
setError('Conversion failed: ' + (d.error || 'unknown error') + '. You can try again.');
hide('status-section'); show('upload-section'); focusHeading('step2-h');
return; // terminal — stop polling
}
// queued / running / a transient error / an unexpected shape: keep going
// so a single hiccup never strands the user on the spinner.
if (d && (d.phase || d.status)) {
announce('Working — ' + (PHASE_LABEL[d.phase] || d.phase || d.status) + '…');
}
setTimeout(pollStatus, 2500);
}
// ----- Step 4: result -----
async function showResult(d) {
const res = await api('/sessions/' + sessionId + '/output');
const html = await res.text();
// Build a local blob URL so "View converted document" can open the
// rendered HTML in a new tab without the /output endpoint needing to be
// reachable unauthenticated.
const blob = new Blob([html], { type: 'text/html' });
if (currentBlobUrl) URL.revokeObjectURL(currentBlobUrl);
currentBlobUrl = URL.createObjectURL(blob);
$('view-btn').onclick = () => window.open(currentBlobUrl, '_blank');
$('download-btn').onclick = () => {
const a = document.createElement('a');
a.href = currentBlobUrl;
a.download = sourceBase + '_converted.html';
document.body.appendChild(a); a.click(); a.remove();
};
const built = (d.pending_prs && d.pending_prs.new_agents) || [];
if (built.length) {
$('built-agents').textContent = 'Iris taught itself ' + built.length +
' new agent(s) for content it had not seen before: ' + built.map(a => a.agent_name).join(', ') + '.';
show('built-agents');
}
hide('status-section'); show('result-section'); focusHeading('step4-h');
}
$('restart-btn').addEventListener('click', () => {
sessionId = null; setError('');
$('upload-form').reset();
updateConvertButton();
hide('result-section'); show('upload-section'); focusHeading('step2-h');
});
$('signout-btn').addEventListener('click', () => {
localStorage.removeItem('iris_token');
token = null; sessionId = null; setError('');
$('upload-form').reset();
hide('account'); hide('upload-section'); hide('status-section'); hide('result-section');
hide('device-instructions');
$('signin-btn').textContent = 'Sign in with GitHub';
show('auth-section'); focusHeading('step1-h');
});
$('feedback-form').addEventListener('submit', async (ev) => {
ev.preventDefault();
setError('');
const fb = $('feedback-text').value.trim();
if (!fb) { setError('Please enter some feedback first.'); return; }
try {
const res = await api('/sessions/' + sessionId + '/feedback', {
method: 'POST', headers: { 'content-type': 'application/json' },
body: JSON.stringify({ feedback: fb }),
});
if (!res.ok) throw new Error(await errMessage(res));
$('feedback-text').value = '';
hide('result-section'); show('status-section'); focusHeading('step3-h');
announce('Re-running with your feedback…');
pollStatus();
} catch (e) {
setError('Could not submit feedback: ' + e.message);
}
});
// If a token is already stored, skip straight to upload.
(async function init() {
if (!token) return;
const res = await api('/me');
if (res.ok) await onSignedIn();
else { token = null; localStorage.removeItem('iris_token'); }
})();
</script>
</body>
</html>