From 7afc0869857a3620c3145f09d19cb1b71aaa3a18 Mon Sep 17 00:00:00 2001 From: Ben Halpern Date: Tue, 5 Nov 2024 10:03:10 -0500 Subject: [PATCH] Remove superfluous content from article show page (#21349) * Only include optional ltag scripts if content matches * Adjust runkit tag logic * Global init buttons * remove unnecessary initbuttons --- app/javascript/packs/organizationDropdown.js | 1 - app/views/articles/_actions.html.erb | 14 -------------- app/views/articles/show.html.erb | 13 ++++++++++--- app/views/comments/_comment_proper.html.erb | 10 ++++++++++ config/locales/views/actions/en.yml | 2 +- config/locales/views/actions/fr.yml | 2 +- .../articleFlows/postSidebarActions.spec.js | 4 +--- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/app/javascript/packs/organizationDropdown.js b/app/javascript/packs/organizationDropdown.js index 3f5f58b01bf8..80982ab04769 100644 --- a/app/javascript/packs/organizationDropdown.js +++ b/app/javascript/packs/organizationDropdown.js @@ -22,7 +22,6 @@ function initDropdown() { ); reportAbuseLink.innerHTML = `Report Abuse`; - initButtons(); profileDropdownDiv.dataset.dropdownInitialized = true; } diff --git a/app/views/articles/_actions.html.erb b/app/views/articles/_actions.html.erb index 12ab5812ddc6..483390ccc31e 100644 --- a/app/views/articles/_actions.html.erb +++ b/app/views/articles/_actions.html.erb @@ -47,20 +47,6 @@ href="https://www.linkedin.com/shareArticle?mini=true&url=<%= u article_url(@article) %>&title=<%= u @article.title %>&summary=<%= u @article.description %>&source=<%= u community_name %>"> <%= t("views.actions.share.linkedin.text") %> - - <%= t("views.actions.share.reddit.text") %> - - - <%= t("views.actions.share.hackernews.text") %> - <%# we consider these scripts safe for embedding as they come from our code %> - <%== PodcastTag.script %> - <%== PollTag.script %> + <% if @article.processed_html.include?("podcastliquidtag") %> + <%== PodcastTag.script %> + <% end %> + <% if @article.processed_html.include?("ltag-poll") %> + <%== PollTag.script %> + <% end %> + <% if @article.processed_html.include?("tweet-embed") %> + <%== TweetTag.script %> + <% end %> + <%# We should be able to make this conditional in future, but defines a global variable for now %> <%== RunkitTag.script %> - <%== TweetTag.script %>
diff --git a/app/views/comments/_comment_proper.html.erb b/app/views/comments/_comment_proper.html.erb index c475b53037f1..84a5084a518c 100644 --- a/app/views/comments/_comment_proper.html.erb +++ b/app/views/comments/_comment_proper.html.erb @@ -43,6 +43,16 @@ <% end %> + + <%= unless comment.deleted || commentable.nil? || should_be_hidden?(comment, @root_comment) (render partial: "comments/comment_footer", locals: { comment: comment, diff --git a/config/locales/views/actions/en.yml b/config/locales/views/actions/en.yml index c3266c1fd7fa..7547f6fc9a7d 100644 --- a/config/locales/views/actions/en.yml +++ b/config/locales/views/actions/en.yml @@ -20,7 +20,7 @@ en: reddit: text: Share to Reddit twitter: - text: Share to Twitter + text: Share to X query: '"%{article}" by %{author}' link: Share Post via... report: Report Abuse diff --git a/config/locales/views/actions/fr.yml b/config/locales/views/actions/fr.yml index b9b8331d9cf9..e00e685bce78 100644 --- a/config/locales/views/actions/fr.yml +++ b/config/locales/views/actions/fr.yml @@ -20,7 +20,7 @@ fr: reddit: text: Partager sur Reddit twitter: - text: Partager sur Twitter + text: Partager sur X query: '"%{article}" by %{author}' link: Share Post via... report: Report Abuse diff --git a/cypress/e2e/seededFlows/articleFlows/postSidebarActions.spec.js b/cypress/e2e/seededFlows/articleFlows/postSidebarActions.spec.js index dbf301847608..2240ede238b0 100644 --- a/cypress/e2e/seededFlows/articleFlows/postSidebarActions.spec.js +++ b/cypress/e2e/seededFlows/articleFlows/postSidebarActions.spec.js @@ -28,10 +28,8 @@ describe('Post sidebar actions', () => { cy.get('@dropdownButton').click(); cy.findByRole('button', { name: /^Copy link$/i }).as('copyPostUrlButton'); cy.get('@copyPostUrlButton').should('have.focus'); - cy.findByRole('link', { name: /^Share to Twitter$/i }); + cy.findByRole('link', { name: /^Share to X$/i }); cy.findByRole('link', { name: /^Share to LinkedIn$/i }); - cy.findByRole('link', { name: /^Share to Reddit$/i }); - cy.findByRole('link', { name: /^Share to Hacker News$/i }); cy.findByRole('link', { name: /^Share to Facebook$/i }); // There is a report abuse link at the bottom of the post too cy.findAllByRole('link', { name: /^Report Abuse$/i }).should(