-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Repository avatar fallback configuration #7087
Repository avatar fallback configuration #7087
Conversation
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
👍 |
Codecov Report
@@ Coverage Diff @@
## master #7087 +/- ##
==========================================
- Coverage 41.56% 41.53% -0.04%
==========================================
Files 446 446
Lines 60770 60825 +55
==========================================
+ Hits 25262 25264 +2
- Misses 32223 32278 +55
+ Partials 3285 3283 -2
Continue to review full report at Codecov.
|
Hide or use a default image? |
I think default image is best |
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
I've implemented a fallback configuration for missing repository avatars.
Also the owner can configure which image should be used as default image. Per default it will point to a new image I added, which is a png version of the repository octicon that is currently used. If the owner decides to use random avatars and later decides to show a default image instead, I've added a task to the admin panel that removes the randomly generated avatar files. |
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
} | ||
|
||
// RemoveRandomAvatars removes the randomly generated avatars that were created for repositories | ||
func RemoveRandomAvatars() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need to remove the random avatars?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random avatars are placed on the file system and set in the database.
Let's say an owner used generated repository avatars and now wants to display a default avatar instead. The generated avatars are stored just like uploaded avatars on the file system (the only difference is the file name) and also update the repository in the database.
The default avatar will be used when no image was added to the repository, which is why the randomly generated images will still be used instead of the default avatar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a repository has a random avatar, delete it from UI will make it as default image and upload a new avatar will delete the previous image. So I think the cron task is unnecessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. But still, looking at an organization with 100 repositories an admin would have to through all projects and delete the avatars. That's why I wanted to provide an easy way to do so, which is why I placed it in the administration panel.
It's not supposed to be a cron task that is executed regularly. Maybe it would be better to put that into a cmd task like gitea cleanup repository-avatars
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM
Fixes #7099 |
Co-Authored-By: zeripath <art27@cantab.net>
* Only show repository avatar in list when one was selected Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Adds fallback configuration option for repository avatar Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Implements repository avatar fallback Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Adds admin task for deleting generated repository avatars Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Solve linting issues Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Save avatar before updating database * Linting * Update models/repo.go Co-Authored-By: zeripath <art27@cantab.net>
Follow up on #6986.
When no repository avatar was assigned an empty img tag is rendered in repository list.
This bugfix only shows the repository avatar in repository list when one was uploaded.This PR adds a configurable fallback.
In Gitea config the owner can switch between the following option:
Also the owner can configure which image should be used as default image. Per default it will point to a new image I added, which is a png version of the repository octicon that is currently used.
If the owner decides to use random avatars and later decides to show a default image instead, I've added a task to the admin panel that removes the randomly generated avatar files.