this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: preserve file extension on image rename; add reverse-side review for bi cards

- ImageTile rename now uses the original file extension instead of hardcoding .png
- tala-cli review: bi-directional cards enqueue a "reverse" item (back->front)
in addition to "forward"; apply_schedule and print_card_preview handle sub_id="reverse"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

+33 -15
+30 -12
crates/tala-cli/src/main.rs
··· 159 159 continue; 160 160 } 161 161 match (&card.kind, df.sidecar.get(&card_id)) { 162 - (CardKind::FrontBack { .. }, sched) => { 163 - let fwd = match sched { 162 + (CardKind::FrontBack { dir, .. }, sched) => { 163 + let (fwd, rev) = match sched { 164 164 Some(CardSchedule::FrontBack { 165 - forward_schedule, .. 166 - }) => forward_schedule.clone(), 167 - _ => None, 165 + forward_schedule, 166 + reverse_schedule, 167 + }) => (forward_schedule.clone(), reverse_schedule.clone()), 168 + _ => (None, None), 168 169 }; 169 170 if fwd.as_ref().is_none_or(is_due) { 170 171 queue.push(Item { ··· 175 176 current: fwd, 176 177 }); 177 178 } 178 - // TODO: reverse side for dir: bi 179 + if matches!(dir, tala_format::Direction::Bidirectional) 180 + && rev.as_ref().is_none_or(is_due) 181 + { 182 + queue.push(Item { 183 + file_idx: fi, 184 + card_id: card_id.clone(), 185 + kind: card.kind.clone(), 186 + sub_id: "reverse".into(), 187 + current: rev, 188 + }); 189 + } 179 190 } 180 191 (CardKind::Cloze { blanks, .. }, sched) => { 181 192 let blank_schedules = match sched { ··· 221 232 item.card_id, 222 233 item.sub_id 223 234 ); 224 - print_card_preview(&item.kind); 235 + print_card_preview(&item.kind, &item.sub_id); 225 236 226 237 let grade = loop { 227 238 print!("Grade (1-4): "); ··· 304 315 reverse_schedule: None, 305 316 }); 306 317 if let CardSchedule::FrontBack { 307 - forward_schedule, .. 318 + forward_schedule, 319 + reverse_schedule, 308 320 } = entry 309 - && sub_id == "forward" 310 321 { 311 - *forward_schedule = Some(sched); 322 + match sub_id { 323 + "forward" => *forward_schedule = Some(sched), 324 + "reverse" => *reverse_schedule = Some(sched), 325 + _ => {} 326 + } 312 327 } 313 328 } 314 329 CardKind::Cloze { .. } => { ··· 326 341 } 327 342 } 328 343 329 - fn print_card_preview(kind: &CardKind) { 344 + fn print_card_preview(kind: &CardKind, sub_id: &str) { 330 345 match kind { 331 - CardKind::FrontBack { .. } => println!(" [front/back — render with tala-ui]"), 346 + CardKind::FrontBack { .. } => { 347 + let dir = if sub_id == "reverse" { "back → front" } else { "front → back" }; 348 + println!(" [front/back ({dir}) — render with tala-ui]"); 349 + } 332 350 CardKind::Cloze { .. } => println!(" [cloze — render with tala-ui]"), 333 351 } 334 352 }
+3 -3
crates/tala/src/main.rs
··· 1416 1416 let mut renaming = use_signal(|| false); 1417 1417 let mut rename_val = use_signal(|| stem.clone()); 1418 1418 let mut copied = use_signal(|| false); 1419 - let ext = path.extension().and_then(|e| e.to_str()).unwrap_or("png"); 1420 - let mime = match ext { "jpg" | "jpeg" => "image/jpeg", "gif" => "image/gif", "webp" => "image/webp", _ => "image/png" }; 1419 + let ext = path.extension().and_then(|e| e.to_str()).unwrap_or("png").to_owned(); 1420 + let mime = match ext.as_str() { "jpg" | "jpeg" => "image/jpeg", "gif" => "image/gif", "webp" => "image/webp", _ => "image/png" }; 1421 1421 let data_uri = std::fs::read(&path) 1422 1422 .map(|bytes| format!("data:{};base64,{}", mime, base64::engine::general_purpose::STANDARD.encode(&bytes))) 1423 1423 .unwrap_or_default(); ··· 1456 1456 if key == "Enter" { 1457 1457 let new_stem = rename_val.peek().trim().to_string(); 1458 1458 if !new_stem.is_empty() && new_stem != stem { 1459 - let new_path = path.with_file_name(format!("{}.png", new_stem)); 1459 + let new_path = path.with_file_name(format!("{}.{}", new_stem, ext)); 1460 1460 if std::fs::rename(&path, &new_path).is_ok() { 1461 1461 if let Ok(mut src) = std::fs::read_to_string(cards_path()) { 1462 1462 src = src.replace(