Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e8d81a0cb | ||
|
|
f8731553c1 | ||
|
|
1d96c38640 |
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import type { Box } from "../composition/compose.js";
|
||||
|
||||
/** Soft crop after folding develop commands (autopilot or human). */
|
||||
export interface FoldedCrop {
|
||||
rect: Box;
|
||||
angle: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Soft crop geometry of a correction: final minus autopilot (centre shift, size, straighten).
|
||||
* Kept out of `learning.ts` so the desktop app can typecheck `planFrame` without Prisma.
|
||||
*/
|
||||
export interface CropBias {
|
||||
dx: number;
|
||||
dy: number;
|
||||
/** Linear size: 1 = same area, >1 looser, <1 tighter. */
|
||||
scale: number;
|
||||
dAngle: number;
|
||||
scene: "ball" | "group" | "person" | null;
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
import type { EditCommand } from "@photoreport/contracts";
|
||||
import type { Db } from "../db.js";
|
||||
import type { Box } from "../composition/compose.js";
|
||||
import type { CropBias, FoldedCrop } from "./cropBias.js";
|
||||
import { TONE_KEYS, WB_KEYS } from "./look.js";
|
||||
|
||||
export type { CropBias, FoldedCrop } from "./cropBias.js";
|
||||
export { TONE_KEYS, WB_KEYS };
|
||||
|
||||
/**
|
||||
@@ -40,26 +42,11 @@ const CROP_SCENE = "__crop.scene";
|
||||
const SCENE_CODE: Record<"ball" | "group" | "person", number> = { ball: 1, group: 2, person: 3 };
|
||||
const SCENE_FROM: Record<number, "ball" | "group" | "person"> = { 1: "ball", 2: "group", 3: "person" };
|
||||
|
||||
export interface FoldedCrop {
|
||||
rect: Box;
|
||||
angle: number;
|
||||
}
|
||||
|
||||
export interface FoldedEdits {
|
||||
values: Record<string, number>;
|
||||
crop: FoldedCrop | null;
|
||||
}
|
||||
|
||||
/** Soft crop geometry of a correction: final minus autopilot (centre shift, size, straighten). */
|
||||
export interface CropBias {
|
||||
dx: number;
|
||||
dy: number;
|
||||
/** Linear size: 1 = same area, >1 looser, <1 tighter. */
|
||||
scale: number;
|
||||
dAngle: number;
|
||||
scene: "ball" | "group" | "person" | null;
|
||||
}
|
||||
|
||||
/** Settings after these commands, as far as the autopilot's controls go (merges of whole presets are ignored). */
|
||||
export function fold(commands: EditCommand[]): FoldedEdits {
|
||||
let values: Record<string, number> = {};
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { EditCommand } from "@photoreport/contracts";
|
||||
import { type Box, type Detections, type FocusHint, clipsBall, compose, minCropWidth, planCrop } from "./compose.js";
|
||||
import { biasCrop, constrainRotated, tighter } from "./geometry.js";
|
||||
import { type Look, WB_KEYS, TONE_KEYS, detailForCrop, lookValues, toneApplied } from "../autopilot/look.js";
|
||||
import type { CropBias } from "../autopilot/learning.js";
|
||||
import type { CropBias } from "../autopilot/cropBias.js";
|
||||
|
||||
/** Straightening beyond this is more likely a creative tilt than a crooked horizon (matches the engine's band). */
|
||||
const MAX_LEVEL = 8;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@photoreport/desktop",
|
||||
"version": "0.3.28",
|
||||
"version": "0.3.29",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "photoreport-desktop"
|
||||
version = "0.3.28"
|
||||
version = "0.3.29"
|
||||
edition = "2024"
|
||||
publish = false
|
||||
description = "PhotoReport desktop: the web app in a native shell, with keychain sign-in and (later) local FTP and the native engine."
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "PhotoReport",
|
||||
"version": "0.3.28",
|
||||
"version": "0.3.29",
|
||||
"identifier": "pt.photoreport.desktop",
|
||||
"build": {
|
||||
"devUrl": "http://localhost:5173",
|
||||
|
||||
@@ -197,12 +197,29 @@ function fill(template: string, vars: TemplateVars, codes: CodeList | undefined,
|
||||
return expanded.text;
|
||||
}
|
||||
|
||||
/** Collapse the spaces an empty variable leaves behind. Missing variables are always reported as issues. */
|
||||
/**
|
||||
* Collapse the holes an empty variable leaves behind. Missing variables are always reported as issues.
|
||||
* The newsroom caption is "{event}, em {city}, no {venue}": without city/venue that must not become
|
||||
* "AFS x FC Vizela, em , no" on a client delivery.
|
||||
*/
|
||||
function tidy(value: string): string {
|
||||
// A match template on an event without an away team: "Gala x , em Braga" → "Gala, em Braga".
|
||||
return value
|
||||
.replace(/\s{2,}/g, " ")
|
||||
// Match template on an event without an away team: "Gala x , em Braga" → "Gala, em Braga".
|
||||
.replace(/\s+x\s*(?=,|$)/g, "")
|
||||
// City missing, venue kept: ", em , no Estádio" → ", no Estádio" (keep the article).
|
||||
.replace(/,\s*em\s*,\s*(n[oa]s?\s+)/gi, ", $1")
|
||||
// Both city and venue missing: trailing ", em , no" / ", em , na".
|
||||
.replace(/,\s*em\s*,\s*n[oa]s?\s*$/gi, "")
|
||||
// Leftover empty city slot: ", em ,".
|
||||
.replace(/,\s*em\s*,/gi, ",")
|
||||
// Venue missing at the end: ", em Braga, no" → ", em Braga".
|
||||
.replace(/,\s*n[oa]s?\s*$/gi, "")
|
||||
// Orphan "em" at the end: ", em".
|
||||
.replace(/,\s*em\s*$/gi, "")
|
||||
.replace(/\s{2,}/g, " ")
|
||||
.replace(/,\s*$/g, "")
|
||||
.replace(/^\s*,\s*/g, "")
|
||||
.trim();
|
||||
}
|
||||
|
||||
|
||||
@@ -99,6 +99,30 @@ describe("IPTC template", () => {
|
||||
expect(old.event).toBe("Conferência de imprensa do FC Porto");
|
||||
});
|
||||
|
||||
it("does not send a broken Portuguese caption when city and venue are missing", () => {
|
||||
// Delivered to Cofina as "AFS x FC Vizela, em , no" — unusable in the newsroom.
|
||||
const game = { home: "AFS", away: "FC Vizela", venue: "", city: "", sport: "futebol", startsAt: new Date("2026-11-04T20:00:00Z") };
|
||||
const { values, issues } = applyTemplate(NEWSROOM_TEMPLATE, buildVars(game, { players: ["Rodrigo Pinho"] }, "MovePhoto"));
|
||||
expect(values.caption).toBe("AFS x FC Vizela");
|
||||
expect(values.headline).toBe("AFS x FC Vizela");
|
||||
expect(values.event).toBe("AFS x FC Vizela");
|
||||
expect(values.city).toBeUndefined();
|
||||
expect(values.location).toBeUndefined();
|
||||
expect(issues.filter((i) => i.kind === "missing_variable").map((i) => i.detail).sort()).toEqual([
|
||||
"city",
|
||||
"city",
|
||||
"city",
|
||||
"venue",
|
||||
"venue",
|
||||
"venue",
|
||||
]);
|
||||
// Only one of city / venue filled: keep the clause that still makes sense.
|
||||
expect(applyTemplate(NEWSROOM_TEMPLATE, buildVars({ ...game, city: "Vizela" }, {}, "P")).values.caption).toBe("AFS x FC Vizela, em Vizela");
|
||||
expect(applyTemplate(NEWSROOM_TEMPLATE, buildVars({ ...game, venue: "Estádio do FC Vizela" }, {}, "P")).values.caption).toBe(
|
||||
"AFS x FC Vizela, no Estádio do FC Vizela",
|
||||
);
|
||||
});
|
||||
|
||||
it("expands codes typed by an editor and keeps long venues whole", () => {
|
||||
const { values, issues } = applyTemplate({ title: "\\v7\\", location: "{venue}" }, buildVars(braga), codeList({ v7: "Miguel Silva (VSC)" }));
|
||||
expect(values.title).toBe("Miguel Silva (VSC)");
|
||||
|
||||
Reference in new issue
Block a user