view app/helpers/application_helper.rb @ 234:7a773720d81f legit-client

Totally legit client
author nanaya <me@nanaya.net>
date Fri, 14 Jul 2023 22:42:20 +0900
parents 12287b32fbda
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