Files
ssmithxandClaude Sonnet 5 c8f6102cfd
Build and validate / build (push) Successful in 11s
Add a real submission form, bypassing the broken Gitea issue-template render
Gitea 1.27.1 on this instance silently ignores the ?template= param for
.github/ISSUE_TEMPLATE/hardware-report.yml — the structured fields never
render, just a blank title/body editor (confirmed live: same URL that's
supposed to load the form shows nothing). Rather than debug Gitea's YAML
issue-forms support, site/report.html is a plain form matching the schema
that builds a title + markdown body (with a ready-to-merge YAML block) and
opens Gitea's issues/new with them pre-filled via query params, which does
work on this instance (verified live).

Verified the full round trip in a real browser: filled the form, submitted,
confirmed the opened Gitea tab has the correct title and a body containing
valid YAML matching every field. Did not actually click "Create Issue" —
no reason to leave a test issue on the tracker.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-03 22:37:27 +00:00

97 lines
3.6 KiB
JavaScript

// Builds a pre-filled Gitea "new issue" URL (title + body via query params —
// verified working on this Gitea instance even though its YAML issue-forms
// rendering (.github/ISSUE_TEMPLATE/hardware-report.yml) does not render as
// a structured form: it silently falls back to a blank issue instead, so we
// don't rely on it) and opens it. The body includes a ready-to-paste YAML
// block matching data/schema.json, so a maintainer can copy it straight
// into a new data/reports/*.yml file with minimal editing.
const REPO_URL = "https://source.archipelago-foundation.org/ssmithx/ArchyHCL";
const form = document.getElementById("report-form");
const statusSelect = document.getElementById("status");
const issuesField = document.getElementById("issues");
const issuesRequiredHint = document.getElementById("issues-required");
const errorEl = document.getElementById("form-error");
function updateIssuesRequirement() {
const required = statusSelect.value !== "working";
issuesRequiredHint.hidden = !required;
issuesField.required = required;
}
statusSelect.addEventListener("change", updateIssuesRequirement);
updateIssuesRequirement();
// A YAML double-quoted scalar uses the same escaping rules as JSON strings
// for every character that matters here (quotes, backslashes, control
// chars) — JSON.stringify is a safe, simple way to produce one.
function yamlString(value) {
return JSON.stringify(value ?? "");
}
function yamlBlock(value) {
const trimmed = (value ?? "").trim();
if (!trimmed) return null;
return trimmed
.split("\n")
.map((line) => " " + line)
.join("\n");
}
function val(id) {
return document.getElementById(id).value.trim();
}
function buildYaml() {
const lines = [];
lines.push(`device_model: ${yamlString(val("device_model"))}`);
lines.push(`form_factor: ${val("form_factor")}`);
lines.push(`cpu: ${yamlString(val("cpu"))}`);
lines.push(`ram_gb: ${val("ram_gb")}`);
lines.push("storage:");
lines.push(` type: ${val("storage_type")}`);
lines.push(` size_gb: ${val("storage_size_gb")}`);
lines.push(`wifi_chip: ${yamlString(val("wifi_chip"))}`);
const ethernet = val("ethernet");
if (ethernet) lines.push(`ethernet: ${yamlString(ethernet)}`);
lines.push(`archy_version: ${yamlString(val("archy_version"))}`);
lines.push(`install_method: ${val("install_method")}`);
lines.push(`status: ${val("status")}`);
lines.push(`tested_date: ${yamlString(val("tested_date"))}`);
const submittedBy = val("submitted_by");
if (submittedBy) lines.push(`submitted_by: ${yamlString(submittedBy)}`);
const issuesBlock = yamlBlock(val("issues"));
if (issuesBlock) lines.push(`issues: |\n${issuesBlock}`);
const notesBlock = yamlBlock(val("notes"));
if (notesBlock) lines.push(`notes: |\n${notesBlock}`);
return lines.join("\n");
}
form.addEventListener("submit", (e) => {
e.preventDefault();
errorEl.hidden = true;
if (statusSelect.value !== "working" && !val("issues")) {
errorEl.textContent = 'Please describe the issue(s) — required when status is "partial" or "broken".';
errorEl.hidden = false;
issuesField.focus();
return;
}
const deviceModel = val("device_model");
const title = `hw: ${deviceModel}`;
const yaml = buildYaml();
const body = [
`Hardware report for **${deviceModel}**, submitted via the site form.`,
"",
"A maintainer: copy the block below into a new file under `data/reports/` (see CONTRIBUTING.md) to add it to the list.",
"",
"```yaml",
yaml,
"```",
].join("\n");
const url = `${REPO_URL}/issues/new?title=${encodeURIComponent(title)}&body=${encodeURIComponent(body)}`;
window.open(url, "_blank", "noopener");
});