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

Add social profile links #5439

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nertc
Copy link
Contributor

@nertc nertc commented Dec 23, 2024

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:

  • DB: Social links table, which contains social links added by the user
  • Model: Parser to differentiate different kind of websites
  • Controller: Logic for CRUD operations for social links
  • View: Functionality to show, edit, add and delete social links
  • JS: Was only used for adding and removing fields on the user side when they interact to the social links fields

Currently parser parses these websites and adds their icons which are taken from Bootstrap-Icons:

  • Discord
  • Facebook
  • Github
  • Gitlab
  • Instagram
  • Linkedin
  • Line
  • Mastodon
  • Medium
  • Quora
  • Reddit
  • Skype
  • Slack
  • Snapchat
  • Stack Overflow
  • Strava
  • Substack
  • Telegram
  • Threads
  • Tik-Tok
  • Twitch
  • X (Twitter)
  • Vimeo
  • WhatsApp
  • YouTube

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
image

Logged in:
image

Edit Profile page:
image
image

@nertc nertc mentioned this pull request Dec 23, 2024
@nertc nertc force-pushed the issue_2245_add_social_links branch from 471cbf6 to 46f7da6 Compare December 24, 2024 07:01
@nertc nertc force-pushed the issue_2245_add_social_links branch from 46f7da6 to 55c89e6 Compare December 24, 2024 07:08
@nertc nertc marked this pull request as ready for review December 24, 2024 07:19
@AntonKhorev
Copy link
Collaborator

Do we need another set of icons in addition to app/assets/images/social_icons?


def parsed
URL_PATTERNS.each do |platform, pattern|
username = url.match(pattern)
Copy link
Collaborator

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?

Copy link
Contributor Author

@nertc nertc Dec 27, 2024

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)

Copy link
Collaborator

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.

<% end %>
</div>

<%= link_to "+", "#", :id => "add-social-link", :class => "btn btn-outline-primary" %>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is it a link and not a button?

Why adding is "+" but removing is "Remove"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had a different logic that needed a link, as I changed logic, I agree with you, I'll change it to button.

My idea was that + sign doesn't require any additional icons and is intuitive, while Remove needs trash icon to be intuitive (- sign doesn't always mean removal and sometimes it may be ambiguous). But I agree with you, maybe it's better to be consistent in this too. Which one do you think is better, to change + sign to Add (which will be much easier and less-code solution) or to change Remove to trash icon (which may be nicer in terms of UI, but will require trash icon and, therefore, more code)?

`);

socialLinkForm.find("button").click(function () {
$(this).parent().remove();
Copy link
Collaborator

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.

class SocialLink < ApplicationRecord
belongs_to :user

validates :url, :presence => true, :format => { :with => URI::DEFAULT_PARSER.make_regexp(%w[http https]), :message => I18n.t("profiles.edit.social_links.http_parse_error") }
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't check if url starts with http://.

And if you also disable CSP:
image

@AntonKhorev
Copy link
Collaborator

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 <textarea>, it's easier to edit. In this case I'd have a textarea with each nonempty line corresponding to a link. Why don't people do this? Is it too geeky?

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

Successfully merging this pull request may close these issues.

2 participants