<p></p>
<p><b>@tomhughes</b> requested changes on this pull request.</p>
<p dir="auto">Added a few comments inline... Other things to consider are whether to offer some other sites - bluesky and threads being the obvious candidates.</p><hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4985#discussion_r1722174489">app/assets/javascripts/social_share_button.js</a>:</p>
<pre style='color:#555'>> @@ -0,0 +1,27 @@
+// Opening pop-ups with share URL
+function openShareUrl(url, initialWidth = 640, initialHeight = 480) {
+ if (typeof url !== "string" || !url.startsWith("http")) {
+ console.error("Invalid URL"); // Consider removing this line if console warnings should be avoided.
</pre>
<p dir="auto">Under what circumstances is this expected to happen?</p>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4985#discussion_r1722177014">app/views/layouts/_head.html.erb</a>:</p>
<pre style='color:#555'>> @@ -5,6 +5,7 @@
<%= javascript_include_tag "turbo", :type => "module" %>
<%= javascript_include_tag "application" %>
<%= javascript_include_tag "i18n/#{I18n.locale}" %>
+ <%= javascript_include_tag "social_share_button" %>
</pre>
<p dir="auto">If this is going to be included everywhere then if can just be added to <code class="notranslate">app/assets/javascripts/application.js</code> rather than including it separately here.</p>
<p dir="auto">The alternative is to do what <code class="notranslate">app/views/accounts/edit.html.erb</code> does to include it only in those view that use it.</p>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4985#discussion_r1722178941">lib/social_share_button_helper.rb</a>:</p>
<pre style='color:#555'>> +
+ def self.generate_share_url(site, params)
+ site = site.to_sym
+ case site
+ when :email
+ "mailto:?subject=#{URI.encode_www_form_component(params[:title])}&body=#{URI.encode_www_form_component(params[:url])}"
+ when :x
+ via_str = params[:via] ? "&via=#{URI.encode_www_form_component(params[:via])}" : ""
+ hashtags_str = params[:hashtags] ? "&hashtags=#{URI.encode_www_form_component(params[:hashtags].join(','))}" : ""
+ "https://x.com/intent/tweet?url=#{URI.encode_www_form_component(params[:url])}&text=#{URI.encode_www_form_component(params[:title])}#{hashtags_str}#{via_str}"
+ when :linkedin
+ "https://www.linkedin.com/shareArticle?mini=true&url=#{URI.encode_www_form_component(params[:url])}"
+ when :facebook
+ "https://www.facebook.com/sharer/sharer.php?url=#{URI.encode_www_form_component(params[:url])}"
+ when :mastodon
+ "https://mastodon.social/share?text=#{URI.encode_www_form_component(params[:title])}&url=#{URI.encode_www_form_component(params[:url])}"
</pre>
<p dir="auto">This is next to useless because it only works if your mastodon account is on <code class="notranslate">mastodon.social</code> which won't be true for most people...</p>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4985#discussion_r1722178052">lib/social_share_button_helper.rb</a>:</p>
<pre style='color:#555'>> + [valid_sites, invalid_sites]
+ end
+
+ def self.icon_path(site)
+ SOCIAL_SHARE_CONFIG[site.to_sym] || ""
+ end
+
+ def self.valid_site?(site)
+ SOCIAL_SHARE_CONFIG.key?(site.to_sym)
+ end
+
+ def self.generate_share_url(site, params)
+ site = site.to_sym
+ case site
+ when :email
+ "mailto:?subject=#{URI.encode_www_form_component(params[:title])}&body=#{URI.encode_www_form_component(params[:url])}"
</pre>
<p dir="auto">This doesn't work anyway, at least in firefox, because it just throws an invalid URL error when you click on a mailto URl with no address.</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4985#pullrequestreview-2246176635">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLLNCBE7Z3KAM3I2WWDZSIZQRAVCNFSM6AAAAABK2RPBLKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDENBWGE3TMNRTGU">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLLK27HEQVM2DAHSCV3ZSIZQRA5CNFSM6AAAAABK2RPBLKWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTUF4HXXW.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/4985/review/2246176635</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/4985#pullrequestreview-2246176635",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/4985#pullrequestreview-2246176635",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>