Skip to content
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

Merged

Conversation

saitho
Copy link
Contributor

@saitho saitho commented May 30, 2019

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:

do not show avatar (default)
generate random avatar, similarly to user avatars
show default avatar image

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>
@saitho saitho mentioned this pull request May 30, 2019
@GiteaBot GiteaBot added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label May 30, 2019
@richmahn
Copy link
Contributor

👍

@codecov-io
Copy link

codecov-io commented May 30, 2019

Codecov Report

Merging #7087 into master will decrease coverage by 0.03%.
The diff coverage is 13.11%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
routers/admin/admin.go 0% <0%> (ø) ⬆️
models/repo.go 48.36% <10.71%> (-1.19%) ⬇️
modules/setting/setting.go 48.33% <100%> (+0.18%) ⬆️
models/unit.go 62.16% <0%> (-5.41%) ⬇️
routers/repo/view.go 42.02% <0%> (-1.02%) ⬇️
modules/log/file.go 77.62% <0%> (+2.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 356854f...d558ecf. Read the comment docs.

@lunny
Copy link
Member

lunny commented May 30, 2019

Hide or use a default image?

@techknowlogick
Copy link
Member

I think default image is best

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 30, 2019
@techknowlogick techknowlogick added the topic/ui Change the appearance of the Gitea UI label May 30, 2019
@techknowlogick techknowlogick added this to the 1.9.0 milestone May 30, 2019
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>
@saitho
Copy link
Contributor Author

saitho commented May 30, 2019

I've implemented a fallback configuration for missing repository avatars.
In Gitea config the owner can switch between the following option:

  1. do not show avatar (default)
  2. generate random avatar, similarly to user avatars
  3. show default avatar image

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.

@saitho saitho changed the title Only show repository avatar in list when one was selected Repository avatar fallback configuration May 30, 2019
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
models/repo.go Show resolved Hide resolved
}

// RemoveRandomAvatars removes the randomly generated avatars that were created for repositories
func RemoveRandomAvatars() error {
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

@saitho saitho Jun 1, 2019

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...

@lunny lunny added the type/bug label May 31, 2019
@lunny lunny mentioned this pull request May 31, 2019
7 tasks
Copy link
Member

@lunny lunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

models/repo.go Outdated Show resolved Hide resolved
@zeripath
Copy link
Contributor

zeripath commented Jun 1, 2019

Fixes #7099

Co-Authored-By: zeripath <art27@cantab.net>
@lunny lunny merged commit 8eba27c into go-gitea:master Jun 2, 2019
jeffliu27 pushed a commit to jeffliu27/gitea that referenced this pull request Jul 18, 2019
* 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>
@saitho saitho deleted the bugfix/6986-Hide_empty_repo_logo_in_branch_list branch December 18, 2019 18:53
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/ui Change the appearance of the Gitea UI type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants