Skip to content

Commit

Permalink
Remove superfluous content from article show page (forem#21349)
Browse files Browse the repository at this point in the history
* Only include optional ltag scripts if content matches

* Adjust runkit tag logic

* Global init buttons

* remove unnecessary initbuttons
  • Loading branch information
benhalpern authored Nov 5, 2024
1 parent 84ab303 commit 7afc086
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
1 change: 0 additions & 1 deletion app/javascript/packs/organizationDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function initDropdown() {
);
reportAbuseLink.innerHTML = `<a href="${reportAbuseLink.dataset.path}" class="crayons-link crayons-link--block">Report Abuse</a>`;

initButtons();
profileDropdownDiv.dataset.dropdownInitialized = true;
}

Expand Down
14 changes: 0 additions & 14 deletions app/views/articles/_actions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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") %>
</a>
<a
target="_blank"
class="crayons-link crayons-link--block"
rel="noopener"
href="https://www.reddit.com/submit?url=<%= u article_url(@article) %>&title=<%= u @article.title %>">
<%= t("views.actions.share.reddit.text") %>
</a>
<a
target="_blank"
class="crayons-link crayons-link--block"
rel="noopener"
href="https://news.ycombinator.com/submitlink?u=<%= u article_url(@article) %>&t=<%= u @article.title %>">
<%= t("views.actions.share.hackernews.text") %>
</a>
<a
target="_blank"
class="crayons-link crayons-link--block"
Expand Down
13 changes: 10 additions & 3 deletions app/views/articles/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,16 @@

<script>
<%# 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 %>
</script>
<div class="js-billboard-container pb-4 crayons-layout__comments-billboard" data-async-url="<%= article_billboard_path(username: @article.username, slug: @article.slug, placement_area: :post_fixed_bottom) %>"></div>
10 changes: 10 additions & 0 deletions app/views/comments/_comment_proper.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@
<% end %>
</div>

<script>
<%# we consider these scripts safe for embedding as they come from our code %>
<% if comment.processed_html.include?("podcastliquidtag") %>
<%== PodcastTag.script %>
<% end %>
<% if comment.processed_html.include?("tweet-embed") %>
<%== TweetTag.script %>
<% end %>
</script>

<%= unless comment.deleted || commentable.nil? || should_be_hidden?(comment, @root_comment)
(render partial: "comments/comment_footer", locals: {
comment: comment,
Expand Down
2 changes: 1 addition & 1 deletion config/locales/views/actions/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion config/locales/views/actions/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 7afc086

Please sign in to comment.