From 27fb680a15bd06139565e71cf406566ddae648b2 Mon Sep 17 00:00:00 2001 From: logikonline Date: Mon, 19 Jan 2026 22:57:09 -0500 Subject: [PATCH] refactor(gallery): simplify imports and string formatting Replace fmt.Sprintf with string concatenation for simple commit messages and consolidate JSON imports to use shared module. - Use string concatenation instead of fmt.Sprintf for commit messages - Move json import to shared modules/json package - Remove unused fmt and encoding/json imports --- .notes/note-1768875333549-sft9y7mew.json | 8 -------- .notes/note-1768881142114-zwzrej9gc.json | 8 ++++++++ routers/web/repo/setting/gallery.go | 9 ++++----- routers/web/repo/view_home.go | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) delete mode 100644 .notes/note-1768875333549-sft9y7mew.json create mode 100644 .notes/note-1768881142114-zwzrej9gc.json diff --git a/.notes/note-1768875333549-sft9y7mew.json b/.notes/note-1768875333549-sft9y7mew.json deleted file mode 100644 index b8dbb7ce52..0000000000 --- a/.notes/note-1768875333549-sft9y7mew.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "note-1768875333549-sft9y7mew", - "title": "working", - "content": "> a few bugs we need to address. 1. when I save a License in the Org Settings - it is\nautomatically making a README in the .profile. It should not do that. 2. THe Repos link in the\nRepo Header (the tab) should link to the Org repositories NOT the Overview page. 3. THe Move File\nto vault - I see the following tags and not text repo.editor.commit_message, repo.file 4. When I\nclick Move to Vault - it takes me to the file viewer but it is not moved to the vault. 5. on the\nvault/secrets/new - remove the Back to List - we already have a cancel button. 6. THe New Secret\nbutton in the header of /vault should be right aligned. 7. No Secrets\nThis repository doesn't have any secrets stored yet. is still not centered\n\n \"repo.file\": \"File\",\n \"repo.file_size\": \"File size\",\n \"repo.file_raw\": \"Raw\",\n \"repo.editor.commit_message\": \"Commit message\",\n \"repo.settings.license_scan\": \"Scan\",\n \"repo.settings.license_detected\": \"License detected\",\n \"repo.settings.license_not_found\": \"No license file detected in repository.\",\n \"org.settings.license_saved\": \"License updated successfully.\",\n \"org.settings.license_cleared\": \"License has been cleared.\",\n \"org.settings.license_error\": \"Failed to update license.\",", - "createdAt": 1768875333547, - "updatedAt": 1768877911515, - "tags": [] -} \ No newline at end of file diff --git a/.notes/note-1768881142114-zwzrej9gc.json b/.notes/note-1768881142114-zwzrej9gc.json new file mode 100644 index 0000000000..32194018b0 --- /dev/null +++ b/.notes/note-1768881142114-zwzrej9gc.json @@ -0,0 +1,8 @@ +{ + "id": "note-1768881142114-zwzrej9gc", + "title": "Release Notes for Gallery", + "content": " New Feature: Repository Home Page Tabs\n\n The repository home page now features a tabbed interface replacing the single README display. When content is available, users will see tabs for:\n\n - Readme - Displays the README file (default tab, existing behavior)\n - License - Displays the LICENSE file content\n - Gallery - Displays project screenshots from the .gallery folder\n\n Tabs only appear when the corresponding content exists in the repository.\n\n ---\n New Feature: Repository Gallery\n\n Developers can now showcase screenshots and images of their applications directly on the repository home page.\n\n Gallery Tab Features:\n - Responsive image grid layout\n - Lightbox viewer for full-size images with keyboard navigation (← →)\n - Custom captions for each image\n - Lazy loading for better performance\n\n Gallery Settings Page (Repository > Settings > Gallery):\n - Upload images (PNG, JPG, JPEG, GIF, WebP, SVG, BMP, ICO)\n - 5MB maximum file size per image\n - Add/edit captions for each image\n - Delete images with confirmation\n\n Storage:\n - Images are stored in the .gallery folder at the repository root\n - Captions are stored in .gallery/gallery.json\n - All changes are committed to the repository automatically\n\n ---\n Localization\n\n Full translations added for gallery-related strings in 20+ languages:\n - English, German, French, Spanish, Italian, Dutch, Polish\n - Portuguese (Brazil & Portugal)\n - Russian, Ukrainian, Turkish, Czech, Greek, Hungarian\n - Finnish, Swedish\n - Japanese, Korean, Chinese (Simplified & Traditional)", + "createdAt": 1768881142111, + "updatedAt": 1768881147863, + "tags": [] +} \ No newline at end of file diff --git a/routers/web/repo/setting/gallery.go b/routers/web/repo/setting/gallery.go index 1fa214b031..798ddf25f1 100644 --- a/routers/web/repo/setting/gallery.go +++ b/routers/web/repo/setting/gallery.go @@ -5,8 +5,6 @@ package setting import ( "bytes" - "encoding/json" - "fmt" "io" "net/http" "path" @@ -14,6 +12,7 @@ import ( "code.gitcaddy.com/server/v3/modules/git" "code.gitcaddy.com/server/v3/modules/gitrepo" + "code.gitcaddy.com/server/v3/modules/json" "code.gitcaddy.com/server/v3/modules/log" "code.gitcaddy.com/server/v3/modules/templates" "code.gitcaddy.com/server/v3/modules/typesniffer" @@ -183,7 +182,7 @@ func GalleryUpload(ctx *context.Context) { // Create/update file in repo opts := &files_service.ChangeRepoFilesOptions{ - Message: fmt.Sprintf("Add gallery image: %s", filename), + Message: "Add gallery image: " + filename, OldBranch: repo.DefaultBranch, NewBranch: repo.DefaultBranch, Files: []*files_service.ChangeRepoFile{ @@ -273,7 +272,7 @@ func GalleryCaption(ctx *context.Context) { } opts := &files_service.ChangeRepoFilesOptions{ - Message: fmt.Sprintf("Update gallery caption: %s", filename), + Message: "Update gallery caption: " + filename, OldBranch: repo.DefaultBranch, NewBranch: repo.DefaultBranch, Files: []*files_service.ChangeRepoFile{ @@ -312,7 +311,7 @@ func GalleryDelete(ctx *context.Context) { // Delete file from repo opts := &files_service.ChangeRepoFilesOptions{ - Message: fmt.Sprintf("Delete gallery image: %s", filename), + Message: "Delete gallery image: " + filename, OldBranch: repo.DefaultBranch, NewBranch: repo.DefaultBranch, Files: []*files_service.ChangeRepoFile{ diff --git a/routers/web/repo/view_home.go b/routers/web/repo/view_home.go index 8498eb704a..879df8a02e 100644 --- a/routers/web/repo/view_home.go +++ b/routers/web/repo/view_home.go @@ -4,7 +4,6 @@ package repo import ( - "encoding/json" "errors" "fmt" "net/http" @@ -22,6 +21,7 @@ import ( "code.gitcaddy.com/server/v3/modules/gitrepo" "code.gitcaddy.com/server/v3/modules/htmlutil" "code.gitcaddy.com/server/v3/modules/httplib" + "code.gitcaddy.com/server/v3/modules/json" "code.gitcaddy.com/server/v3/modules/log" "code.gitcaddy.com/server/v3/modules/plugins" repo_module "code.gitcaddy.com/server/v3/modules/repository"