~ knotless Search/
↑↓ move↵ open⇧↵ all results

grain.social/grain

photography-focused photo sharing platform

grain.social
1 collaborator
0
2

Photos post on PDSes that still require alt

Merged chadtmiller.com asked to merge into feature/rust from grain.social/grain:fix/rust-photo-alt-always

Only what this pull adds. It is built on grain runs on a Rust server modelled on knotless, without hatk.

crates/grain-serve/src/spaces/pool.rs+2−4
@@ -106,15 +106,13 @@ fn gallery_writes(
)];
for (n, photo) in photos.into_iter().enumerate() {
let key = format!("{rkey}-{n}");
let mut record = json!({
let record = json!({
"$type": PHOTO,
"photo": photo.photo,
"alt": photo.alt.unwrap_or_default(),
"aspectRatio": photo.aspect_ratio,
"createdAt": now,
});
if let Some(alt) = photo.alt {
record["alt"] = alt.into();
}
writes.push(space::create(PHOTO, &key, checked(app, PHOTO, record)?));
let item = json!({
"$type": ITEM,
web/src/routes/create/+page.svelte+1−1
@@ -263,7 +263,7 @@
createWrite('social.grain.photo', photoRkeys[i], {
photo: blobs[i],
aspectRatio: { width: photo.width, height: photo.height },
...(photo.alt ? { alt: photo.alt } : {}),
alt: photo.alt || '',
createdAt: now,
}),
),
web/src/routes/profile/[actor]/gallery/[rkey]/edit/+page.svelte+2−2
@@ -354,7 +354,7 @@ import type { PhotoView } from '$lib/lexicons/social/grain/photo/defs.ts'
createWrite('social.grain.photo', photoRkey, {
photo: blobBySlot.get(i),
aspectRatio: { width: slot.processed.width, height: slot.processed.height },
...(slot.processed.alt ? { alt: slot.processed.alt } : {}),
alt: slot.processed.alt || '',
createdAt: now,
}),
)
@@ -389,7 +389,7 @@ import type { PhotoView } from '$lib/lexicons/social/grain/photo/defs.ts'
updateWrite('social.grain.photo', photoRkey, {
photo: blobBySlot.get(i),
aspectRatio: { width: slot.replacement.width, height: slot.replacement.height },
...(slot.view.alt ? { alt: slot.view.alt } : {}),
alt: slot.view.alt || '',
createdAt: (slot.view as any).record?.createdAt ?? now,
}),
)
web/src/routes/settings/import/+page.svelte+1−0
@@ -117,6 +117,7 @@
createWrite('social.grain.photo', photoRkeys[i], {
photo: blobs[i],
aspectRatio: { width: photo.width, height: photo.height },
alt: '',
createdAt,
}),
),
AGENTS.md+6−0
@@ -145,6 +145,12 @@ be dropped; a description on any field whose name does not say what it
holds; `maxGraphemes` beside `maxLength` for text people read; reuse of
`social.grain.defs` and `com.atproto.repo.strongRef` over new shapes.
Publishing a schema does not reach every PDS. `@atproto/pds` validates writes
against copies compiled into the server (`validateRecord` in
`packages/pds/src/repo/prepare.ts`), and its `social.grain.photo` requires
`alt`, so a photo with no description sends `alt: ""`. A write has to stay
valid against what those servers ship until they upgrade.
## Project structure
| Directory | Purpose |