diff --git a/app/server.py b/app/server.py index 1502cf0..02baa83 100644 --- a/app/server.py +++ b/app/server.py @@ -21,7 +21,7 @@ import time import urllib.request from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from pathlib import Path -from urllib.parse import parse_qs, urlparse +from urllib.parse import parse_qs, quote, urlparse # Sibling modules: db (SQLite, paths), llama (model servers), memory (Q&A). import db @@ -54,7 +54,16 @@ NOPROXY = urllib.request.build_opener(urllib.request.ProxyHandler({})) # Edge path; %ProgramFiles(x86)% expanded by Windows env. EDGE = Path(os.path.expandvars(r"%ProgramFiles(x86)%\Microsoft\Edge\Application\msedge.exe")) PRINT_CSS = ( - "@media print{body{max-width:none;padding:0}img,tr{break-inside:avoid}h2,h3{break-after:avoid}}" + "@page{margin:15mm}" + "@media print{:root{--bg:#fff;--card:#fff;--soft:#f3f3f3;--line:#ccc}html,body{background:#fff}" + "body{max-width:none;padding:0;font-size:9pt;line-height:1.5}" + "h1{font-size:16pt}h2{font-size:12pt;margin-top:1.6em;border-top:0;padding-top:0}" + "table{font-size:8.5pt;border-radius:0;border:0;border-top:1px solid #999;border-bottom:1px solid #999}" + "td,th{padding:4px 8px}th{background:#eee}" + "#in-breve+ul{border-radius:0;padding:10px 16px 10px 2em}" + "details{border:0;padding:0;margin-top:1em;background:none}summary{display:none}" + "img{border-radius:0;max-width:100%}code{border-radius:0}" + "img,tr{break-inside:avoid}h2,h3{break-after:avoid}}" ) # Serializes ask_once: one llama start/stop at a time. LOCK = threading.Lock() @@ -876,10 +885,14 @@ class Handler(BaseHTTPRequestHandler): if file_path is None: self._send(b"not found", 404) else: + # File name from the report ; filename* carries the UTF-8 form, filename the ASCII fallback. + match = re.search(r"<title>(.*?)", file_path.with_name("report.html").read_text(encoding="utf-8")[:2000]) + label = re.sub(r'[\\/:*?"<>|\s]+', " ", match[1] if match else name).strip() or name + ascii_label = label.encode("ascii", "ignore").decode().strip() or name self._send( file_path.read_bytes(), ctype="application/pdf", - headers=[("Content-Disposition", f'attachment; filename="{name}.pdf"')], + headers=[("Content-Disposition", f'attachment; filename="{ascii_label}.pdf"; filename*=UTF-8\'\'{quote(label + ".pdf")}')], ) elif parsed.path == "/ask": if not params.get("q", "").strip(): diff --git a/app/ui/ui.js b/app/ui/ui.js index 8d1eabb..daee899 100644 --- a/app/ui/ui.js +++ b/app/ui/ui.js @@ -77,8 +77,11 @@ const sel={}; // Mini modal with the secondary actions of one recording: rerun from step, drop video, delete. function more(name,mb,label,canDrop,title,canRetitle,blocked){ mbody.innerHTML=`${label}`+(canRetitle?``:"")+(mb?``:"")+ +``+ (canDrop&&!blocked?``:"")+ (blocked?"":``)+``;mdlg.showModal()} +// Ask the server to open the meeting folder in Explorer. +async function reveal(name){const response=await fetch("/reveal?name="+name,{method:"POST"});if(!response.ok)alert(await response.text())} // Participants: named speakers (unnamed labels shown as-is) with talk time, in the same modal. async function who(name){const data=await (await fetch("/speakers?name="+name)).json(); mbody.innerHTML=`Partecipanti`+(data.rows.map(row=>`
${E(row.person||row.label)} ${fmt(row.talk_s)}
`).join("")||"
nessun dato
")+``} @@ -215,7 +218,7 @@ qs.textContent=data.queue?`rielaborazione: ${data.queue} da completare`:""; // Remember step-select values so they survive the re-render. document.querySelectorAll("select[id^=f-]").forEach(select=>sel[select.id]=select.value); // Table header. -let html="riunionestatodurataspeakerMBazioni"; +let html="riunionestatodurataspeakerdimensioneazioni"; // Pagination: PS meetings per page; clamp the page if recordings were removed, then draw the pager. const pages=Math.max(1,Math.ceil(data.recs.length/PS));if(pg_>=pages)pg_=pages-1; pgr.innerHTML=pages>1?`pagina ${pg_+1} di ${pages} (${data.recs.length} riunioni)`:""; @@ -224,7 +227,7 @@ for(const row of data.recs.slice(pg_*PS,(pg_+1)*PS)){ // Display title, falling back to the upload name. const nm=row.title||row.upload,act=!!(row.prog||row.running||row.status==="queued"); // Main row: checkbox, title and rename buttons; status badge with error text and time since last data. -html+=`${nm?`${E(nm)}${act?"":""}
${row.name}`:row.name+(act?"":"")}
${row.status}${row.receiving_age_s!=null&&row.status==="recording"?` ${row.receiving_age_s}s ago`:""}${row.error?`
${E(row.error)}`:""}${row.duration_s?fmt(row.duration_s):""}${row.speakers??""}${row.mb} +html+=`${nm?`${E(nm)}${act?"":""}
${row.name}`:row.name+(act?"":"")}
${row.status}${row.receiving_age_s!=null&&row.status==="recording"?` ${row.receiving_age_s}s ago`:""}${row.error?`
${E(row.error)}`:""}${row.duration_s?fmt(row.duration_s):""}${row.speakers??""}${row.mb?row.mb+" MB":""}
📄 reportpdf
`; html+=pgo.has(row.name)?progPanel(row):""; if(open_.has(row.name))html+=await panel(row.name);html+=""}