[openstreetmap/openstreetmap-website] Add social profile links (PR #5439)

Minh Nguyễn notifications at github.com
Thu Mar 13 23:01:26 UTC 2025


@1ec5 commented on this pull request.



> +
+class SocialLink < ApplicationRecord
+  belongs_to :user
+
+  validates :url, :format => { :with => %r{\Ahttps?://.+\z}, :message => :http_parse_error }
+
+  URL_PATTERNS = {
+    :bluesky => %r{\Ahttps?://(?:www\.)?bsky\.app/profile/([a-zA-Z0-9\._-]+)},
+    :discord => %r{\Ahttps?://(?:www\.)?discord\.com/users/(\d+)},
+    :facebook => %r{\Ahttps?://(?:www\.)?facebook\.com/([a-zA-Z0-9.]+)},
+    :github => %r{\Ahttps?://(?:www\.)?github\.com/([a-zA-Z0-9_-]+)},
+    :gitlab => %r{\Ahttps?://(?:www\.)?gitlab\.com/([a-zA-Z0-9_-]+)},
+    :instagram => %r{\Ahttps?://(?:www\.)?instagram\.com/([a-zA-Z0-9._]+)},
+    :linkedin => %r{\Ahttps?://(?:www\.)?linkedin\.com/in/([a-zA-Z0-9_-]+)},
+    :line => %r{\Ahttps?://(?:www\.)?line\.me/ti/p/([a-zA-Z0-9_-]+)},
+    :mastodon => %r{\Ahttps?://(?:(?:www\.)?mastodon\.social|en\.osm\.town)/@([a-zA-Z0-9_]+)},

This is very restrictive. A lot of OSM contributors have accounts in other places, such as but not limited to [Mapstodon](https://mapstodon.space/). Sites that accept Mastodon accounts typically accept them in one of the following formats:

* `mapper at example.net`
* `@mapper at example.net`
* `https://example.net/@mapper`

There’s no way to validate a Mastodon profile URL or Mastodon address by domain, as that would defeat the purpose of the Fediverse.

If the purpose of this regex is only to assign a Mastodon icon, that’s no big deal. But it looks like the link in the profile only displays the local part of the Mastodon address. This can get confusing when multiple servers have accounts with the same name. The standard display format is `@mapper at example.com`.

> +#
+# Foreign Keys
+#
+#  fk_rails_...  (user_id => users.id)
+#
+
+class SocialLink < ApplicationRecord
+  belongs_to :user
+
+  validates :url, :format => { :with => %r{\Ahttps?://.+\z}, :message => :http_parse_error }
+
+  URL_PATTERNS = {
+    :bluesky => %r{\Ahttps?://(?:www\.)?bsky\.app/profile/([a-zA-Z0-9\._-]+)},
+    :discord => %r{\Ahttps?://(?:www\.)?discord\.com/users/(\d+)},
+    :facebook => %r{\Ahttps?://(?:www\.)?facebook\.com/([a-zA-Z0-9.]+)},
+    :github => %r{\Ahttps?://(?:www\.)?github\.com/([a-zA-Z0-9_-]+)},

Flickr might be a nice one to add. I’ve seen lots of examples of people using their Flickr accounts to host photos taken during field surveys, and our forum has special handling for Flickr photos.

> +#
+# Indexes
+#
+#  index_social_links_on_user_id  (user_id)
+#
+# Foreign Keys
+#
+#  fk_rails_...  (user_id => users.id)
+#
+
+class SocialLink < ApplicationRecord
+  belongs_to :user
+
+  validates :url, :format => { :with => %r{\Ahttps?://.+\z}, :message => :http_parse_error }
+
+  URL_PATTERNS = {

Some suggestions for additional sites that users might want to display on their profiles in the same manner, in case the list isn’t strictly limited to social media accounts:

* OSM Community Forum (though it should be automatic)
* OpenGeofiction and OpenHistoricalMap
* Wikipedia, Wikidata, Wikivoyage, and Wikimedia Commons

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5439#pullrequestreview-2683519315
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/5439/review/2683519315 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250313/9f884cbf/attachment.htm>


More information about the rails-dev mailing list