Image Handling & Core Updates: A Significant Commit
What developments have taken place today?
This commit significantly enhances image handling within the application, introducing new functionality for resizing, uploading, and displaying images. Key changes include:
- Configuration Structure Updates: The
Config
struct now includes fields for storing the paths to directories where resized images are saved (data_resized_directory
) and original files are stored (data_directory
). - Image Resizing Logic Implementation: A new
GenerateImageDiskPath
function is implemented, generating unique filenames based on width, height, and quality. It also utilizes theconvert
command-line tool for padding and centering images during resizing, ensuring consistent image dimensions and appearance. Debugging information related to image size and quality has been added. - File Upload Support: The
post_add.go.tmpl
template now supports file uploads, allowing users to submit images alongside their posts. - File Repository Modifications: New methods (
Save
,LoadOne
,UpdatePath
) are added to thePostFileRepository
struct for managing uploaded files associated with posts. - Homepage Template Updates: The homepage template is updated to display a list of uploaded images linked to each post, utilizing image paths obtained from the file repository.
- PostAddValidator Enhancements: The
PostAddValidator
now validates file uploads, checking for valid formats (PNG, JPG, JPEG) and sizes. It also ensures that required fields like title and content are not empty. - Fullscreen Modal Implementation: A new feature has been added which allows users to view images in a fullscreen modal window with larger image sizes (800x800). The layout dynamically adjusts for smaller screens, displaying the image and post text side-by-side.
This commit also addresses several technical improvements:
- GitLab Integration Enhancements: The code now retrieves post statistics from GitLab using the API.
- Timezone Handling Improvements: Database queries are updated to use UTC_TIMESTAMP() for consistent time representation across servers and environments. A new
timezone_offset
field is added to the user struct for storing timezone information directly within the database. - Cron Job Setup: A cron job has been created to run the
command/cron
binary, responsible for scheduling tasks within the application. - Secret Management Enhancements: The system now encrypts sensitive configuration data using AES-256-CBC with PBKDF2 key derivation, improving security and simplifying key management.
These changes collectively provide a more robust, user-friendly, and secure experience for managing images and related content within the application.
Summary: This commit significantly expanded image handling capabilities by incorporating resizing logic, file upload support, and improved display features. It also implemented enhanced security measures through secret encryption, streamlined repository management, and addressed technical improvements related to GitLab integration and timezone consistency, resulting in a more functional and reliable user experience.
image processing file uploads gitlab integration secret management image resizing