This document outlines the plan for implementing the guest photo upload feature with an automated gallery update process using Google Forms and Google Apps Script.
- Action: Create a new Google Form.
- Fields:
- Your Name (Short Answer, Required)
- Approximate Date of Photo (Date or Short Answer, Required)
- Upload Your Photo (File Upload, Required)
- Configure to accept Image files only.
- Set appropriate file size limits if desired (within Google's limits).
- Tell Us About the Photo (Paragraph, Optional)
- Configuration:
- Link the Form to a new Google Sheet to collect responses.
- Configure the Form's file upload setting to save photos automatically to a specific Google Drive folder. Note: Remember the name/location of this folder.
- Manually add an "Approved?" column to the linked Google Sheet after creation.
- Guest Submission: Guests access the
photos.htmlpage and use the embedded Google Form to submit their name, photo date, photo file, and optional description. - System Action: The Form automatically saves the text data to the linked Google Sheet and the photo file to the designated Google Drive folder.
- Manual Review (Emily): Periodically review new submissions by checking the Google Sheet and the Google Drive folder.
- Manual Approval (Emily): For photos to be included in the gallery, type "YES" (or another consistent marker) into the "Approved?" column for the corresponding row in the Google Sheet.
- Action: Create a new Google Apps Script project attached to the Google Sheet containing the form responses.
- Script Functionality:
- Trigger: Set up a time-driven trigger (e.g., runs every hour) or potentially an
onFormSubmittrigger (though time-driven might be more robust for processing). - Read Sheet: The script reads all rows from the response sheet.
- Filter Approved: It identifies rows where the "Approved?" column is marked "YES".
- Get Drive Links: For each approved row, the script needs to find the corresponding photo file in the Google Drive folder. Crucially, it must then generate a shareable link for that file. The permissions on the Drive folder must be set so that "Anyone with the link can view".
- Compile JSON: The script creates a JSON array containing objects for each approved photo. Each object should include:
imageUrl: The shareable Google Drive link.submitterName: The name provided by the guest.photoDate: The approximate date provided.description: The optional description.
- Publish Web App: The script publishes the JSON data as a web app. The web app's
doGet()function will return the JSON data. Note the unique URL of the deployed web app.
- Trigger: Set up a time-driven trigger (e.g., runs every hour) or potentially an
- Action: Modify the
initPhotoGalleryfunction injs/main.js. - Functionality:
- Remove the hardcoded
imageFilesarray. - Use the
fetchAPI to retrieve the JSON data from the deployed Google Apps Script web app URL. - Handle potential errors during fetching (e.g., network issues, script errors).
- If the fetch is successful, parse the JSON data.
- Dynamically create the HTML elements for each photo in the
gallery-griddiv using the data from the JSON (image URL forsrc, other fields for potential captions or alt text). - Ensure the lightbox functionality works with the dynamically loaded images.
- Remove the hardcoded
Once implemented, the workflow will be:
- Guest uploads photo.
- Emily marks "YES" in the Sheet.
- Apps Script runs, finds the "YES", gets the link, updates the JSON data at its URL.
- The next time a user visits
photos.html, the JavaScript fetches the updated JSON and displays the newly approved photo in the gallery automatically.
graph TD
A[Guest Submits Photo via Google Form] --> B{Google Form};
B --> C[Google Sheet Populated];
B --> D[Photo Saved to Google Drive];
C --> E{Emily Reviews Sheet};
D --> E;
E -- Marks 'YES' --> F[Approved? Column Updated in Sheet];
F --> G{Google Apps Script (Scheduled)};
G -- Reads Sheet --> G;
G -- Gets Shareable Links from Drive --> G;
G --> H[Publishes Approved Photo List (JSON) to URL];
H --> I{Website JavaScript (js/main.js)};
I -- Fetches JSON --> I;
I --> J[Dynamically Builds Gallery];
J --> K[Website Gallery Updated Automatically];
subgraph Manual Steps
E
end
subgraph Automated Steps
A
B
C
D
F
G
H
I
J
K
end
style E fill:#f9f,stroke:#333,stroke-width:2px
Switch to Code mode to begin implementation, starting with the Google Form creation and embedding, followed by the Apps Script development and website JavaScript modifications.