diff options
author | rhenium <re4k@re4k.info> | 2013-06-02 03:07:06 +0900 |
---|---|---|
committer | rhenium <re4k@re4k.info> | 2013-06-02 03:07:06 +0900 |
commit | 7c6ac47334ee3c4de6d15308a7efab8764e2f6e9 (patch) | |
tree | 0a5e16c10501d4889fa6409f8b3687dc729d16a8 | |
parent | fb2a7041165e4cc0a6c488b3b78390ca98357169 (diff) | |
download | aclog-7c6ac47334ee3c4de6d15308a7efab8764e2f6e9.tar.gz |
move @user_limit to helper
-rw-r--r-- | app/controllers/tweets_controller.rb | 23 | ||||
-rw-r--r-- | app/helpers/tweets_helper.rb | 22 | ||||
-rw-r--r-- | app/views/tweets/_tweet.html.haml | 2 | ||||
-rw-r--r-- | app/views/tweets/_tweet.json.jbuilder | 4 |
4 files changed, 24 insertions, 27 deletions
diff --git a/app/controllers/tweets_controller.rb b/app/controllers/tweets_controller.rb index 8879289..2930473 100644 --- a/app/controllers/tweets_controller.rb +++ b/app/controllers/tweets_controller.rb @@ -1,8 +1,5 @@ # -*- encoding: utf-8 -*- class TweetsController < ApplicationController - before_filter :set_user_limit - helper_method :account_private? - def show tweet_required @caption = "#{@user.screen_name}'s Tweet" @@ -102,26 +99,6 @@ class TweetsController < ApplicationController @user = _require_user(@tweet.user_id, nil) end - def set_user_limit - if params[:action] == "show" - if params[:full] == "true" - @user_limit = nil - else - @user_limit = Settings.tweets.users.count_lot - end - else - @user_limit = Settings.tweets.users.count_default - end - - if request.format == :json - if params[:limit] - @user_limit = params[:limit].to_i - else - @user_limit = nil - end - end - end - def check_public! authorize_to_show_best!(@user) end diff --git a/app/helpers/tweets_helper.rb b/app/helpers/tweets_helper.rb index 0d9f8b7..cfd4771 100644 --- a/app/helpers/tweets_helper.rb +++ b/app/helpers/tweets_helper.rb @@ -1,6 +1,26 @@ module TweetsHelper + def user_limit + if request.format == :json + if params[:limit] + params[:limit].to_i + else + nil + end + else + if params[:action] == "show" + if params[:full] == "true" + nil + else + Settings.tweets.users.count_lot + end + else + Settings.tweets.users.count_default + end + end + end + def user_truncated?(tweet) - tr = @user_limit || Float::INFINITY + tr = user_limit || Float::INFINITY tr < tweet.favorites_count || tr < tweet.retweets_count end end diff --git a/app/views/tweets/_tweet.html.haml b/app/views/tweets/_tweet.html.haml index 4dceeaa..998f870 100644 --- a/app/views/tweets/_tweet.html.haml +++ b/app/views/tweets/_tweet.html.haml @@ -39,7 +39,7 @@ %span.type= title %dd %ul.inline - - users.limit(@user_limit).each do |m| + - users.limit(user_limit).each do |m| %li = link_to user_path(m.screen_name) do = image_tag m.profile_image_url, alt: m.screen_name, title: m.name diff --git a/app/views/tweets/_tweet.json.jbuilder b/app/views/tweets/_tweet.json.jbuilder index e7f2d88..5a56442 100644 --- a/app/views/tweets/_tweet.json.jbuilder +++ b/app/views/tweets/_tweet.json.jbuilder @@ -2,6 +2,6 @@ json.(tweet, :id, :favorites_count, :retweets_count) json.user_id tweet.user_id -json.favoriters tweet.favorites.limit(@user_limit).pluck(:user_id) -json.retweeters tweet.retweets.limit(@user_limit).pluck(:user_id) +json.favoriters tweet.favorites.limit(ser_limit).pluck(:user_id) +json.retweeters tweet.retweets.limit(user_limit).pluck(:user_id) |