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

Change Twitter sharing references fully to X #1078

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed app/assets/images/icons/icon_share-twitter-2x.png
Binary file not shown.
Binary file removed app/assets/images/icons/icon_share-twitter.png
Binary file not shown.
Binary file added app/assets/images/icons/icon_share-x-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/icons/icon_share-x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions app/assets/stylesheets/petitions/_icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// Icons
// .icon .icon-share-facebook
// .icon .icon-share-email
// .icon .icon-share-twitter
// .icon .icon-share-x
// .icon .icon-share-whatsapp
// .icon .icon-email
// .icon .icon-warning-white
Expand Down Expand Up @@ -154,13 +154,13 @@
background-size: 18px 13px;
}
}
.icon-share-twitter {
.icon-share-x {
width: 16px;
height: 13px;
background-image: image-url("icons/icon_share-twitter.png");
background-image: image-url("icons/icon_share-x.png");

@include device-pixel-ratio() {
background-image: image-url("icons/icon_share-twitter-2x.png");
background-image: image-url("icons/icon_share-x-2x.png");
background-size: 16px 13px;
}
}
Expand Down
10 changes: 5 additions & 5 deletions app/helpers/sharing_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ def share_via_email_url(petition)
"mailto:?#{share_via_email_params(petition)}"
end

def share_via_twitter(petition, options = {})
link_to(share_button(:twitter), share_via_twitter_url(petition), options)
def share_via_x(petition, options = {})
link_to(share_button(:x), share_via_x_url(petition), options)
end

def share_via_twitter_url(petition)
"https://twitter.com/intent/tweet?#{share_via_twitter_params(petition)}"
def share_via_x_url(petition)
"https://x.com/intent/post?#{share_via_x_params(petition)}"
end

def share_via_whatsapp(petition, options = {})
Expand All @@ -41,7 +41,7 @@ def share_via_email_params(petition)
share_params(subject: share_title(petition), body: petition_url(petition))
end

def share_via_twitter_params(petition)
def share_via_x_params(petition)
share_params(text: share_title(petition), url: petition_url(petition))
end

Expand Down
4 changes: 2 additions & 2 deletions app/helpers/social_meta_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ def open_graph_tag(name, content, interpolation = {})
end
end

def twitter_card_tag(name, content, interpolation = {})
def x_card_tag(name, content, interpolation = {})
if Symbol === content
tag(:meta, name: "twitter:#{name}", content: t(content, **(interpolation.merge(scope: :'metadata.twitter'))))
tag(:meta, name: "twitter:#{name}", content: t(content, **(interpolation.merge(scope: :'metadata.x'))))
elsif name == 'image'
tag(:meta, name: "twitter:image", content: url_to_image(content))
else
Expand Down
2 changes: 1 addition & 1 deletion app/views/application/_share_petition.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= share_via_email(petition, rel: 'external', target: '_blank') %>
</li>
<li>
<%= share_via_twitter(petition, rel: 'external', target: '_blank') %>
<%= share_via_x(petition, rel: 'external', target: '_blank') %>
</li>
<li class="petition-share-whatsapp">
<%= share_via_whatsapp(petition, rel: 'external', target: '_blank') %>
Expand Down
20 changes: 10 additions & 10 deletions app/views/application/_social_meta.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
<%= open_graph_tag 'type', 'website' %>
<%= open_graph_tag 'title', page_title %>
<% end %>
<!-- Twitter -->
<%= twitter_card_tag 'card', 'summary' %>
<%= twitter_card_tag 'site', '@hocpetitions' %>
<%= twitter_card_tag 'image', 'os-social/opengraph-image.png' %>
<!-- X -->
<%= x_card_tag 'card', 'summary' %>
<%= x_card_tag 'site', '@hocpetitions' %>
<%= x_card_tag 'image', 'os-social/opengraph-image.png' %>
<% if archived_petition_page? %>
<%= twitter_card_tag 'title', :title, petition: @petition.action %>
<%= twitter_card_tag 'description', @petition.background? ? @petition.background : @petition.additional_details %>
<%= x_card_tag 'title', :title, petition: @petition.action %>
<%= x_card_tag 'description', @petition.background? ? @petition.background : @petition.additional_details %>
<% elsif defined?(@petition) %>
<%= twitter_card_tag 'title', :title, petition: @petition.action %>
<%= twitter_card_tag 'description', @petition.background %>
<%= x_card_tag 'title', :title, petition: @petition.action %>
<%= x_card_tag 'description', @petition.background %>
<% else %>
<%= twitter_card_tag 'title', page_title %>
<%= twitter_card_tag 'description', 'Official online petitions in response to issues of the day, listing the number that got a Government response, and those that have been debated in the House of Parliament' %>
<%= x_card_tag 'title', page_title %>
<%= x_card_tag 'description', 'Official online petitions in response to issues of the day, listing the number that got a Government response, and those that have been debated in the House of Parliament' %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<p>The current Petitions Committee, the group of MPs who decide whether petitions are debated, won’t exist after <%= @closing_date %>. This means that if <%= @count > 1 ? "any of your petitions" : "your petition" %> has over <%= Site.formatted_threshold_for_debate %> signatures, <%= @count > 1 ? "they" : "it" %> can’t be scheduled for debate during this Parliament. After the election, a new Petitions Committee will be responsible for deciding which petitions are debated.</p>

<p>The petitions site will reopen when a new Petitions Committee is appointed, but at the moment we don’t know exactly when. You can follow us on X (formerly Twitter) <a href="https://x.com/HoCPetitions">@HoCPetitions</a> for updates, or check back on the petitions site for news.</p>
<p>The petitions site will reopen when a new Petitions Committee is appointed, but at the moment we don’t know exactly when. You can follow us on X <a href="https://x.com/HoCPetitions">@HoCPetitions</a> for updates, or check back on the petitions site for news.</p>

<% if Parliament.dissolution_faq_url? %>
<p>You can find out more about what the General Election means for your petitions on our website: <%= link_to(nil, Parliament.dissolution_faq_url) %></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The Government can’t respond to petitions during the election period. This mea

The Petitions Committee, the group of MPs who decide whether petitions are debated, won’t exist after <%= @closing_date %>. This means that if <%= @count > 1 ? "any of your petitions" : "your petition" %> has over <%= Site.formatted_threshold_for_debate %> signatures, <%= @count > 1 ? "they" : "it" %> can’t be scheduled for debate during this Parliament. After the election, a new Petitions Committee will be responsible for deciding which petitions are debated.

The petitions site will reopen when a new Petitions Committee is appointed, but at the moment we don’t know exactly when. You can follow us on X (formerly Twitter) @HoCPetitions for updates, or check back on the petitions site for news.
The petitions site will reopen when a new Petitions Committee is appointed, but at the moment we don’t know exactly when. You can follow us on X @HoCPetitions for updates, or check back on the petitions site for news.

<% if Parliament.dissolution_faq_url? %>
You can find out more about what the General Election means for your petitions on our website: <%= Parliament.dissolution_faq_url %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<p>Petitions started before the election won’t restart when the site opens again. You are very welcome to resubmit your petition once the site reopens, but you’ll need to collect your five sponsor signatures again.</p>

<p>The petitions site will reopen when a new Petitions Committee is appointed, but at the moment we don’t know exactly when. You can follow us on X (formerly Twitter) <a href="https://x.com/HoCPetitions">@HoCPetitions</a> for updates, or check back on the petitions site for news.</p>
<p>The petitions site will reopen when a new Petitions Committee is appointed, but at the moment we don’t know exactly when. You can follow us on X <a href="https://x.com/HoCPetitions">@HoCPetitions</a> for updates, or check back on the petitions site for news.</p>

<% if Parliament.dissolution_faq_url? %>
<p>You can find out more about what the General Election means for your petitions on our website: <%= link_to(nil, Parliament.dissolution_faq_url) %></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ We’re very sorry that we didn’t have time to check your petition before this

Petitions started before the election won’t restart when the site opens again. You are very welcome to resubmit your petition once the site reopens, but you’ll need to collect your five sponsor signatures again.

The petitions site will reopen when a new Petitions Committee is appointed, but at the moment we don’t know exactly when. You can follow us on X (formerly Twitter) @HoCPetitions for updates, or check back on the petitions site for news.
The petitions site will reopen when a new Petitions Committee is appointed, but at the moment we don’t know exactly when. You can follow us on X @HoCPetitions for updates, or check back on the petitions site for news.

<% if Parliament.dissolution_faq_url? %>
You can find out more about what the General Election means for your petitions on our website: <%= Parliament.dissolution_faq_url %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<p>Petitions started before the election won’t restart when the site opens again. You are very welcome to resubmit your petition once the site reopens, but you’ll need to collect your sponsor signatures again.</p>

<p>The petitions site will reopen when a new Petitions Committee is appointed, but at the moment we don’t know exactly when. You can follow us on X (formerly Twitter) <a href="https://x.com/HoCPetitions">@HoCPetitions</a> for updates, or check back on the petitions site for news.</p>
<p>The petitions site will reopen when a new Petitions Committee is appointed, but at the moment we don’t know exactly when. You can follow us on X <a href="https://x.com/HoCPetitions">@HoCPetitions</a> for updates, or check back on the petitions site for news.</p>

<% if Parliament.dissolution_faq_url? %>
<p>You can find out more about what the General Election means for your petitions on our website: <%= link_to(nil, Parliament.dissolution_faq_url) %></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ We’re very sorry that you didn’t have time to collect your five signatures b

Petitions started before the election won’t restart when the site opens again. You are very welcome to resubmit your petition once the site reopens, but you’ll need to collect your sponsor signatures again.

The petitions site will reopen when a new Petitions Committee is appointed, but at the moment we don’t know exactly when. You can follow us on X (formerly Twitter) @HoCPetitions for updates, or check back on the petitions site for news.
The petitions site will reopen when a new Petitions Committee is appointed, but at the moment we don’t know exactly when. You can follow us on X @HoCPetitions for updates, or check back on the petitions site for news.

<% if Parliament.dissolution_faq_url? %>
You can find out more about what the General Election means for your petitions on our website: <%= Parliament.dissolution_faq_url %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<p>The current Petitions Committee, the group of MPs who decide whether petitions are debated, won’t exist after <%= @closing_date %>. This means that if <%= @count > 1 ? "any of the petitions" : "the petition" %> has over <%= Site.formatted_threshold_for_debate %> signatures, <%= @count > 1 ? "they" : "it" %> can’t be scheduled for debate during this Parliament. After the election, a new Petitions Committee will be responsible for deciding which petitions are debated.</p>

<p>The petitions site will reopen when a new Petitions Committee is appointed, but at the moment we don’t know exactly when. You can follow us on X (formerly Twitter) <a href="https://x.com/HoCPetitions">@HoCPetitions</a> for updates, or check back on the petitions site for news.</p>
<p>The petitions site will reopen when a new Petitions Committee is appointed, but at the moment we don’t know exactly when. You can follow us on X <a href="https://x.com/HoCPetitions">@HoCPetitions</a> for updates, or check back on the petitions site for news.</p>

<% if Parliament.dissolution_faq_url? %>
<p>You can find out more about what the General Election means for your petitions on our website: <%= link_to(nil, Parliament.dissolution_faq_url) %></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The Government can’t respond to petitions during the election period. This mea

The Petitions Committee, the group of MPs who decide whether petitions are debated, won’t exist after <%= @closing_date %>. This means that if <%= @count > 1 ? "any of the petitions" : "the petition" %> has over <%= Site.formatted_threshold_for_debate %> signatures, <%= @count > 1 ? "they" : "it" %> can’t be scheduled for debate during this Parliament. After the election, a new Petitions Committee will be responsible for deciding which petitions are debated.

The petitions site will reopen when a new Petitions Committee is appointed, but at the moment we don’t know exactly when. You can follow us on X (formerly Twitter) @HoCPetitions for updates, or check back on the petitions site for news.
The petitions site will reopen when a new Petitions Committee is appointed, but at the moment we don’t know exactly when. You can follow us on X @HoCPetitions for updates, or check back on the petitions site for news.

<% if Parliament.dissolution_faq_url? %>
You can find out more about what the General Election means for your petitions on our website: <%= Parliament.dissolution_faq_url %>
Expand Down
2 changes: 1 addition & 1 deletion config/locales/metadata.en-GB.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ en-GB:
title: "Petition: %{petition}"
archived_title: "Archived Petition: %{petition}"

twitter:
x:
default_title: "Petitions - UK Government and Parliament"
title: "Petition: %{petition}"
archived_title: "Archived Petition: %{petition}"
4 changes: 2 additions & 2 deletions config/locales/petitions.en-GB.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ en-GB:
html: <span class="icon icon-share-facebook"></span> Facebook
email:
html: <span class="icon icon-share-email"></span> Email
twitter:
html: <span class="icon icon-share-twitter"></span> Twitter
x:
html: <span class="icon icon-share-x"></span> X
whatsapp:
html: <span class="icon icon-share-whatsapp"></span> Whatsapp

Expand Down
4 changes: 2 additions & 2 deletions features/step_definitions/petition_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,9 @@
within(:css, '.petition-share') do
expect(page).to have_link('Facebook', href: %r[\Ahttps://www\.facebook\.com/sharer/sharer\.php\?ref=responsive&u=#{ERB::Util.url_encode(petition_url(@petition))}\z])
end
when 'Twitter'
when 'X'
within(:css, '.petition-share') do
expect(page).to have_link('Twitter', href: %r[\Ahttps://twitter\.com/intent/tweet\?text=Petition%3A%20#{ERB::Util.url_encode(@petition.action)}&url=#{ERB::Util.url_encode(petition_url(@petition))}\z])
expect(page).to have_link('X', href: %r[\Ahttps://x\.com/intent/post\?text=Petition%3A%20#{ERB::Util.url_encode(@petition.action)}&url=#{ERB::Util.url_encode(petition_url(@petition))}\z])
end
when 'Whatsapp'
within(:css, '.petition-share') do
Expand Down
2 changes: 1 addition & 1 deletion features/suzie_views_a_petition.feature
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Feature: Suzie views a petition
And I should not see "This petition is closed"
And I can share it via Email
And I can share it via Facebook
And I can share it via Twitter
And I can share it via X
And I can share it via Whatsapp

Scenario: Suzie views a petition containing urls, email addresses and html tags
Expand Down
8 changes: 4 additions & 4 deletions spec/helpers/sharing_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
end
end

describe "#share_via_twitter_url" do
it "generates a share via Twitter url" do
expect(helper.share_via_twitter_url(petition)).to eq <<-URL.strip
https://twitter.com/intent/tweet?text=Petition%3A%20Do%20something&url=https%3A%2F%2Fpetition.parliament.uk%2Fpetitions%2F100000
describe "#share_via_x_url" do
it "generates a share via X url" do
expect(helper.share_via_x_url(petition)).to eq <<-URL.strip
https://x.com/intent/post?text=Petition%3A%20Do%20something&url=https%3A%2F%2Fpetition.parliament.uk%2Fpetitions%2F100000
URL
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/helpers/social_meta_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
end
end

describe "#twitter_card_tag" do
describe "#x_card_tag" do
context "when using a string for content" do
subject do
helper.twitter_card_tag("site", "@hocpetitions")
helper.x_card_tag("site", "@hocpetitions")
end

it "generates a meta tag with the content" do
Expand All @@ -64,7 +64,7 @@

context "when using a symbol for content" do
subject do
helper.twitter_card_tag("title", :default_title)
helper.x_card_tag("title", :default_title)
end

it "generates a meta tag with the i18n content" do
Expand All @@ -74,7 +74,7 @@

context "when using a symbol for content with interpolation" do
subject do
helper.twitter_card_tag("title", :title, petition: "Show us the money")
helper.x_card_tag("title", :title, petition: "Show us the money")
end

it "generates a meta tag with the i18n content" do
Expand All @@ -90,7 +90,7 @@
end

subject do
helper.twitter_card_tag("image", "os-social/opengraph-image.png")
helper.x_card_tag("image", "os-social/opengraph-image.png")
end

it "generates a meta tag with the correct asset image url" do
Expand Down