Line numbers are places in import and export; fix stale scripts

Import: each row's place is its line number, so blank lines leave a
place empty; a fully numbered text file ("38. Title") or a Rank column
gives places directly, and repeated numbers take the next free place.
Entries are added at those places (existing ones there move down), the
review shows each row's #, and the room check covers the highest place.

Export writes a blank line for every empty place, so line N is #N and a
file round-trips.

Static files now carry an ETag and unversioned ones are revalidated on
every load. Scripts import each other without a ?v= tag, so browsers kept
an hour-old import.js (with the "null" bug) after an update.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cdnutterandClaude Opus 5.5 committed 2026-10-08 14:43:53 -07:00
1 parent 88373176f2
commit 62fcf6b45d
7 files changed
+151 -72

No files matched your search

+9 -5
View File
@@ -14,8 +14,9 @@ var exportFormats = map[string]struct{ ext, contentType string }{
"txt": {"txt", "text/plain; charset=utf-8"},
}
// handleExport downloads a list's titles in rank order, one per line, with
// nothing else: no ranks, header row or metadata.
// handleExport downloads a list's titles, one per line, with nothing else:
// no ranks, header row or metadata. Line N is place #N, so an empty place
// is a blank line, and importing the file puts everything back where it was.
func (s *Server) handleExport(w http.ResponseWriter, r *http.Request) {
format := r.URL.Query().Get("format")
if format == "" {
@@ -35,9 +36,12 @@ func (s *Server) handleExport(w http.ResponseWriter, r *http.Request) {
s.serverError(w, r, err)
return
}
titles := make([]string, len(items))
for i, it := range items {
titles[i] = it.Title
var titles []string
for _, it := range items {
for len(titles) < it.Rank-1 {
titles = append(titles, "")
}
titles = append(titles, it.Title)
}
w.Header().Set("Content-Type", f.contentType)
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s.%s"`, l.Slug, f.ext))