diff options
author | re4k <re4k@re4k.info> | 2013-04-17 02:00:26 +0900 |
---|---|---|
committer | re4k <re4k@re4k.info> | 2013-04-17 02:00:26 +0900 |
commit | 88026553952be01d4b5e46d59c66444d93ad1410 (patch) | |
tree | 83dac9c3ad95969de9d7e5dd2ee307241dc64484 /app/views | |
parent | 22ca2944772896c1d7b219a159891ed11fb4ef1b (diff) | |
download | aclog-88026553952be01d4b5e46d59c66444d93ad1410.tar.gz |
refactor, add limit parameter
Diffstat (limited to 'app/views')
-rw-r--r-- | app/views/main/index.html.haml | 8 | ||||
-rw-r--r-- | app/views/shared/_tweet.html.haml | 4 | ||||
-rw-r--r-- | app/views/shared/_tweet.json.jbuilder | 30 | ||||
-rw-r--r-- | app/views/shared/tweets.html.haml | 13 | ||||
-rw-r--r-- | app/views/users/show.json.jbuilder | 2 |
5 files changed, 29 insertions, 28 deletions
diff --git a/app/views/main/index.html.haml b/app/views/main/index.html.haml index 02d5b2b..7e1bbf2 100644 --- a/app/views/main/index.html.haml +++ b/app/views/main/index.html.haml @@ -4,8 +4,6 @@ %p UserStreams で登録ユーザーのふぁぼり・ふぁぼられ・RTを集めて表示するサービスです。あんふぁぼも反映されます。 %p - Favstar を参考に開発しています。現時点でトロフィー以外の機能はすべて使えるはずです。 -%p API も提供する予定です。about → api を見てください(まだ開発中であり、変更がある可能性もあります) .alert (04/04) 諸事情でアプリケーションを作り直しました。再認証(logout → login)すると新しいトークンで上書きされます。 @@ -13,14 +11,16 @@ = link_to "アプリ連携", "https://twitter.com/settings/applications" から不要な "AcLog" と "Aclog2" は解除しても大丈夫です。 %h4 - 今後の予定(2013/04/04) + 今後の予定(2013/04/16) %ul + %li ふぁぼ爆撃対策: TLふぁぼり(エタフォ)・ユーザーTLふぁぼり(fav2you)対策 %li 通知を細かく設定できるように %li パクリツイート対策 %li ふぁぼったー・Favstar からのデータの取り込み - %li ふぁぼ爆撃対策 %li トロフィー機能をいらないよね… %p + ふぁぼ爆撃(無差別なふぁぼなど)と判断された場合は数時間ふぁぼりの記録が停止されます。基準は相当高く設定しているので誤判定はまずないとは思いますがもしなにかあれば連絡ください。 +%p = link_to "ツイート", "https://twitter.com/share", :class => "twitter-share-button", :"data-text" => "aclog", :"data-count" => "none", :"data-url" => "http://aclog.koba789.com/" %hr %h5 diff --git a/app/views/shared/_tweet.html.haml b/app/views/shared/_tweet.html.haml index 3dd290b..c8c3a09 100644 --- a/app/views/shared/_tweet.html.haml +++ b/app/views/shared/_tweet.html.haml @@ -33,12 +33,12 @@ %dt %span.count= actions.count %span.type= type - - if actions.count > show_count(actions.count) + - if user_limit && params[:action] == "show" %span.full = link_to "show full", params.merge(:full => true) %dd %ul.inline - - actions.take(show_count(actions.count)).each do |m| + - actions.take(user_limit || actions.count).each do |m| %li = link_to_user_page m.screen_name do = image_tag m.profile_image_url, :alt => m.screen_name, :title => m.name diff --git a/app/views/shared/_tweet.json.jbuilder b/app/views/shared/_tweet.json.jbuilder index c048dee..15dae1b 100644 --- a/app/views/shared/_tweet.json.jbuilder +++ b/app/views/shared/_tweet.json.jbuilder @@ -1,26 +1,26 @@ json.(item, :id, :text, :source, :tweeted_at, :favorites_count, :retweets_count) -json.user do |json| +json.user do json.id item.user_id if @include_user json.partial! "shared/user", :user => item.user end end -json.favorites item.favorites.order("id") do |json, favorite| - json.user do |json| - json.id favorite.user_id - if @include_user - json.partial! "shared/user", :user => favorite.user - end - end -end -json.retweets item.retweets.order("id") do |json, retweet| - json.id retweet.id - json.user do |json| - json.id retweet.user_id - if @include_user - json.partial! "shared/user", :user => retweet.user +render_actions = -> name, data, render_id do + n = 0 + json.__send__(name, data) do |action| + json.id action.id if render_id + json.user do + json.id action.user_id + if @include_user && (!user_limit || n < user_limit) + json.partial! "shared/user", :user => action.user + end end + n += 1 end end + +render_actions.call(:favorites, item.favorites.includes(:user), false) +render_actions.call(:retweets, item.retweets.includes(:user), true) + diff --git a/app/views/shared/tweets.html.haml b/app/views/shared/tweets.html.haml index 0ab1a69..55e8e42 100644 --- a/app/views/shared/tweets.html.haml +++ b/app/views/shared/tweets.html.haml @@ -1,12 +1,11 @@ -- if @show_search +- if params[:action] == "search" = render :partial => "shared/search" .items = render :partial => "shared/tweet", :collection => @items, :as => :item .loading = image_tag "loading.gif", :alt => "loading...", :title => nil -- if @items - - if @page_param - = paginate(@items) - - elsif @items.last - .pagination - = link_to raw("Next ›"), params.merge(:max_id => @items.last.id - 1), :rel => :next +- if /offset/i =~ @items.to_sql + = paginate(@items) +- elsif @items.last + .pagination + = link_to raw("Next ›"), params.merge(:max_id => @items.last.id - 1), :rel => :next diff --git a/app/views/users/show.json.jbuilder b/app/views/users/show.json.jbuilder new file mode 100644 index 0000000..bca1b00 --- /dev/null +++ b/app/views/users/show.json.jbuilder @@ -0,0 +1,2 @@ +json.partial! "shared/tweet", :item => @item + |