Sha256: 55ebc8bbfaa19581de912b7ef06f88f46ae90a4d42f95379a4bc9fce50b1a136
Contents?: true
Size: 1.01 KB
Versions: 9
Compression:
Stored size: 1.01 KB
Contents
require 'text_filter_plugin' class PublifyApp class Textfilter class Twitterfilter < TextFilterPlugin::PostProcess plugin_display_name 'HTML Filter' plugin_description 'Strip HTML tags' def self.filtertext(text) # First, autolink text = text.to_s URI.extract(text, %w(http https mailto gopher)) do |item| text = text.gsub(item, "<a href='#{item}'>#{item}</a>") end # hashtags text.split.grep(/^#\w+/) do |item| # strip_html because Ruby considers "#prouddad</p>" as a word uri = URI.escape("https://twitter.com/search?q=#{item.strip_html}&src=tren&mode=realtime") text = text.gsub(item, "<a href='#{uri}'>#{item.strip_html}</a>") end # @mention text.to_s.split.grep(/@\w+/) do |item| uri = URI.escape("https://twitter.com/#{item.strip_html.delete('@')}") text = text.gsub(item, "<a href='#{uri}'>#{item.strip_html}</a>") end text end end end end
Version data entries
9 entries across 9 versions & 1 rubygems