diff options
author | Rhenium <rhenium@rhe.jp> | 2014-01-21 06:43:02 +0900 |
---|---|---|
committer | Rhenium <rhenium@rhe.jp> | 2014-01-21 06:43:02 +0900 |
commit | 174f0059afe8914554c454b6c04c80cf278a9d1e (patch) | |
tree | 60fe0664cd093d0b47385b70677574197304ece4 /app/helpers/application_helper.rb | |
parent | c2479259ae06d19999f08dd6e5f3a679725d0c27 (diff) | |
download | aclog-174f0059afe8914554c454b6c04c80cf278a9d1e.tar.gz |
use Twitter::Autolink to link usernames / urls / ...
Diffstat (limited to 'app/helpers/application_helper.rb')
-rw-r--r-- | app/helpers/application_helper.rb | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5700099..4c3e5a4 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,31 +1,10 @@ module ApplicationHelper + include Twitter::Autolink + def format_time(dt) dt.to_time.localtime("+09:00").strftime("%Y-%m-%d %H:%M:%S") end - def format_tweet_text(text) - ret = text.gsub(/<([a-z]+?)(?<!\\):(.+?)(?:(?<!\\):(.+?))?>/) do - case $1 - when "mention" - screen_name = CGI.unescape($2) - link_to("@#{screen_name}", "/#{screen_name}") - when "url" - n = [$3, $2.gsub(/(https?)%3A/, "\\1:")].map {|m| m.gsub("\\:", ":") } - link_to(*n) - when "hashtag" - hashtag = CGI.unescape($2) - link_to("##{hashtag}", "https://twitter.com/search?q=#{CGI.escape("##{hashtag}")}") - when "symbol" - symbol = CGI.unescape($2) - link_to("$#{symbol}", "https://twitter.com/search?q=#{CGI.escape("$#{symbol}")}") - else - $& - end - end - return ret - end - alias format_source_text format_tweet_text - def title(*args) content_for :title do (args.compact).join(" - ") |