Remove server-side auth files (.htaccess, auth.php, login.php, logout.php, SECURITY_SETUP.md) and replace index.php with static index.html. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| .gitignore | ||
| config.php | ||
| index.html | ||
| README.md | ||
OMG Static - H&M Agent
A comprehensive web-based tool for managing H&M documents through the One2Edit API. This application provides automated image relinking, document exporting, and image status checking capabilities.
🚀 Features
1. Relink Images
Automatically relinks missing images in H&M documents using intelligent matching algorithms.
Link by File
- Process a single document by Document ID
- Extracts image filenames from
absolutePathfor accurate matching - Handles H&M-specific logos with hardcoded asset identifiers
- Generic image matching through campaign folder structure
Link by Folder
- Process multiple documents in a folder by Folder ID
- Batch processing with individual session management per document
- Comprehensive reporting across all documents
2. Image Status
Check the link status of all images across multiple documents in a folder.
- Document Overview: Shows total, linked, and missing images per document
- Folder Summary: Aggregated statistics across all documents
- Link State Analysis: Categorizes images by their current link state
3. Export INDD
Bulk export InDesign documents from a folder to assets.
- Processes all documents in a specified folder
- Exports to Asset Project ID 7 with folder identifier
68cc028b0e3f4a98ed07db6c - Maintains original document names for assets
4. Export PDF
Bulk export PDF documents with specific filtering and naming conventions.
- R100 Filtering: Only processes documents containing "R100" in the name
- Name Transformation: Replaces "R100" with "RATIOS" in exported asset names
- Quality Settings: Uses preset ID 6 with registration marks
- Exports to Asset Project ID 10 with folder identifier
686fac43868b7ed49b028bee
5. Ratio Check
Validate image aspect ratios against expected values (placeholder functionality).
🏗️ Architecture
Session Management
All document operations use proper One2Edit session management:
- Open Session:
document.session.open- Creates edit session - Perform Operations: Image relinking with session ID
- Save Session:
document.session.save- Commits changes - Close Session:
document.session.close- Releases session
Image Matching Algorithm
Filename Extraction
- Extracts actual filenames from
absolutePathinstead of unreliable<name>tags - Handles URL encoding/decoding automatically
- Splits paths on '/' and takes the last segment
Matching Hierarchy
- H&M sRGB Logo: Hardcoded to asset
68626a50da85f5bf560161ed - H&M CMYK Logo: Hardcoded to asset
68626a4a0eb4d535b80789cb - Generic Images:
- Determines target folder (RGB/CMYK) based on filename patterns
- Searches campaign-specific asset structure
- Performs fuzzy matching with and without file extensions
Campaign Folder Structure
Assets/
└── [Campaign Folder Name]/
└── Links/
├── RGB/
└── CMYK/
Error Handling & Resilience
- Individual Failures: Don't stop batch operations
- Session Cleanup: Ensures sessions are properly closed even on errors
- Comprehensive Logging: Debug information for troubleshooting
- Timeout Prevention: 5-second delays between relink operations, 2-second delays between documents
📋 API Reference
Core APIs Used
| API Call | Purpose | Parameters |
|---|---|---|
document.list |
Get documents in folder | folderId, include=id |
document.info |
Get document details | id, include=folderId |
document.folder.info |
Get folder information | id, include=name |
document.session.open |
Start edit session | documentId |
document.session.save |
Save changes | documentId, editSession |
document.session.close |
End session | documentId, editSession |
document.image.list |
Get image information | id, include=linkState|absolutePath |
document.image.relink |
Relink image | id, frameId, assetIdentifier, editSession |
document.export.indd |
Export to InDesign | id, assetProjectId, assetFolderIdentifier |
document.export.pdf |
Export to PDF | id, presetId, assetProjectId |
asset.list |
Browse asset library | projectId, folderIdentifier |
Authentication
- Domain:
local - Username:
pauljohns@oliver.agency - Password:
J4ckel-4! - Client ID:
6
Asset Configuration
- Project ID 7: InDesign exports and image assets
- Project ID 10: PDF exports
- InDesign Folder:
68cc028b0e3f4a98ed07db6c - PDF Folder:
686fac43868b7ed49b028bee
🎯 Usage Instructions
Getting Started
- Open
index.htmlin a web browser - Select an action from the dropdown
- Fill in the required parameters
- Click "Submit" to execute
Action Parameters
Relink Images
- Link Method: Choose "Link by File" or "Link by Folder"
- Document ID: (Link by File) Single document to process
- Folder ID: (Link by Folder) Process all documents in folder
Image Status
- Folder ID: Folder to check image status for all documents
Export INDD
- Folder ID: Folder containing documents to export
Export PDF
- Folder ID: Folder containing R100 documents to export
Ratio Check
- Input Path: Path to check ratios
- Expected Ratio: Target aspect ratio (e.g., "16:9")
- Tolerance (%): Acceptable variance percentage
- Generate Report: Whether to create a report
Reading Results
- Progress Updates: Real-time status during operations
- Debug Logging: Click "Show Debug Log" for detailed API information
- Comprehensive Reports: Final summaries with per-document breakdowns
🔧 Configuration
Image Processing Rules
CMYK Detection
Files ending with 39L_TAC330.tif are automatically processed through the CMYK asset folder.
RGB Default
All other images default to the RGB asset folder unless specifically detected as CMYK.
H&M Logo Handling
H&M-logo_sRGB.ai→ Asset68626a50da85f5bf560161edH&M-logo_CMYK_coated.eps→ Asset68626a4a0eb4d535b80789cb
Performance Settings
- Relink Delay: 5 seconds between image relink operations
- Document Delay: 2 seconds between document processing
- Status Check Delay: 500ms between document status checks
🐛 Troubleshooting
Common Issues
"allUnlinkedImages is not defined"
This was resolved by updating the code to only process MISSING images instead of all unlinked images.
Images showing as linked = 0
Fixed by correcting linkState comparison from 'Normal' to 'NORMAL' (case sensitivity).
Timeout Errors
Resolved by implementing proper session management and adding delays between operations.
Incorrect Image Names
Fixed by extracting filenames from absolutePath instead of unreliable <name> XML tags.
Debug Information
Enable debug logging to see:
- API request/response details
- Image matching logic
- Session management steps
- Error details and stack traces
Session Management Issues
If sessions are left open:
- Operations may timeout
- Subsequent operations may fail
- Check debug log for session IDs
- Sessions auto-expire after a period
📊 Reporting
Relink Reports
Relink Complete!
Total Images: 25
Missing Images: 8
Successfully Relinked: 7
Failed: 1
Image Status Reports
Image Status Check Complete!
Total Documents Checked: 5
Successful Checks: 5
Failed Checks: 0
Overall Totals:
- Total Images: 127
- Linked Images (Normal): 119
- Missing Images: 8
Document Details:
Document 2518: 15 linked, 2 missing (17 total)
Document 2519: 22 linked, 0 missing (22 total)
...
Export Reports
Export Complete!
Total Documents: 12
Successful: 12
Failed: 0
🔐 Security Considerations
- Credentials: Hardcoded in application (consider environment variables for production)
- CORS: Requires proper server configuration for cross-origin requests
- Rate Limiting: Built-in delays prevent API abuse
- Session Management: Proper cleanup prevents resource leaks
🚀 Future Enhancements
Potential Improvements
- Environment Configuration: Move credentials to config files
- Bulk Operations UI: Progress bars and cancel functionality
- Asset Preview: Show thumbnails before relinking
- Advanced Filtering: More sophisticated image matching rules
- Export Presets: Configurable export settings
- Retry Logic: Automatic retry for failed operations
- Background Processing: Queue-based operations for large batches
API Extensions
- Batch Relink API: Single API call for multiple images
- Status Webhooks: Real-time progress notifications
- Asset Search API: Better asset discovery and matching
📁 File Structure
Agent/
├── index.html # Main application file
└── README.md # This documentation
🤝 Contributing
Code Style
- JavaScript: ES6+ features with async/await
- Error Handling: Try-catch blocks with detailed logging
- API Calls: Consistent error checking and XML parsing
- User Feedback: Real-time progress updates
Adding New Features
- Add action option to dropdown
- Define parameters in
actionVariables - Create handler function following existing patterns
- Implement proper session management
- Add comprehensive error handling
- Update documentation
Version: 1.0
Last Updated: December 2024
Author: Claude Code Assistant
License: Internal Use Only