- JavaScript 72.7%
- SCSS 25.5%
- HTML 1.7%
- Dockerfile 0.1%
| public | ||
| src | ||
| systemd | ||
| tests | ||
| .drone.yml | ||
| .gitignore | ||
| .prettierrc | ||
| bun.lockb | ||
| Dockerfile | ||
| index.html | ||
| package.json | ||
| pnpm-lock.yaml | ||
| README.md | ||
| vite.config.js | ||
Orario
Sito per visualizzare l'orario delle lezioni per i vari anni di corso.
Usage
You need to have installed node and npm (or pnpm). To setup the project just run npm install.
Development
To start the development server run npm run dev.
Editor
È meglio se prima di fare commit il codice sia formattato con Prettier, nel caso di VSCode c'è un'estensione omonima e le opzioni da aggiungere al proprio JSON di impostazioni sono
...
"prettier.printWidth": 100,
"prettier.singleQuote": true,
"prettier.quoteProps": "consistent",
"prettier.tabWidth": 4,
"prettier.semi": false,
"prettier.arrowParens": "avoid",
"editor.formatOnSave": true,
...
Production
To build the ViteJS project run npm run build, for deployment a .env file can be used to set the BASE_URL variable.
Semester Timetable Data & Automated Updates
The timetable IDs and semester dates are stored in semester-data.json.
The client application loads semester-data.json with a Stale-While-Revalidate / Fallback pattern:
- The bundled
src/semester-data.jsonis used as an immediate fallback (ensuring instant render and offline availability). - On startup, the client dynamically fetches
/semester-data.json(hourly cache-busted). If new IDs or dates are published, the UI updates automatically without needing to rebuild or redeploy the frontend bundle.
Updating Semester Data
To manually check and update semester data:
# Update both src/semester-data.json and public/semester-data.json
npm run update-data
# Or run directly with custom output path(s)
node src/scripts/update-semester-data.js --output /var/www/orario/semester-data.json
# Check without modifying files (exits with code 1 if updates found, 0 if up to date)
node src/scripts/update-semester-data.js --check
Automated Daily Host Updates
To ensure the production site always has up-to-date timetable IDs each semester without manual commits, set up a daily check on the server hosting /var/www/orario.
Option 1: Systemd Timer (Recommended)
- Copy the systemd unit files to
/etc/systemd/system/:sudo cp systemd/orario-update.service /etc/systemd/system/ sudo cp systemd/orario-update.timer /etc/systemd/system/ - In
/etc/systemd/system/orario-update.service, ensure theExecStartpath points to your repository's update script and your webroot target, for example:ExecStart=/usr/bin/node /home/fra/tech/phc/orario/src/scripts/update-semester-data.js --output /var/www/orario/semester-data.json --quiet - Enable and start the timer:
sudo systemctl daemon-reload sudo systemctl enable --now orario-update.timer - Verify status:
systemctl list-timers | grep orario
Option 2: Standard Cron (crontab -e)
Add a daily cron entry to the caddy (or deployment) user's crontab:
crontab -e
Add the following line (runs daily at 04:30 AM):
30 4 * * * /usr/bin/node /home/fra/tech/phc/orario/src/scripts/update-semester-data.js --output /var/www/orario/semester-data.json --quiet >> /var/log/orario-update.log 2>&1