view app/helpers/application_helper.rb @ 238:a04b4830eef2 legit-client

Filter out non-own tweets included for replies
author nanaya <me@nanaya.net>
date Sat, 15 Jul 2023 01:53:05 +0900
parents 7a773720d81f
children 3ac13a9e593d
line wrap: on
line source

module ApplicationHelper
  include Twitter::TwitterText::Autolink

  def atom_id(id)
    "tag:rsstweet@nanaya.pro,2014:#{id}"
  end

  def expand_url(text, urls)
    text.gsub /https?:\/\/t\.co\/[A-Za-z0-9]+/ do |url|
      urls[url] || url
    end
  end

  def status_url(tweet)
    status_url_base tweet[:user][:username], tweet[:id]
  end

  def status_url_base(username, id)
    "https://twitter.com/#{username.presence || '_'}/status/#{id}"
  end
end