Files
Levyraati26_go/templates/submission.html
T
Esa Kataja 80d3e36679 Add the submission pipeline and the review loop
Steps 3 and 4 of the build order. A member can now upload a song, watch it
convert, publish it, and review what everyone else has published.

Pipeline:
- ffprobe reads tags synchronously at submit so prefill never races typing;
  ffmpeg converts to Opus in the background, two at a time
- ffmpeg succeeding is the validation — no container sniffing
- publish moves the file inside the transaction, so a song row and its .ogg
  appear together or neither does
- five submissions per rolling 24h, failures excluded

Reviews and the reveal rule:
- the queue is unreviewed songs only, oldest first, never your own
- other people's reviews and the average are withheld in the query, not the
  template — a hidden average is never sent
- 30 minutes to edit or delete your own review, enforced in the WHERE clause
- deleting the last review unlocks the song for its submitter again

The waiting page has one button: the metadata form autosaves after a pause in
typing, and Julkaise submits it and publishes in the same request, so nothing
is lost without JS.

Genres store an English code and render a Finnish label.
2026-07-31 21:42:49 +03:00

56 lines
2.1 KiB
HTML

{{define "submission-status"}}
<div class="status" {{if not .Done}}hx-get="/submit/{{.ID}}/status" hx-trigger="every 2s" hx-swap="outerHTML"{{end}}>
<p class="{{if .Failed}}error{{end}}"><strong>{{.Label}}</strong></p>
{{if .Failed}}
{{with .StatusMsg}}<p class="muted small">{{.}}</p>{{end}}
<form method="post" action="/submit/{{.ID}}/discard">
<button type="submit">Poista lähetys</button>
</form>
{{else}}
<!-- Outside the form and attached to it with form=, so one button both submits the metadata
and publishes. Disabled until the audio has finished converting. -->
<button type="submit" form="meta" {{if not .Ready}}disabled{{end}}>Julkaise</button>
{{if not .Ready}}<p class="muted small">Julkaise aukeaa kun muunnos on valmis.</p>{{end}}
{{end}}
</div>
{{end}}
{{define "saved"}}<span id="saved" class="saved">{{if .}}Tallennettu {{.}}{{end}}</span>{{end}}
{{define "content"}}
<h1>Lähetys</h1>
{{if .Data.Failed}}{{template "submission-status" .Data}}{{end}}
{{if not .Data.Failed}}
<form id="meta" method="post" action="/submit/{{.Data.ID}}/publish" class="stack"
hx-post="/submit/{{.Data.ID}}" hx-trigger="input changed delay:1.2s, change"
hx-target="#saved" hx-swap="outerHTML">
<label>Kappaleen nimi
<input name="title" value="{{.Data.Title}}" maxlength="100" required>
</label>
<label>Esittäjä
<input name="artist" value="{{.Data.Artist}}" maxlength="100" required>
</label>
<label>Genre
<select name="genre" required>
<option value="">— valitse —</option>
{{$current := .Data.Genre}}
{{range .Data.Genres}}
<option value="{{.Code}}" {{if eq .Code $current}}selected{{end}}>{{.Label}}</option>
{{end}}
</select>
</label>
<label>Esittely <span class="muted small">(vapaaehtoinen)</span>
<textarea name="description" rows="5" maxlength="2000">{{.Data.Description}}</textarea>
</label>
{{template "saved" ""}}
</form>
<p class="muted">Tiedot tallentuvat itsestään kirjoittaessasi. Nimi, esittäjä ja genre tarvitaan
ennen julkaisua.</p>
{{template "submission-status" .Data}}
{{end}}
{{end}}