docs+tests: Document and test references section shortcut URLs

## Documentation Updates (doc/11-PDF-EXPORT.md)
Added "References Section Integration" section with:
- Template code examples for shortcut URL usage
- Data configuration structure
- Key features and use cases
- Security attributes documentation
- Test command reference

## Test Updates (tests/mjs/28-references-pdf-download.test.mjs)
Completely rewrote test to match new direct link behavior:
-  OLD: Tested modal opening, onclick handlers
-  NEW: Tests direct shortcut URLs

New test coverage (5 tests):
1. English direct shortcut URL validation
2. Spanish direct shortcut URL validation
3. HTTP 301 redirect verification
4. Year validation (404 for invalid years)
5. Works without JavaScript (PDF export context)

Verifies:
- Correct href: /cv-jamr-{year}-{lang}.pdf
- No onclick handlers (pure HTML link)
- Security attributes (target="_blank", rel="noopener noreferrer")
- Year-aware dynamic URLs
- Language-aware (es/en)
- Backend 301 redirects working
- 404 for past/future years

## Benefits
- Comprehensive test coverage for new behavior
- Complete documentation with examples
- Easy to maintain and understand
- Validates entire shortcut URL feature end-to-end
This commit is contained in:
juanatsap
2025-11-20 12:43:29 +00:00
parent f25f2de8b3
commit 16194328b6
2 changed files with 172 additions and 279 deletions
+41
View File
@@ -710,8 +710,49 @@ curl -I http://localhost:1999/cv-jamr-2025-en.pdf
# Test invalid year (should fail)
curl -I http://localhost:1999/cv-jamr-2024-en.pdf
# Expected: HTTP/1.1 404 Not Found
# Run automated test
bun tests/mjs/28-references-pdf-download.test.mjs
```
### References Section Integration
The shortcut URLs are integrated into the **References section** of the CV for easy access:
**Template Integration** (`templates/partials/sections/references.html`):
```html
{{if eq .Action "downloadPDF"}}
<a href="/cv-jamr-{{$.CurrentYear}}-{{$.Lang}}.pdf"
target="_blank"
rel="noopener noreferrer">
<strong>{{.LinkText}}</strong>
</a>
{{end}}
```
**Data Configuration** (`data/cv-en.json`, `data/cv-es.json`):
```json
{
"title": "Download this curriculum in English",
"action": "downloadPDF",
"textBefore": "Download this curriculum in",
"linkText": "English"
}
```
**Key Features:**
- **Direct link** - No modal, no JavaScript dependency
- **Language-aware** - Spanish CV gets Spanish link, English CV gets English link
- **Year-aware** - Automatically uses current year
- **Works everywhere** - PDF exports, emails, external shares
- **Security** - Proper `target="_blank"` and `rel="noopener noreferrer"` attributes
**Use Cases:**
- ✅ Works in printed PDFs (link remains functional)
- ✅ Works in email clients (direct download link)
- ✅ Works without JavaScript (static HTML link)
- ✅ Works when shared externally (permanent, memorable URL)
## Design Philosophy
### Why This Naming Convention?