|
| 1 | +'use client'; |
| 2 | + |
| 3 | +/** |
| 4 | + * In-app documentation. Bilingual (fr/en) content picked from the active language; kept inline |
| 5 | + * here rather than in the global i18n dictionary since it's long-form and page-local. |
| 6 | + */ |
| 7 | +import { |
| 8 | + FolderLock, |
| 9 | + Zap, |
| 10 | + KeyRound, |
| 11 | + Webhook, |
| 12 | + HardDrive, |
| 13 | + Keyboard, |
| 14 | + Globe, |
| 15 | + type LucideIcon, |
| 16 | +} from 'lucide-react'; |
| 17 | +import { API_URL } from '@/lib/api'; |
| 18 | +import { useT } from '@/lib/i18n'; |
| 19 | + |
| 20 | +type Block = { p: string } | { code: string } | { ul: string[] }; |
| 21 | +interface Section { |
| 22 | + icon: LucideIcon; |
| 23 | + title: string; |
| 24 | + blocks: Block[]; |
| 25 | +} |
| 26 | + |
| 27 | +export default function DocsPage() { |
| 28 | + const { lang } = useT(); |
| 29 | + const L = (fr: string, en: string) => (lang === 'fr' ? fr : en); |
| 30 | + |
| 31 | + const sections: Section[] = [ |
| 32 | + { |
| 33 | + icon: FolderLock, |
| 34 | + title: L('Espaces & coffres', 'Spaces & vaults'), |
| 35 | + blocks: [ |
| 36 | + { |
| 37 | + p: L( |
| 38 | + 'Un espace est un dossier de premier niveau. Deux types : « normal » (chiffré côté serveur, AES-256-GCM — analysable par l’antivirus, partageable, aperçu) et « sécurisé » Zero-Knowledge (chiffré dans votre navigateur avec une phrase de passe que le serveur ne voit jamais).', |
| 39 | + 'A space is a top-level folder. Two kinds: “normal” (encrypted server-side with AES-256-GCM — antivirus-scannable, shareable, previewable) and a “secured” Zero-Knowledge vault (encrypted in your browser with a passphrase the server never sees).', |
| 40 | + ), |
| 41 | + }, |
| 42 | + { |
| 43 | + p: L( |
| 44 | + '⚠️ La phrase de passe d’un coffre est irrécupérable : si vous l’oubliez, le contenu est perdu. Les coffres ne sont ni partageables, ni accessibles par l’API/WebDAV (le serveur ne peut pas les déchiffrer).', |
| 45 | + '⚠️ A vault passphrase is unrecoverable: if you forget it, the contents are lost. Vaults can’t be shared, nor reached via the API/WebDAV (the server can’t decrypt them).', |
| 46 | + ), |
| 47 | + }, |
| 48 | + ], |
| 49 | + }, |
| 50 | + { |
| 51 | + icon: Zap, |
| 52 | + title: L('Quick-Upload', 'Quick-Upload'), |
| 53 | + blocks: [ |
| 54 | + { |
| 55 | + p: L( |
| 56 | + 'Créez un code dans Compte ▸ Codes Quick-Upload. N’importe qui (sans compte) peut alors déposer des fichiers dans le dossier choisi via le lien /q?code=…, ou par script :', |
| 57 | + 'Create a code in Account ▸ Quick-Upload codes. Anyone (no account) can then drop files into the chosen folder via the /q?code=… link, or by script:', |
| 58 | + ), |
| 59 | + }, |
| 60 | + { code: `curl -F "file=@photo.jpg" ${API_URL}/quick/MONCODE` }, |
| 61 | + { |
| 62 | + p: L( |
| 63 | + 'Options par code : mot de passe, expiration, limite d’utilisations. Les codes sont uniques (ils routent vers votre compte).', |
| 64 | + 'Per-code options: password, expiry, usage limit. Codes are unique (they route to your account).', |
| 65 | + ), |
| 66 | + }, |
| 67 | + ], |
| 68 | + }, |
| 69 | + { |
| 70 | + icon: KeyRound, |
| 71 | + title: L('Jetons d’API (REST)', 'API tokens (REST)'), |
| 72 | + blocks: [ |
| 73 | + { |
| 74 | + p: L( |
| 75 | + 'Pour automatiser votre compte (scripts, sauvegardes, CI). Créez un jeton dans Compte ▸ Jetons d’API (scopes lecture/écriture, dossier et expiration optionnels). Le jeton n’est affiché qu’une fois.', |
| 76 | + 'To automate your account (scripts, backups, CI). Create a token in Account ▸ API tokens (read/write scopes, optional folder and expiry). The token is shown once.', |
| 77 | + ), |
| 78 | + }, |
| 79 | + { |
| 80 | + code: `# Vérifier le jeton, lister les dossiers, envoyer un fichier |
| 81 | +curl -H "Authorization: Bearer ocl_…" ${API_URL}/api/v1/me |
| 82 | +curl -H "Authorization: Bearer ocl_…" ${API_URL}/api/v1/folders |
| 83 | +curl -H "Authorization: Bearer ocl_…" -F "file=@backup.tgz" \\ |
| 84 | + "${API_URL}/api/v1/files?folderId=<ID>"`, |
| 85 | + }, |
| 86 | + { |
| 87 | + p: L( |
| 88 | + 'Endpoints : GET /me, GET+POST /folders, GET+POST /files, GET /files/:id/download. Coffres exclus.', |
| 89 | + 'Endpoints: GET /me, GET+POST /folders, GET+POST /files, GET /files/:id/download. Vaults excluded.', |
| 90 | + ), |
| 91 | + }, |
| 92 | + ], |
| 93 | + }, |
| 94 | + { |
| 95 | + icon: HardDrive, |
| 96 | + title: L('WebDAV (disque réseau)', 'WebDAV (network drive)'), |
| 97 | + blocks: [ |
| 98 | + { |
| 99 | + p: L( |
| 100 | + 'Montez vos espaces normaux comme un disque réseau (Finder, Explorateur Windows, rclone, Cyberduck).', |
| 101 | + 'Mount your normal spaces as a network drive (Finder, Windows Explorer, rclone, Cyberduck).', |
| 102 | + ), |
| 103 | + }, |
| 104 | + { code: `URL : ${API_URL}/dav/\n${L('Identifiant', 'Username')} : ${L('votre e-mail (ignoré)', 'your email (ignored)')}\n${L('Mot de passe', 'Password')} : ${L('un jeton d’API (lecture + écriture)', 'an API token (read + write)')}` }, |
| 105 | + { |
| 106 | + p: L( |
| 107 | + 'Astuce : testez d’abord avec rclone ou Cyberduck (plus tolérants que l’Explorateur Windows). En HTTPS uniquement.', |
| 108 | + 'Tip: test first with rclone or Cyberduck (more forgiving than Windows Explorer). HTTPS only.', |
| 109 | + ), |
| 110 | + }, |
| 111 | + ], |
| 112 | + }, |
| 113 | + { |
| 114 | + icon: Webhook, |
| 115 | + title: L('Webhooks', 'Webhooks'), |
| 116 | + blocks: [ |
| 117 | + { |
| 118 | + p: L( |
| 119 | + 'Recevez un POST sur une URL à vous quand un fichier arrive (filtre par dossier possible). Le corps est signé en HMAC-SHA256 si vous définissez un secret (en-tête X-OpenCoperLock-Signature).', |
| 120 | + 'Get a POST to your own URL when a file arrives (optionally per folder). The body is HMAC-SHA256 signed if you set a secret (header X-OpenCoperLock-Signature).', |
| 121 | + ), |
| 122 | + }, |
| 123 | + { code: `{ "event": "file.created", "at": "…", "file": { "id": "…", "name": "…", "sizeBytes": 123 } }` }, |
| 124 | + ], |
| 125 | + }, |
| 126 | + { |
| 127 | + icon: Keyboard, |
| 128 | + title: L('Raccourcis clavier (Drive)', 'Keyboard shortcuts (Drive)'), |
| 129 | + blocks: [ |
| 130 | + { |
| 131 | + ul: [ |
| 132 | + L('Ctrl/⌘ + K — palette : rechercher fichiers, dossiers, actions', 'Ctrl/⌘ + K — palette: search files, folders, actions'), |
| 133 | + L('↑ ↓ naviguer · Entrée ouvrir · Retour arrière remonter', '↑ ↓ navigate · Enter open · Backspace go up'), |
| 134 | + L('Ctrl/⌘ + A tout sélectionner · Suppr corbeille · F2 renommer', 'Ctrl/⌘ + A select all · Delete trash · F2 rename'), |
| 135 | + L('Ctrl/⌘ + C / X / V / D copier / couper / coller / dupliquer', 'Ctrl/⌘ + C / X / V / D copy / cut / paste / duplicate'), |
| 136 | + L('Échap retour · clic droit menu · appui long (mobile) sélectionner', 'Esc back · right-click menu · long-press (mobile) to select'), |
| 137 | + ], |
| 138 | + }, |
| 139 | + ], |
| 140 | + }, |
| 141 | + { |
| 142 | + icon: Globe, |
| 143 | + title: L('Remote-Upload', 'Remote-Upload'), |
| 144 | + blocks: [ |
| 145 | + { |
| 146 | + p: L( |
| 147 | + 'Collez un lien : le serveur télécharge le fichier directement (protégé contre le SSRF), pratique depuis un appareil à connexion limitée.', |
| 148 | + 'Paste a link: the server fetches the file directly (SSRF-guarded), handy from a device on a limited connection.', |
| 149 | + ), |
| 150 | + }, |
| 151 | + ], |
| 152 | + }, |
| 153 | + ]; |
| 154 | + |
| 155 | + return ( |
| 156 | + <div className="mx-auto max-w-3xl space-y-6"> |
| 157 | + <div> |
| 158 | + <h1 className="text-2xl font-semibold tracking-tight text-white">{L('Documentation', 'Documentation')}</h1> |
| 159 | + <p className="mt-1 text-sm text-zinc-500"> |
| 160 | + {L('Tout ce que vous pouvez faire avec OpenCoperLock.', 'Everything you can do with OpenCoperLock.')} |
| 161 | + </p> |
| 162 | + </div> |
| 163 | + |
| 164 | + {sections.map((s) => ( |
| 165 | + <section key={s.title} className="card space-y-3"> |
| 166 | + <div className="flex items-center gap-2.5"> |
| 167 | + <span className="grid h-9 w-9 place-items-center rounded-lg bg-accent-soft text-violet-300"> |
| 168 | + <s.icon size={18} /> |
| 169 | + </span> |
| 170 | + <h2 className="font-semibold text-zinc-100">{s.title}</h2> |
| 171 | + </div> |
| 172 | + {s.blocks.map((b, i) => |
| 173 | + 'p' in b ? ( |
| 174 | + <p key={i} className="text-sm leading-relaxed text-zinc-400"> |
| 175 | + {b.p} |
| 176 | + </p> |
| 177 | + ) : 'code' in b ? ( |
| 178 | + <pre key={i} className="overflow-auto rounded-lg border border-white/[0.06] bg-ink-950/60 p-3 font-mono text-xs leading-relaxed text-zinc-200"> |
| 179 | + {b.code} |
| 180 | + </pre> |
| 181 | + ) : ( |
| 182 | + <ul key={i} className="list-disc space-y-1 pl-5 text-sm leading-relaxed text-zinc-400"> |
| 183 | + {b.ul.map((li) => ( |
| 184 | + <li key={li}>{li}</li> |
| 185 | + ))} |
| 186 | + </ul> |
| 187 | + ), |
| 188 | + )} |
| 189 | + </section> |
| 190 | + ))} |
| 191 | + </div> |
| 192 | + ); |
| 193 | +} |
0 commit comments