Skip to content

Commit

Permalink
Remove Twitter, add new socials to article share
Browse files Browse the repository at this point in the history
  • Loading branch information
veganstraightedge committed Feb 22, 2025
1 parent f22e9a0 commit 48dd7e8
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Metrics/MethodLength:
- "db/migrate/*"

Metrics/ModuleLength:
Max: 116
Max: 121

Metrics/ParameterLists:
Max: 6
Expand Down
51 changes: 6 additions & 45 deletions app/assets/images/social-icons/bluesky.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 3 additions & 10 deletions app/assets/images/social-icons/email.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions app/assets/images/social-icons/threads.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app/assets/stylesheets/2017/components/_social.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
// The Mastodon account is on a domain called todon.eu
.link-domain-todon,
.link-domain-mastodon { @include social-icon("mastodon"); }
.link-domain-email { @include social-icon("email"); }
.link-domain-facebook { @include social-icon("facebook"); }
.link-domain-github { @include social-icon("github"); }
.link-domain-instagram { @include social-icon("instagram"); }
.link-domain-telegram { @include social-icon("telegram"); }
.link-domain-threads { @include social-icon("threads"); }
.link-domain-tiktok { @include social-icon("tiktok"); }
.link-domain-tumblr { @include social-icon("tumblr"); }
.link-domain-twitter { @include social-icon("twitter"); }
Expand Down
20 changes: 12 additions & 8 deletions app/helpers/articles_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,40 @@ def social_share_sites article
slug: article.slug

{
Twitter: "https://twitter.com/intent/tweet?text=#{url_encode article.title}&url=#{url}&via=crimethinc",
Email: "mailto:?subject=#{article.title}",
Facebook: "https://www.facebook.com/sharer?u=#{url_encode url}",
Tumblr: ['http://tumblr.com/widgets/share/tool?canonicalUrl=', url, '&caption=',
url_encode(article.title), '&content=', article.image].join
}
end

def social_links_for article
domains = %i[email bluesky mastodon threads facebook tumblr]

tag.ul class: 'social-links' do
social_link_for(article, :twitter) +
social_link_for(article, :facebook) +
social_link_for(article, :tumblr)
domains.map { social_link_for article, it }.join.html_safe
end
end

def social_link_for article, site
# TODO: change list of social sites
# TODO: add: mastodon, bluesky, threads
# TODO: remove: twitter
url = article_url year: article.year,
month: article.month,
day: article.day,
slug: article.slug

share_url =
case site
when :twitter
"https://twitter.com/intent/tweet?text=#{url_encode article.title}&url=#{url}&via=crimethinc"
when :email
"mailto:?subject=CrimethInc.— #{article.name}&body=#{article.name} #{url_encode url}"
when :bluesky
"https://bsky.app/intent/compose?text=#{article.name} #{url_encode url} — @crimethinc.com "
when :facebook
"https://www.facebook.com/sharer?u=#{url_encode url}"
when :mastodon
"http://mastodon.social/share?text=#{article.name} #{url_encode url}"
when :threads
"https://threads.net/intent/post?text=#{article.name} #{url_encode url} — @crimethincredux"
when :tumblr
[
'http://tumblr.com/widgets/share/tool?canonicalUrl=',
Expand Down
2 changes: 0 additions & 2 deletions config/locales/en/2025.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ en:
Everything conspires to suppress the voices of those who fight for a better world.
Help us bring them to a wide audience.
domains:
twitter: Twitter
facebook: Facebook
tumblr: Tumblr
email: Email

Expand Down

0 comments on commit 48dd7e8

Please sign in to comment.