view app/helpers/application_helper.rb @ 236:498043313523 legit-client

Support multiple headers
author nanaya <me@nanaya.net>
date Sat, 15 Jul 2023 01:40:31 +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