Adauga sectiune despre index.php, pick.php, tokens/, php.ini si tests/run_tests.php (ce face si cum se ruleaza). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
110 lines
6.6 KiB
Markdown
110 lines
6.6 KiB
Markdown
# CLAUDE.md
|
|
|
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
|
|
## Project Overview
|
|
|
|
Romfast company website (2025 version) for a Romanian ERP software company. Promotes ROA (Romfast Applications) — an ERP system covering accounting, inventory, HR, automotive service, and HORECA industries.
|
|
|
|
## Deploy
|
|
|
|
```bash
|
|
rsync -avz \
|
|
--exclude='.git' --exclude='.superdesign' --exclude='.claude' \
|
|
--exclude='verify-cleanup.sh' \
|
|
--exclude='efactura-generator/config.json' \
|
|
-e "ssh -p 7822" \
|
|
/home/moltbot/workspace/romfast-website/ \
|
|
romfastr@nl1-ss18.a2hosting.com:~/public_html/
|
|
```
|
|
|
|
- **Host:** nl1-ss18.a2hosting.com | **Port:** 7822 | **User:** romfastr
|
|
- **Document root:** `~/public_html/` — SSH key auth (no password)
|
|
- **Important:** rsync-ul NU folosește `--delete`, deci nu șterge nimic pe prod. `efactura-generator/config.json` e exclus explicit ca să nu poată fi suprascris niciodată din repo (conține `api_key` și e gestionat doar pe server).
|
|
|
|
## Sub-proiectul `efactura-generator/`
|
|
|
|
Directorul `efactura-generator/` din acest repo este o **oglindă** a proiectului canonic `/workspace/efactura-generator/` (repo separat: `git@gitea.romfast.ro:romfast/efactura-generator.git`). Sursa de adevăr e acolo.
|
|
|
|
**NU edita direct fișierele din `efactura-generator/` aici** — modificările se pierd la următorul sync. În schimb:
|
|
|
|
1. Editează în `/workspace/efactura-generator/` (repo canonic).
|
|
2. Rulează `/workspace/efactura-generator/sync-to-website.sh` care propagă schimbările în `efactura-generator/` din acest repo cu excluderile potrivite (fără `config.json`, fără Dockerfile, fără docs interne etc.).
|
|
3. Commit aici (`romfast-website`) și deploy cu rsync-ul de mai sus.
|
|
|
|
`config.json` de pe server (`~/public_html/efactura-generator/config.json`) conține `api_key` și nu e nici în repo, nici în sync — se gestionează manual pe a2hosting.
|
|
|
|
## Sub-proiectul `oauth2/`
|
|
|
|
Flux OAuth2 ANAF eFactura (obținere access/refresh token) folosit de aplicația desktop ROA/ROACONT. Deployat pe `https://romfast.ro/oauth2/`.
|
|
|
|
- **`index.php`** — endpoint principal, trei ramuri:
|
|
1. **Refresh token** (`refresh_token` primit prin `$_POST` sau `$_GET`) → passthrough curl către ANAF, întoarce JSON brut (folosit de butonul "Actualizare" din ROA).
|
|
2. **Intrare inițială** (fără `?code`) → redirect 302 către ANAF authorize. Dacă vine cu `?state=<64 hex>` salvează state-ul în sesiunea PHP (flux automat, legat de `pick.php`); fără `state` = flux manual/retro-compat (tokenurile apar direct în pagină).
|
|
3. **Callback ANAF** (`?code=...` sau `?error=...`) → schimb code→token; dacă există state valid în sesiune scrie fișier în `tokens/<sha256(state)>.json` (succes sau eroare) și afișează doar o pagină de confirmare; altfel (retro-compat) afișează access/refresh token direct în HTML.
|
|
- **`pick.php`** — endpoint de polling apelat de ROA cu `POST state=<64 hex>`. Răspunde `{"status":"pending"}` până apare fișierul de token, apoi îl livrează o singură dată (claim atomic prin `rename`) și îl șterge. TTL 600s pentru fișiere orfane/`.tmp`.
|
|
- **`tokens/`** — director de stocare temporară token/eroare, cheie = SHA-256(state). Protejat cu `.htaccess` (`Require all denied`); creat automat de `index.php`/`pick.php` dacă lipsește. Nu se commite conținutul (fișiere efemere, curățate de TTL).
|
|
- **`php.ini`** — config logging erori local pentru acest subdirector (`error_log = /oauth2/error_log.txt`).
|
|
- **`tests/run_tests.php`** — suită de teste self-contained (fără framework extern), acoperă `index.php` + `pick.php`. Rulare:
|
|
```bash
|
|
php oauth2/tests/run_tests.php
|
|
```
|
|
Ce face: copiază `index.php`/`pick.php` într-un director temporar (nu atinge `tokens/` din repo), pornește `php -S 127.0.0.1:8317` pe copie cu `session.save_path` propriu, rulează matricea de teste prin cereri HTTP reale (fără dependențe externe), oprește serverul și curăță totul la final (`register_shutdown_function`). Exit code 0 = toate testele au trecut; ieșirea arată `OK`/`FAIL` per test plus un rezumat `N trecute, M eșuate`. Notă: testele de refresh declanșează un apel curl real către `logincert.anaf.ro` cu un refresh_token fictiv (ANAF răspunde `invalid_grant`) — asercțiunile (nu e 302, `Content-Type` JSON) rămân valabile și offline.
|
|
|
|
## Development
|
|
|
|
No build process. Serve locally with:
|
|
|
|
```bash
|
|
python3 -m http.server 8000
|
|
# Access at http://localhost:8000
|
|
```
|
|
|
|
The `efactura-generator/` sub-app has its own Node.js server (rulează din repo-ul canonic, nu de aici):
|
|
|
|
```bash
|
|
cd /workspace/efactura-generator && node js/server.js
|
|
# Access at http://localhost:3000
|
|
```
|
|
|
|
## Architecture
|
|
|
|
### Static Website
|
|
|
|
- **Tailwind CSS** (CDN): `<script src="https://cdn.tailwindcss.com"></script>`
|
|
- **Flowbite** (CDN): component library on top of Tailwind
|
|
- **Lucide Icons** (CDN): icon set
|
|
- **Google Fonts**: Inter (primary), Merriweather (serif), JetBrains Mono
|
|
- **`professional-theme.css`**: main custom stylesheet — CSS custom properties, soft professional blue palette, dark mode variables
|
|
- **`professional-theme.js`**: handles dark mode toggle, mobile menu, Lucide icon init, scroll/card animations
|
|
|
|
### CSS Custom Properties (professional-theme.css)
|
|
|
|
```css
|
|
:root {
|
|
--soft-professional-blue: #5288c4; /* primary */
|
|
--gentle-trust-blue: #4a7ba7; /* secondary */
|
|
--muted-accent-red: #b85555; /* accent */
|
|
--executive-navy: #2c3e50; /* text */
|
|
--navbar-bg: linear-gradient(135deg, #2c3e50, #4a7ba7);
|
|
}
|
|
```
|
|
|
|
Dark mode activated via `body.dark-mode` class — toggled by `professional-theme.js`.
|
|
|
|
### Navigation Pattern
|
|
|
|
The navbar HTML is **manually duplicated** across every page (no templating). When updating nav links, update all files. Path to CSS/JS assets is relative — top-level pages use `professional-theme.css`, subdirectory pages use `../professional-theme.css`.
|
|
|
|
### Content Structure
|
|
|
|
- `/` — homepage (`index.html`)
|
|
- `/menu/` — company pages (about, contact, support, services, jobs, references)
|
|
- `/roa/` — ROA ERP product pages (one per module)
|
|
- `/efactura-generator/` — standalone Romanian e-invoice editor (loads XML, edits, prints, exports XML)
|
|
- `/oauth2/` — ANAF eFactura OAuth2 token flow for the ROA desktop app (see "Sub-proiectul `oauth2/`" above)
|
|
|
|
### efactura-generator
|
|
|
|
Separate single-page app at `efactura-generator/index.html`. Has its own CSS (`styles/main.css`), JS (`js/script.js`, `js/formatter.js`, `js/print.js`), print templates (`templates/print.html`, `templates/print-compact.html`), and optional Node.js dev server (`js/server.js`). Also deployed as GitHub Pages at `romfast.github.io/efactura-generator/`.
|