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
Custom User Profile Pictures #278
Conversation
restarting the travis build, i think I fixed the problems on our end. |
@fusion94 can you check the CLAHub stuff? |
@jrgifford CLAHub is broken atm go ahead and merge |
@ar7em this looks good, before I merge, can you add some tests for this behavior? If you need some help, you can send me an email (its in my GitHub profile). 🤘 |
Will do this ASAP. I'm not really familiar with Ruby, so 'll have to look through some guides on testing. |
OK. We use rspec - if you need help, let me know. 😃 |
test'll be good. I'm not sure this will correctly handle invalid non zero length inputs. e.g. " ", "myimage.jpg", "//no.protocol.com/myimage.jpg" or other typos. Would be good to have those tested. |
I'm sorry for taking so long to response. I tried to provide some testing to new functionality. Could you please spare couple of minutes and review the code? |
I'll see if i can take a look at this today. |
I think you should squash a bunch of these commits. And I see I'm late to the party but have you considered using the fastimage gem? It's faster than the standard Net::HTTP request and will identify the image type for you (not simply checking the extension of the file). The downside is that you won't be able to determine the image size, but maybe you could check its width and height instead? I'm not sure if the maintainers of the project will agree. Also, there shouldn't be any need to check for zero length inputs. Just make a request to the input provided (or use fastimage) and if an image is found then the input is valid. |
GuilhermeSimoes, thanx for your reply. |
Ok, so here's the gist:
A console text editor will then open. Depending on your OS, this will be either Vim or Nano. Just search for these text editors to understand the basic stuff. You then have the chance to edit, delete, reorder and squash (join) commits. All you have to do, is change the first word before each commit. For example:
In this PR, in the commit "Removed obsolete schema part", you should change "pick" to "fixup". This will squash this commit into the previous commit and discard its commit message. This way the history of the project will look a lot cleaner. Finally, you have to push your changes. But since you are rewriting history, you'll have to use the
|
External avatar url can now be set from account settings. Test added for external avatar url field.
Empty external avatar url is valid value. If user has empty avatar url then gravatar will be used instead.
First of all, thank you, GuilhermeSimoes, for you kind answer and definite guide. I've played around with I'll also consider using At last, speaking of avatar url length in the helper method: external avatar should be optional to use. That's why i removed the check for empty string from validation method and appropriate test in last commit (yet again i'm not sure if i should squash it too). If no url is specified in corresponding field, gravatar image is used. |
You don't have to always squash everything. I just suggested squashing that specific commit because you were just deleting stuff in that commit that you had added in the previous commit. In that case, you should just squash it so the history of the project is not polluted. In this last commit, I think it makes sense to leave it as it is, no need to squash it. I think it shows the rationale behind the change. And indeed you are right about the avatar url length. I don't know what I was thinking 😄 Might I suggest just 2 more things? Check this: if self.avatar_url.nil? or self.avatar_url.empty?
return
end Rails has a method called return if self.avatar_url.blank? And in the helper method: if user.avatar_url and user.avatar_url.length > 0
user.avatar_url
else
Kandan::Config.options[:avatar_url].gsub(/%{hash}/, user.gravatar_hash).
gsub(/%{size}/, (options[:size] || 30).to_s).
gsub(/%{fallback}/, options[:fallback] || Kandan::Config.options[:avatar_fallback] || 'mm')
end I'd use the blank method and switch the if block with the else block. Like this: if user.avatar_url.blank?
Kandan::Config.options[:avatar_url].gsub(/%{hash}/, user.gravatar_hash).
gsub(/%{size}/, (options[:size] || 30).to_s).
gsub(/%{fallback}/, options[:fallback] || Kandan::Config.options[:avatar_fallback] || 'mm')
else
user.avatar_url
end If nobody says anything about |
|
So my question is, why are the tests failing here? Do they work locally? |
This works and i'm less worried about the tests due to the age of the PR |
Adds avatar url field at profile page, that replaces gravatar icon. New user validate method
check_external_avatar
checks if avatar extension does match one of permitted extension inkandan_settings.yml
and does not exceed size limit.