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

Always generate avatar #6876

Merged
merged 6 commits into from
Dec 8, 2017
Merged

Always generate avatar #6876

merged 6 commits into from
Dec 8, 2017

Conversation

rullzer
Copy link
Member

@rullzer rullzer commented Oct 19, 2017

@LukasReschke as discussed

Even if no avatar is set we should just generate the image. This to not
duplicate the code on all the clients. And only server images from the
avatar endpoint.

Todo:

  • Save avatar
  • Move this to the actual avatar code instead of the Controller

Future work:

  • use imgsrc so the browser fetches the right size on hdpi stuff
  • extend caching

@rullzer rullzer added this to the Nextcloud 13 milestone Oct 19, 2017
@codecov
Copy link

codecov bot commented Oct 20, 2017

Codecov Report

Merging #6876 into master will increase coverage by 0.03%.
The diff coverage is 81.19%.

@@             Coverage Diff              @@
##             master    #6876      +/-   ##
============================================
+ Coverage     50.85%   50.89%   +0.03%     
- Complexity    24539    24557      +18     
============================================
  Files          1584     1584              
  Lines         93798    93891      +93     
  Branches       1358     1358              
============================================
+ Hits          47704    47788      +84     
- Misses        46094    46103       +9
Impacted Files Coverage Δ Complexity Δ
core/Controller/AvatarController.php 81.16% <100%> (+2.64%) 31 <0> (-1) ⬇️
lib/private/Avatar.php 78.08% <80.7%> (+1.77%) 43 <18> (+19) ⬆️
apps/files_trashbin/lib/Trashbin.php 72.53% <0%> (+0.24%) 136% <0%> (ø) ⬇️
core/js/js.js 63.55% <0%> (+0.56%) 0% <0%> (ø) ⬇️

@rullzer
Copy link
Member Author

rullzer commented Nov 2, 2017

Ah mmm so upating the JS is a tiny bit tricky as there is also some code to handle unknown users etc.

@rullzer
Copy link
Member Author

rullzer commented Nov 2, 2017

So @tobiasKaminsky this is what you wanted right?

@jancborchardt please checkout this branch and try to share etc. To see if there are no weird avatar hickups now.

@tobiasKaminsky
Copy link
Member

@rullzer this is great. So we can drop avatar generation once NC 12 has end of life :-)

/**
* @NoAdminRequired
* @NoCSRFRequired
* @NoSameSiteCookieRequired
Copy link
Member

Choose a reason for hiding this comment

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

Why did you remove this? This is for example required when Collabora is embedding avatars since it runs under a different origin :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question


$hsl = $this->rgbToHsl($rgb[0], $rgb[1], $rgb[2]);

// Classic formulla to check the brigtness for our eye
Copy link
Member

Choose a reason for hiding this comment

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

/formulla/formula/

* @param double $h Heu in range [0, 1]
* @param double $s Saturation in range [0, 1]
* @param double $l Lightness in range [0, 1]
* @return int[] Array containging r g b in the range [0, 255]
Copy link
Member

Choose a reason for hiding this comment

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

/containging/containing/

}

/**
* @param double $h Heu in range [0, 1]
Copy link
Member

Choose a reason for hiding this comment

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

/Heu/Hue/ maybe?

@@ -210,4 +230,160 @@ private function getExtension() {
}
throw new NotFoundException;
}

private function generateAvatar($userDisplayName, $size) {
Copy link
Member

Choose a reason for hiding this comment

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

PHPDoc on the parameters would be awesome 😄

Even if no avatar is set we should just generate the image. This to not
duplicate the code on all the clients. And only server images from the
avtar endpoint.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Copy link
Member

@MorrisJobke MorrisJobke left a comment

Choose a reason for hiding this comment

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

I made the font use semibold weight and made it a bit better centered, because it was slightly off.

@MorrisJobke
Copy link
Member

bildschirmfoto 2017-12-08 um 16 24 04

The only thing that may be a bit different is, that we now always have an avatar in the top right - cc @nextcloud/designers

@skjnldsv
Copy link
Member

skjnldsv commented Dec 8, 2017

I'm OK with that. This is also pretty nice for the top right menu list drop-down positioning issue we have here and there :)

@MariusBluem
Copy link
Member

I like always having the avatar at the top 👍

@MorrisJobke
Copy link
Member

Discussed with @LukasReschke on IRC and good to get in.

@MorrisJobke MorrisJobke merged commit ed7beb9 into master Dec 8, 2017
@MorrisJobke MorrisJobke deleted the always_img_avatar branch December 8, 2017 22:58
@MorrisJobke
Copy link
Member

@rullzer Seems to break the integration tests for sharing :/ See @danxuliu's comment in #6715 (comment)

@rullzer
Copy link
Member Author

rullzer commented Dec 11, 2017

I know. I have a patch for that already

@MorrisJobke
Copy link
Member

I know. I have a patch for that already

#7342

@jancborchardt
Copy link
Member

Hm, in the past @karlitschek and I discussed this with avatar placeholder in top right and we didn’t really like it as it’s very present and colorful. However it kind of nudges you to set a proper image, so I guess it’s fine after all. :)

@jancborchardt
Copy link
Member

Actually this causes a confusion with new users or installations. Cause in the top right the avatar is shown and not the settings icon, it is not immediately obvious where the settings are:

#7535

(When you are used to the UI and added a picture, you also know where the settings are.)

@MariusBluem
Copy link
Member

I disagree with you @jancborchardt ... this behaviour is known by the users from so many services ... not only by Nextcloud.

To make it crystal clear we could show some arrows with descriptions in the firstrunwizard :)

@jancborchardt
Copy link
Member

To make it crystal clear we could show some arrows with descriptions in the firstrunwizard :)

If it's known, we don't need a pointer for such an obvious menu in the first run wizard. ;)

@MorrisJobke
Copy link
Member

Actually this causes a confusion with new users or installations. Cause in the top right the avatar is shown and not the settings icon, it is not immediately obvious where the settings are:

I guess the main problem is, that we don't have an indicator for menus. On github they put for example a little arrow beside the avatar to indicate the menu:

bildschirmfoto 2017-12-16 um 12 32 18

@MariusBluem
Copy link
Member

Dropbox:
c3d27750-4e64-44d5-a824-f1ec369ab2b5

Microsoft:
dfcc7cd6-ef3d-4890-8162-c26912e8ee1f

No indicator ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants