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.json is 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.

  1. 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/
    
  2. In /etc/systemd/system/orario-update.service, ensure the ExecStart path 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
    
  3. Enable and start the timer:
    sudo systemctl daemon-reload
    sudo systemctl enable --now orario-update.timer
    
  4. 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
S
Description
Sito web statico per visualizzare gli orari delle lezioni e creare specchietti personalizzati
Readme
463 KiB
Languages
JavaScript 72.7%
SCSS 25.5%
HTML 1.7%
Dockerfile 0.1%