diff options
author | re4k <re4k@re4k.info> | 2013-03-09 19:48:53 +0900 |
---|---|---|
committer | re4k <re4k@re4k.info> | 2013-03-09 19:48:53 +0900 |
commit | 11d5c2683fe0f296280fa4b717db92b1d358d704 (patch) | |
tree | eeb7b773f072a668ab6668f99162dcdc9932c132 /app/helpers/application_helper.rb | |
parent | 4ba0b50fc998c9b47b74adc31b6422f7dddcd199 (diff) | |
download | aclog-11d5c2683fe0f296280fa4b717db92b1d358d704.tar.gz |
* Fix #1
* Increase worker
Diffstat (limited to 'app/helpers/application_helper.rb')
-rw-r--r-- | app/helpers/application_helper.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 0000000..bb410cd --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,31 @@ +require "time" + +module ApplicationHelper + def format_tweet_created_at(dt) + dt.to_time.localtime("+09:00").strftime("%Y-%m-%d %H:%M:%S") + end + + def format_tweet_text(text) + text + .gsub(/<url:((?:https?|ftp).+?):(.+?)>/){link_to($2, $1, :target => "_blank")} + .gsub(/<hashtag:(.+?)>/){link_to("##{URI.decode($1)}", "https://twitter.com/search?q=%23#{$1}")} + .gsub(/<mention:(.+?)>/){link_to("@#{$1}", "/#{$1}")} + .gsub(/\r\n|\r|\n/, "<br />") + end + + def format_source_text(text) + text.gsub("&", "&") + end + + def status_url(tweet) + "/#{@user_cache[tweet.user_id].screen_name}/status/#{tweet.id}" + end + + def twitter_status_url(tweet) + "https://twitter.com/#{@user_cache[tweet.user_id].screen_name}/status/#{tweet.id}" + end + + def user_url(user_id) + "/#{@user_cache[user_id].screen_name}" + end +end |