No description
Find a file
2025-12-04 14:14:52 -05:00
.gitignore Implement basic authentication with login page 2025-12-04 14:09:14 -05:00
.htaccess Update .htaccess to allow AJAX access to config.php and protect system files 2025-12-04 14:14:52 -05:00
auth.php Implement basic authentication with login page 2025-12-04 14:09:14 -05:00
config.php Implement basic authentication with login page 2025-12-04 14:09:14 -05:00
index.php Implement basic authentication with login page 2025-12-04 14:09:14 -05:00
login.php Implement basic authentication with login page 2025-12-04 14:09:14 -05:00
logout.php Implement basic authentication with login page 2025-12-04 14:09:14 -05:00
README.md Convert index.html to index.php and update font to Montserrat 2025-12-04 13:28:39 -05:00
SECURITY_SETUP.md Convert index.html to index.php and update font to Montserrat 2025-12-04 13:28:39 -05:00

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

Automatically relinks missing images in H&M documents using intelligent matching algorithms.

  • Process a single document by Document ID
  • Extracts image filenames from absolutePath for accurate matching
  • Handles H&M-specific logos with hardcoded asset identifiers
  • Generic image matching through campaign folder structure
  • 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:

  1. Open Session: document.session.open - Creates edit session
  2. Perform Operations: Image relinking with session ID
  3. Save Session: document.session.save - Commits changes
  4. Close Session: document.session.close - Releases session

Image Matching Algorithm

Filename Extraction

  • Extracts actual filenames from absolutePath instead of unreliable <name> tags
  • Handles URL encoding/decoding automatically
  • Splits paths on '/' and takes the last segment

Matching Hierarchy

  1. H&M sRGB Logo: Hardcoded to asset 68626a50da85f5bf560161ed
  2. H&M CMYK Logo: Hardcoded to asset 68626a4a0eb4d535b80789cb
  3. 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

  1. Open index.html in a web browser
  2. Select an action from the dropdown
  3. Fill in the required parameters
  4. Click "Submit" to execute

Action Parameters

  • 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 → Asset 68626a50da85f5bf560161ed
  • H&M-logo_CMYK_coated.eps → Asset 68626a4a0eb4d535b80789cb

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:

  1. Operations may timeout
  2. Subsequent operations may fail
  3. Check debug log for session IDs
  4. Sessions auto-expire after a period

📊 Reporting

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

  1. Add action option to dropdown
  2. Define parameters in actionVariables
  3. Create handler function following existing patterns
  4. Implement proper session management
  5. Add comprehensive error handling
  6. Update documentation

Version: 1.0
Last Updated: December 2024
Author: Claude Code Assistant
License: Internal Use Only