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>
6.6 KiB
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
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.jsone exclus explicit ca să nu poată fi suprascris niciodată din repo (conțineapi_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:
- Editează în
/workspace/efactura-generator/(repo canonic). - Rulează
/workspace/efactura-generator/sync-to-website.shcare propagă schimbările înefactura-generator/din acest repo cu excluderile potrivite (fărăconfig.json, fără Dockerfile, fără docs interne etc.). - 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:- Refresh token (
refresh_tokenprimit prin$_POSTsau$_GET) → passthrough curl către ANAF, întoarce JSON brut (folosit de butonul "Actualizare" din ROA). - 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 depick.php); fărăstate= flux manual/retro-compat (tokenurile apar direct în pagină). - Callback ANAF (
?code=...sau?error=...) → schimb code→token; dacă există state valid în sesiune scrie fișier întokens/<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.
- Refresh token (
pick.php— endpoint de polling apelat de ROA cuPOST state=<64 hex>. Răspunde{"status":"pending"}până apare fișierul de token, apoi îl livrează o singură dată (claim atomic prinrename) ș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 deindex.php/pick.phpdacă 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:Ce face: copiazăphp oauth2/tests/run_tests.phpindex.php/pick.phpîntr-un director temporar (nu atingetokens/din repo), porneștephp -S 127.0.0.1:8317pe copie cusession.save_pathpropriu, 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/FAILper test plus un rezumatN trecute, M eșuate. Notă: testele de refresh declanșează un apel curl real cătrelogincert.anaf.rocu un refresh_token fictiv (ANAF răspundeinvalid_grant) — asercțiunile (nu e 302,Content-TypeJSON) rămân valabile și offline.
Development
No build process. Serve locally with:
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):
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 variablesprofessional-theme.js: handles dark mode toggle, mobile menu, Lucide icon init, scroll/card animations
CSS Custom Properties (professional-theme.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-proiectuloauth2/" 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/.