gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit81f10e4e81f10e4eident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre81f10e4e/tools/import.hl

3.0 KB

  1. // tools/import.hl — import AntColony ticket files into the RUNNING app, over its JSON API.
  2. //
  3. // bin/hybriel tools/import.hl (default folder: import/tickets of the app — relative paths
  4. // resolve against THIS script's folder, hence '../import/tickets')
  5. // TICKETS_IMPORT_DIR=/some/dir TICKETS_URL=http://127.0.0.1:8350 bin/hybriel tools/import.hl
  6. //
  7. // WRITES NEED A TOKEN (ticket #7): TICKETS_TOKEN = an API token (log in with ident, /you →
  8. // "Create a token"); the imported tickets are opened by that token's user.
  9. //
  10. // A ticket file is `project:` and `subject:` header lines, a blank line, the summary
  11. // (hard-wrapped lines are joined into paragraphs, blank line = new paragraph —
  12. // lib/import.hl).
  13. // Each file is POSTed to /api/tickets with `source` = its file name; the app answers a
  14. // known source with the ticket it already has (200, existed) instead of a second one
  15. // (201), so running this twice imports nothing twice. Going through the API (not the
  16. // tables) means the running server stays the only writer and open browsers see the
  17. // imported tickets arrive live.
  18. import { listDir, readFile } from 'hl:fs'
  19. import { env } from 'hl:proc'
  20. import { fetch } from 'hl:fetch'
  21. import { parse } from '../lib/import.hl'
  22. static dir = env('TICKETS_IMPORT_DIR') != null ? env('TICKETS_IMPORT_DIR') : '../import/tickets'
  23. static base = env('TICKETS_URL') != null ? env('TICKETS_URL') : 'http://127.0.0.1:8350'
  24. static token = env('TICKETS_TOKEN') != null ? env('TICKETS_TOKEN') : ''
  25. if (token == '') { console.log('import: TICKETS_TOKEN is not set — API writes need a token (log in, /you → Create a token)') }
  26. // a > b for two strings (strings order by code point, hybriel#2; still no list sort())
  27. static after = (a, b) => { return a > b }
  28. // file names, sorted, so an empty store numbers each project's tickets in file order
  29. names = []
  30. for (n of listDir(dir)) {
  31. name = hlTypeName(n) == 'String' ? n : n.name
  32. if (name.endsWith('.md')) { names.push(name) }
  33. }
  34. let i = 1
  35. while (i < names.length) {
  36. cur = names[i]
  37. let j = i - 1
  38. while (j >= 0 && after(names[j], cur)) {
  39. names[j + 1] = names[j]
  40. j = j - 1
  41. }
  42. names[j + 1] = cur
  43. i = i + 1
  44. }
  45. created = 0
  46. existed = 0
  47. failed = 0
  48. for (name of names) {
  49. t = parse(readFile(dir + '/' + name))
  50. if (t.error != null) {
  51. console.log('SKIP ' + name + ': ' + t.error)
  52. failed = failed + 1
  53. } else {
  54. res = fetch(base + '/api/tickets', { method = 'POST' headers = { authorization = 'Bearer ' + token } json = { project = t.project subject = t.subject summary = t.summary source = name } })
  55. if (res.status == 201) {
  56. created = created + 1
  57. tk = res.json().ticket
  58. console.log('NEW ' + name + ' → ' + tk.project + ' ' + tk.ref)
  59. } else if (res.status == 200) {
  60. existed = existed + 1
  61. tk = res.json().ticket
  62. console.log('HAVE ' + name + ' = ' + tk.project + ' ' + tk.ref)
  63. } else {
  64. failed = failed + 1
  65. console.log('FAIL ' + name + ': ' + res.status + ' ' + res.text())
  66. }
  67. }
  68. }
  69. console.log('import: ' + created + ' new, ' + existed + ' already there, ' + failed + ' failed (' + dir + ' → ' + base + ')')

Branches

Latest commits

  • 81f10e4eident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre
  • f51029abMerge branch 'sy-sync'mre
  • eae6e8c7sync components.hybriel 4922f9c: comments like / Edit / Delete / 'edited' are 44 px targets; gate: 'edited' hit-area padding, thread targets check (SY)mre
  • 0de4750btheme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
  • 4eeb7bfeST2 report wordingmre
  • 2558f56cst2-sec: keep the hlsid session cookie name (no one is signed out), Secure flag only; gate: a cookie issued by main stays signed in; ident stub serves selector.js; security.mjs in deploy GATESmre
  • ea2e440esecurity audit (ST): JSON body cap, relation rights, login session rotation, __Host- Secure cookie, API security headers, CSP+referrer meta, /connect cap, one-line subjects, tests/security.mjs, reportmre
  • 7c8c2282sessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
  • b6277497report MT-mobile, LOGmre
  • 6709398blist paging: the newest rows come first (the sorted array was not used); filter rows hide their scrollbar; gate checks the ordermre
  • 31736a80gate: member-name check fails on the old row layout toomre
  • e03ae537gate: the phone checks run on without the Show more button (so old code reports every failed check)mre
  • adf7f132gate: 390 px checks for the mobile audit fixes (row number, filters, field widths, Edit, member names, relation taps, paging)mre
  • 28e9c938ticket list: draw the newest 50 rows and a Show more button (500 rows were a 2-4 s first paint, 740 KB, a 90 000 px phone page)mre
  • ccebb0c7mobile: ticket number stays on one line, filter chips one scrolling row, fields full width under their caption, Edit/action buttons, member names whole, 44 px relation linksmre
  • f2dc7741gate: the phone toolbar is two even rows (E2)mre
  • 20f7c33async components.hybriel 214c318: MdEditor on a phone, two even toolbar rows of 44 px targets, label 15 px, table head 16 px (E2)mre
  • d74a5482sync components.hybriel 134b4e3: MdEditor builds an editor put into the page at once, redraws a surface put in anew (F5, hybriel#211)mre
  • 9d02c540sync components.hybriel 6b0936a: the 'edited' foldable drops the theme's border and marginmre
  • 22751914sync components.hybriel 8d79ff7: bubble hugs its content, quiet 'edited' label; gate checksmre