commit 37fcdcb5ccdc49733937fbbc34102004d405a736 Author: DJP Date: Thu Oct 23 14:49:33 2025 -0400 Add Microsoft authentication and user tracking to HP Copy Proofing Tool - Implemented Microsoft Azure AD authentication using MSAL - Added login/logout functionality with protected content - Integrated username/email capture from authenticated users - Modified webhook to include username and timestamp with each submission - Updated README with authentication setup and usage instructions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..68635a1 Binary files /dev/null and b/.DS_Store differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..95bc9fc --- /dev/null +++ b/README.md @@ -0,0 +1,149 @@ +# HP Studio Copy Proofing Tool + +A web-based tool for proofing and validating copy in creative assets stored in Box. + +## Overview + +The HP Studio Copy Proofing Tool allows studio teams to validate the spelling, grammar, and overall correctness of copy in creative assets. The tool works by: + +1. Taking a Box file URL as input +2. Extracting the file ID +3. Sending it to a webhook for processing +4. Displaying the results in a clean, organized interface + +## Features + +- **Microsoft Authentication**: Secure login using Microsoft Azure AD credentials +- **User Tracking**: Automatically captures and logs username/email with each submission +- **Language Detection**: Identifies the language and dialect used in the copy +- **Grammar Checking**: Highlights grammatical issues found in the text +- **Spelling Validation**: Identifies and suggests corrections for spelling errors +- **Text Evaluation**: Provides a comprehensive review of all text, marking items as approved or needing correction +- **Debug Mode**: Includes a collapsible debug section to view the raw JSON response + +## Requirements + +- PHP 7.0 or higher +- cURL extension enabled +- Web server (Apache, Nginx, etc.) +- Internet connection to access Box and the webhook service + +## Installation + +1. Clone this repository to your web server: + ``` + git clone https://github.com/yourorganization/hp-studio-copy-proofing-tool.git + ``` + +2. Navigate to the installation directory: + ``` + cd hp-studio-copy-proofing-tool + ``` + +3. Configure the webhook URL by editing `config.php`: + ```php + $config = [ + 'webhook_url' => 'https://your-webhook-url.com/endpoint', + ]; + ``` + +4. Configure Microsoft Authentication in `index.php` (around line 552): + - Set `clientId` to your Azure AD application ID + - Set `authority` to your tenant ID URL: `https://login.microsoftonline.com/YOUR_TENANT_ID` + - Set `redirectUri` to your application's URL + +5. Ensure the web server has write permissions to the directory. + +## Usage + +1. Access the tool via your web browser at `http://your-server/hp-studio-copy-proofing-tool/` + +2. **Sign in** with your Microsoft account credentials when prompted + +3. Enter a valid Box file URL in the format `https://oliver-na.app.box.com/file/1234567890` (only image files are supported: gif, jpeg, jpg, png, webp) + +4. Click "Process File" and wait for the analysis to complete + +5. Review the results: + - Document Summary shows language information and issue count + - Grammar Issues highlights any grammatical errors + - Spelling Errors shows any misspelled words with context and suggested corrections + - Text Evaluation provides an assessment of all text content + +6. For debugging, click "View Raw JSON Response" to see the full API response + +## Webhook Data Sent + +When a file is submitted, the following data is sent to the webhook: + +```json +{ + "url": "https://oliver-na.app.box.com/file/1697251331911", + "file_id": "1697251331911", + "username": "user@example.com", + "timestamp": "2024-01-15 14:30:45" +} +``` + +## Response Format + +The webhook service should return a JSON response in the following format: + +```json +{ + "document_analysis": { + "language_detected": [ + { + "language": "English", + "type": "US", + "spelling_status": "correct" + } + ], + "grammar_issues": [ + { + "section": "Text on the left shelf", + "error": "Missing possessive apostrophe in 'Hellmanns'.", + "suggestion": "Add an apostrophe to read 'Hellmann's'." + } + ], + "spelling_errors": [ + { + "word": "Hellmanns", + "context": "Hellmanns on both shelf stoppers", + "correct_spelling": "Hellmann's", + "status": "incorrect" + } + ], + "text_evaluation": [ + { + "text": "Make it irresistibly rich & creamy", + "status": "good" + } + ] + } +} +``` + +## Troubleshooting + +- **Invalid URL Error**: Ensure the Box URL is in the correct format with a valid file ID +- **Webhook Connection Error**: Verify the webhook URL in `config.php` is correct and accessible +- **No Results Displayed**: Check if the webhook is returning properly formatted JSON + +## Security Considerations + +- This tool requires Microsoft Azure AD authentication for access +- User credentials are managed through Microsoft's authentication system +- Username/email is captured and sent with each webhook request for audit tracking +- This tool is designed for internal use only +- The webhook URL should be secured and properly authenticated +- No sensitive data is stored locally on the server +- Session data is stored in browser sessionStorage and cleared on logout + +## License + +Copyright © 2024 HP Inc. All rights reserved. + +## Credits + +Developed by the HP Studio Tool Team \ No newline at end of file diff --git a/config.php b/config.php new file mode 100644 index 0000000..7a18d75 --- /dev/null +++ b/config.php @@ -0,0 +1,9 @@ + 'https://hook.us1.make.celonis.com/2k3aopltgt4mguvrtynygyrjkqeajddn', +]; \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..f0a9099 --- /dev/null +++ b/index.php @@ -0,0 +1,630 @@ + $boxUrl, + 'file_id' => $fileId, + 'username' => $username, + 'timestamp' => date('Y-m-d H:i:s') + ]; + + // Initialize cURL session + $ch = curl_init($webhookUrl); + + // Set cURL options + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); + curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'Content-Type: application/json' + ]); + + // Execute cURL request + $response = curl_exec($ch); + + // Check for errors + if (curl_errno($ch)) { + $error = 'cURL Error: ' . curl_error($ch); + } else { + $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + if ($httpCode >= 200 && $httpCode < 300) { + $result = json_decode($response, true); + } else { + $error = "HTTP Error: $httpCode - $response"; + } + } + + // Close cURL session + curl_close($ch); + } else { + $error = "Could not extract file ID from the provided Box URL."; + } +} +?> + + + + + + + HP STUDIO COPY PROOFING TOOL + + + + + + + + + + + + + +
+
+
+ +
+ +
+ + +
+ + +

HP STUDIO COPY PROOFING TOOL

+ +
+
+
+ + + Only image files supported (gif, jpeg, jpg, png, webp) +
+ + +
+ + +
+

Result

+ + +
+ +
+ +
+

Extracted Information:

+

Box URL:

+

File ID:

+ +

Document Analysis Results:

+ + + + + +
+
Document Summary
+
+
+ Language: + + + + () + + +
+ +
+ Issues Found: + +
+
+
+ + + +
+
Language Detection
+ +
+
+ + + () + + + Spelling: + +
+
+ +
+ + + + +
+
Grammar Issues
+ +
+
+ : +
+
+ +
+
+ +
+
+ +
+ + + + +
+
Spelling Errors
+ + +
+
+ Word: +
+
+ Context: +
+
+ Correction: +
+
+ + +
+ + + + + +
+
Text Evaluation
+ +
+
+ Needs Correction: +
+
+ "" +
+
+ Approved Text
'; + foreach ($analysis['text_evaluation'] as $text): + if ($text['status'] === 'good'): + $goodTexts = true; + ?> +
+
+ "" +
+
+ +
+
No text evaluations available.
+
+ +
+ + + +
+
Response Data
+
+
+ + + +
+ +
+
+
+
+ + +
+ +
+ +
+ + + + + + + + + + \ No newline at end of file