CodexWorker

Backend Developer | Go, Microservices, Scalability

Today's App Updates: Significant Improvements Across Image Handling, User Experience & More

What developments have taken place today?

Several significant improvements and additions have been implemented across various parts of the application, primarily focused on image handling, user interaction, and website display enhancements. These include:

  1. Configuration 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). This facilitates image URL generation and file organization.

  2. Image Resizing & Uploads: A comprehensive image resizing system has been implemented, utilizing the convert command-line tool for padding, centering, and compression. The GenerateImageDiskPath function now dynamically constructs unique filenames based on width, height, and quality parameters. File upload functionality is also integrated into the ‘Post Add’ form, enabling users to submit images alongside their posts.

  3. File Repository Enhancements: New methods (Save, LoadOne, UpdatePath) have been added to the PostFileRepository struct for managing associated files within posts.

  4. Homepage & Post Display Updates: The homepage template now displays uploaded image paths, and the post display has been revamped to support larger images (800x800) alongside smaller thumbnails, utilizing a fullscreen modal view that adapts to different screen sizes. Responsive design adjustments ensure proper layout on smaller screens.

  5. GitLab Integration: Code has been added to retrieve post statistics from GitLab using the GitLab API and handle commit information retrieval. The GitLabReader struct now includes functionality for fetching all files associated with specific posts.

  6. Newsletter Subscription: The homepage’s newsletter subscription process is now handled asynchronously, validating email format and preventing duplicate submissions through a series of checks and event listeners.

  7. Testing Framework Improvements: The testing suite has been updated to use npm run test instead of npx jest, with enhanced error handling and build aborting on test failure. It also incorporates mocking of the Date.now() function for consistent test results.

  8. Time Difference Display: A new JavaScript file (/js/post.js) has been added to display human-readable time differences for posts, leveraging a humanReadableTimeDifference function and a pluralize helper. The existing homepage.js was updated to reference this new file.

  9. Modal Closure: The application now properly closes modals when the Escape key is pressed.

  10. Validation Updates: The PostAddValidator has been enhanced to include validation for file uploads (size and format) and to ensure that required fields like title and content are not empty. Additionally, it filters out empty files during validation.

  11. Image Resizing Logic Refinement: A dedicated JavaScript file (/js/post.js) handles the resizing of images using a new function, accommodating a 100x100 pixel size with an 80-quality setting and includes debugging logging for supported sizes. The Convert function now incorporates additional arguments to improve image compatibility.

  12. Form Submission Logging: Added logging within the form submission handler to print form data to the console, aiding in debugging.

In summary, these changes significantly enhance the application’s functionality by enabling rich media support (images), streamlining user workflows (file uploads and newsletter subscriptions), improving website presentation (post display and responsive design), and strengthening code quality through testing improvements and validation rules. The integration of GitLab statistics provides valuable data insights, while the modularized JavaScript files promote maintainability and extensibility.

image handling user interaction website enhancements gitlab integration file repository