-
Notifications
You must be signed in to change notification settings - Fork 942
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
Add social profile links #5439
base: master
Are you sure you want to change the base?
Add social profile links #5439
Conversation
46f7da6
to
55c89e6
Compare
Do we need another set of icons in addition to |
app/models/social_link.rb
Outdated
|
||
def parsed | ||
URL_PATTERNS.each do |platform, pattern| | ||
username = url.match(pattern) |
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.
It's not a username, is it?
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.
It's a user's name shown in the URL of some websites' profile page (for example, in the https://github.com/nertc
nertc
is a username
)
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.
MatchData
object is not a username.
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.
To use more intuitive name and not to confuse "user's name" to username, name of the variable username
was changed to names
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.
Is it more intuitive? Now it suggests there are multiple names in this variable.
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.
It is named names
, because it will either be null
or array that will contain one element (user's name). Naming it name
would cause to interpret it as a string or other single object variable, while naming it names
emphasizes that it is an array that contains a name of the user.
app/assets/javascripts/user.js
Outdated
`); | ||
|
||
socialLinkForm.find("button").click(function () { | ||
$(this).parent().remove(); |
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.
I press this button, this removes the link, and I'd think it's saved. But actually not, failing the validation will resurrect the link.
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.
On document load now application checks and hides those fields that have "_destroy" checkbox checked. Therefore, this problem was solved.
When I'm making a site for myself and there's this kind of UI with Add buttons adding an input and Remove buttons next to added inputs, I don't bother doing it. I just put a |
Thanks for the review. I agree with you, if I did a website only for me, it would be a quicker solution to add a textarea and it would do the job. But for most users current solution will be more intuitive and appealing in terms of UI/UX. It's more common and therefore understandable approach (for example GitHub has the same approach on the profile page). |
They have different design. They are more colorful and more like logos which should gain users' attention (for example as share buttons), but icons added by this PR are one color, simple icons, which should not gain much attention as they are there only for the information for the small part of the profile page (not big functional buttons). We can use icons from the |
a1b03f9
to
bfa37a0
Compare
dc9d0cb
to
8263827
Compare
Merge conflict was fixed. |
app/views/profiles/edit.html.erb
Outdated
<div class="social-link-fields row mb-3"> | ||
<%= social_link_form.text_field :url, :hide_label => true, :wrapper_class => "col-sm-8" %> | ||
<%= social_link_form.check_box :_destroy, :wrapper_class => "d-none social_link_destroy" %> | ||
<%= social_link_form.label :_destroy, t(".social_links.remove"), :class => "btn btn-outline-primary col-sm-1 align-self-start" %> |
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.
col-sm-1
is too narrow
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.
It was changed to col-sm-2
. Increasing button's width further will make it too wide.
app/models/social_link.rb
Outdated
class SocialLink < ApplicationRecord | ||
belongs_to :user | ||
|
||
validates :url, :format => { :with => %r{\Ahttps?://.+\z}, :message => I18n.t("profiles.edit.social_links.http_parse_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.
model is referring to controller's i18n key here
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.
Was fixed with the key that is translated outside of the model.
app/views/profiles/edit.html.erb
Outdated
@@ -40,6 +40,21 @@ | |||
</div> | |||
</fieldset> | |||
|
|||
<fieldset class="mb-3"> |
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 is the link editor placed between avatar and home location? If you don't change the order of other things on this page, this place makes the least sense to me.
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.
Where do you think is a good place for it? Should it be between the description and avatar, before the description or the last one?
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.
Editor of the social links was moved below the description, as, I think, description has higher priority and should be displayed higher in the editor, and also social links are positioned next to the description and, therefore, in the editor too, social links should be next to the description.
<p class="text-body-secondary"> | ||
<%= image_tag "/assets/social_link_icons/#{social_link.parsed[:platform].nil? ? 'other' : social_link.parsed[:platform]}.svg", | ||
:alt => social_link.parsed[:platform].nil? ? "other" : social_link.parsed[:platform], | ||
:class => "me-2" %> | ||
<%= link_to social_link.parsed[:name], social_link.url, :class => "text-body-secondary", :rel => "nofollow me" %> | ||
</p> |
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.
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.
From now, URL won't wrap and will show ellipses (...
) if it doesn't fit.
<div class="my-3"> | ||
<%= link_to t(".edit_profile"), edit_profile_path, :class => "btn btn-outline-primary" %> | ||
</div> | ||
<% end %> |
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.
The placement of this button suggests that it leads to editing only the social links. If it actually did, that could have been a good idea, given how many editable things there are already on profile/edit
.
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.
I also thought about a separate page or in-place editing for social links, but for consistency, preferred to keep it in the way that everything is done on the profile page. I agree with you about changing general behavior of editing profile page, but, I think, it will be better if we do it as a separate issue and PR and it will change not some part of profile/edit
but whole behavior to in-place edit. For now, to avoid any confusion from users about the function of the button, I'll move it to where it was before (under the description block).
|
||
def parsed | ||
URL_PATTERNS.each do |platform, pattern| | ||
names = url.match(pattern) |
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.
matches urls like https://evil.example.com/reddit.com/user/NotRedditor
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.
From now it will check whether regex of the websites directly follows to http://www.
, https://www.
, http://
or https://
.
411888c
to
61ac59c
Compare
61ac59c
to
922a34e
Compare
PR was updated according to the comments. Also, master was rebased as a base for this branch. |
Thanks for the review |
if ($("#social_links").length) { | ||
$("#add-social-link").click(function (event) { | ||
event.preventDefault(); | ||
const newIndex = -(new Date().getTime()); |
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.
const newIndex = -(new Date().getTime()); | |
const newIndex = -Date.now(); |
This PR addresses "Please make contact information fields, how to contact the user, email address, telegrams, various social networks https://www.openstreetmap.org" issue mentioned in the #2245
Description
This PR adds:
Currently parser parses these websites and adds their icons which are taken from Bootstrap-Icons:
Discord, Line, Skype and Slack doesn't show username in the URL. To avoid showing some Id numbers on the profile page, for these cases instead of the Id only the name of the application is shown.
Applications other than those mentioned in the list show their URL on the profile page and have general web icon (globe icon).
If there is an idea that some of them should be removed or others should be added, feel free to share recommendations.
Parser was done in the Ruby to avoid adding more JS client-side logic to the website. If it is preferable, it can be moved to JS.
How has this been tested?
There are validation and functional tests written to test the functionality. In addition to this, different kind of manual testing was done to ensure that all the icons, errors, fields and etc. were displayed correctly.
Screenshots
Logged out:
![image](https://private-user-images.githubusercontent.com/55288419/398124807-cbd7bb83-5363-463b-bbad-92695394fb77.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0OTI0MzcsIm5iZiI6MTczOTQ5MjEzNywicGF0aCI6Ii81NTI4ODQxOS8zOTgxMjQ4MDctY2JkN2JiODMtNTM2My00NjNiLWJiYWQtOTI2OTUzOTRmYjc3LnBuZz9YLUFtei1B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Vycz1ob3N0In0.A7jbMpd26_E2k_7rXxM0r7kTJAkbNTUu0-8NbsAaR0k)
Logged in:
![image](https://private-user-images.githubusercontent.com/55288419/398125132-c183b9b3-50e0-4ce7-888b-7a0228fc0547.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0OTI0MzcsIm5iZiI6MTczOTQ5MjEzNywicGF0aCI6Ii81NTI4ODQxOS8zOTgxMjUxMzItYzE4M2I5YjMtNTBlMC00Y2U3LTg4OGItN2EwMjI4ZmMwNTQ3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDAwMTUzN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA4ZTc5Zjk2ZWQ0ZjQyYzUwM2U5YzQ3NTFlYjA1NmRjOWNjMWJmMjhkMWI2YmI2NjM1MzkxNGY5YzZlNzBmNDgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.ODbiNPQzZwJetXqb7rEwvO_dhwhGEfkAi9n9JuM6AK8)
Edit Profile page:
![image](https://private-user-images.githubusercontent.com/55288419/398125256-f7c14102-0d3f-4685-a243-1281ae9c8751.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0OTI0MzcsIm5iZiI6MTczOTQ5MjEzNywicGF0aCI6Ii81NTI4ODQxOS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