Download app/core.cjs from Devseis/Ora: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/spaces/Devseis/Ora/resolve/main/app/core.cjs
- Command line
-
hf download hf://spaces/Devseis/Ora/app/core.cjs
-
curl -L -o core.cjs https://huggingface.co/spaces/Devseis/Ora/resolve/main/app/core.cjs
1.42 kB
| ; | |
| // Pure helpers for Ora's main process (no Electron here, so test/core.test.cjs can run them with plain Node). | |
| function slug(text, max = 40) { | |
| return (text || 'picture').toLowerCase().normalize('NFKD').replace(/[^\w\s-]/g, '').trim() | |
| .replace(/[\s_-]+/g, '-').slice(0, max).replace(/-+$/, '') || 'picture'; | |
| } | |
| // Folder-safe name: letters, digits, spaces and dashes only, on every system. | |
| function folderName(text, max = 60) { | |
| const clean = String(text || '').normalize('NFKD').replace(/[^\w\s-]/g, ' ').replace(/_/g, ' ').replace(/\s+/g, ' ').trim(); | |
| return clean.slice(0, max).trim() || 'Plan'; | |
| } | |
| // A batch of pictures ("Make the month's posts" is up to 30): folder, position and title of one picture in it. | |
| const MAX_JOBS = 30; | |
| function validateProject(p) { | |
| if (p === undefined) return []; | |
| const errors = []; | |
| if (!p || typeof p !== 'object') return ['bad project']; | |
| if (typeof p.folder !== 'string' || !/^[\w -]{1,80}$/.test(p.folder)) errors.push('bad project folder'); | |
| if (!Number.isInteger(p.total) || p.total < 1 || p.total > MAX_JOBS) errors.push('bad picture count'); | |
| if (!Number.isInteger(p.index) || p.index < 1 || p.index > p.total) errors.push('bad picture number'); | |
| if (typeof p.title !== 'string' || p.title.length > 300) errors.push('bad picture title'); | |
| return errors; | |
| } | |
| module.exports = { slug, folderName, validateProject, MAX_JOBS }; | |