caelum0x f80b04ae0f feat(ritgram): move GitGram app into railyard as Ritgram, next to Rithub
Moved later/gitgram-ai/gitgram/ to apps/ritgram/ (fresh history; full history stays in caelum0x/gitgram).
AITimeMachine stays separate in later/gitgram-ai per the Rithub master plan.
Logs, pid files and env files are ignored; GPL-3.0 mobile/proximity noted in THIRD_PARTY_NOTICES.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-13 04:18:46 +03:00

39 lines
1.3 KiB
TypeScript

/**
* Alt-text preferences, ported from Bluesky's `alt-text-required` preference to
* the product's stack. The "require alt text" flag is stored alongside the
* existing accessibility settings (localStorage key
* `gitgram:accessibility-settings`) so it survives reloads without a dedicated
* backend endpoint, and is read by the composer to optionally block posting
* media that has no description.
*/
const ACCESSIBILITY_STORAGE_KEY = 'gitgram:accessibility-settings'
/** Max length for a single image description (mirrors Bluesky's 2000 cap). */
export const MAX_ALT_TEXT_LENGTH = 2000
interface AltTextPreferenceShape {
requireAltText?: boolean
}
/**
* Whether the user has opted into being required to add alt text before posting
* media. Defaults to `false` when unset or unavailable (SSR / private mode).
*/
export function isAltTextRequired(): boolean {
if (typeof window === 'undefined') return false
try {
const raw = window.localStorage.getItem(ACCESSIBILITY_STORAGE_KEY)
if (!raw) return false
const parsed = JSON.parse(raw) as AltTextPreferenceShape
return parsed.requireAltText === true
} catch {
return false
}
}
/** Normalizes a raw alt-text input: trims and clamps to the max length. */
export function normalizeAltText(value: string): string {
return value.trim().slice(0, MAX_ALT_TEXT_LENGTH)
}