aboutsummaryrefslogtreecommitdiffstats
path: root/app/views/shared
diff options
context:
space:
mode:
authorre4k <re4k@re4k.info>2013-03-28 02:11:40 +0900
committerre4k <re4k@re4k.info>2013-03-28 02:11:40 +0900
commit295db76b7643868456eafb98cf760a5e383b41ed (patch)
tree054845af698810440ce1b96324618fb05ee67cb2 /app/views/shared
parentb4972590475eb595bc88f6ee47125fe8ca6e1fb2 (diff)
downloadaclog-295db76b7643868456eafb98cf760a5e383b41ed.tar.gz
Refactor
Diffstat (limited to 'app/views/shared')
-rw-r--r--app/views/shared/_sidebar_i.html.haml12
-rw-r--r--app/views/shared/_sidebar_main.html.haml1
-rw-r--r--app/views/shared/_sidebar_users.html.haml38
-rw-r--r--app/views/shared/_tweet.html.haml9
-rw-r--r--app/views/shared/_tweet.json.jbuilder19
-rw-r--r--app/views/shared/_user.json.jbuilder9
-rw-r--r--app/views/shared/tweets.html.haml4
-rw-r--r--app/views/shared/tweets.json.jbuilder4
-rw-r--r--app/views/shared/users.html.haml13
-rw-r--r--app/views/shared/users.json.jbuilder9
10 files changed, 99 insertions, 19 deletions
diff --git a/app/views/shared/_sidebar_i.html.haml b/app/views/shared/_sidebar_i.html.haml
new file mode 100644
index 0000000..098b35c
--- /dev/null
+++ b/app/views/shared/_sidebar_i.html.haml
@@ -0,0 +1,12 @@
+%ul.nav.nav-tabs.nav-stacked
+ %li
+ = link_to "about", :controller => "main", :action => "about"
+ %li
+ = link_to "api", :controller => "main", :action => "api"
+%ul.nav.nav-tabs.nav-stacked
+ %li
+ = link_to "best", :controller => "i", :action => "best"
+ %li
+ = link_to "recent", :controller => "i", :action => "recent"
+ %li
+ = link_to "timeline", :controller => "i", :action => "timeline"
diff --git a/app/views/shared/_sidebar_main.html.haml b/app/views/shared/_sidebar_main.html.haml
new file mode 100644
index 0000000..dcc2630
--- /dev/null
+++ b/app/views/shared/_sidebar_main.html.haml
@@ -0,0 +1 @@
+= render "shared/sidebar_i"
diff --git a/app/views/shared/_sidebar_users.html.haml b/app/views/shared/_sidebar_users.html.haml
new file mode 100644
index 0000000..bfd4b4d
--- /dev/null
+++ b/app/views/shared/_sidebar_users.html.haml
@@ -0,0 +1,38 @@
+.sidebar
+ .avatar= link_to (image_tag @user.profile_image_url_original, :alt => @user.screen_name, :width => 64, :height => 64, :class => "icon img-rounded"), :controller => "users", :action => "best", :screen_name => @user.screen_name
+ .screen_name= link_to "@#{@user.screen_name}", :controller => "users", :action => "best", :screen_name => @user.screen_name
+ - if @user.registered?
+ %table.table.table-condensed.records
+ %tr
+ %td favorited
+ %td.data= @user.stats[:favorited_count]
+ %tr
+ %td retweeted
+ %td.data= @user.stats[:retweeted_count]
+ %tr
+ %td avg. fav
+ %td.data= ((@user.stats[:favorited_count] + 0.0) / @user.stats[:tweets_count]).round(2)
+ - else
+ .alert.alert-info
+ = "@#{@user.screen_name} has never signed in to aclog"
+ .user_nav
+ %ul.nav.nav-tabs.nav-stacked
+ - if @user.registered?
+ %li
+ = link_to "info", :controller => "users", :action => "info", :screen_name => @user.screen_name
+ %li
+ = link_to "best", :controller => "users", :action => "best", :screen_name => @user.screen_name
+ %li
+ = link_to "recent", :controller => "users", :action => "recent", :screen_name => @user.screen_name
+ %li
+ = link_to "timeline", :controller => "users", :action => "timeline", :screen_name => @user.screen_name
+ %li
+ = link_to "discovered", :controller => "users", :action => "discovered", :screen_name => @user.screen_name
+ %li
+ = link_to "favorited by", :controller => "users", :action => "favorited_by", :screen_name => @user.screen_name
+ %li
+ = link_to "retweted by", :controller => "users", :action => "retweeted_by", :screen_name => @user.screen_name
+ %li
+ = link_to "given favorites", :controller => "users", :action => "given_favorites_to", :screen_name => @user.screen_name
+ %li
+ = link_to "given retweets", :controller => "users", :action => "given_retweets_to", :screen_name => @user.screen_name
diff --git a/app/views/shared/_tweet.html.haml b/app/views/shared/_tweet.html.haml
index d98fdbb..3f76f1a 100644
--- a/app/views/shared/_tweet.html.haml
+++ b/app/views/shared/_tweet.html.haml
@@ -26,11 +26,10 @@
%span.type= type
%dd
%ul.inline
- - actions.take(params[:controller] == "users" && params[:action] == "show" ? actions.count : 20).each do |a| |
- - m = a.user || User.new
+ - actions.take(params[:action] == "show" ? actions.count : 20).each do |a|
+ - m = a.user
%li
- - if m.screen_name
+ - if m
= link_to image_tag(m.profile_image_url, :alt => m.screen_name, :title => m.name), :controller => "users", :action => "best", :screen_name => m.screen_name
- else
- = image_tag(m.profile_image_url, :alt => m.name, :title => m.name)
-
+ = image_tag asset_path("missing_profile_image.png"), :alt => "Missing User: #{a.user_id}", :title => "Missing User: #{a.user_id}"
diff --git a/app/views/shared/_tweet.json.jbuilder b/app/views/shared/_tweet.json.jbuilder
index 467249a..c048dee 100644
--- a/app/views/shared/_tweet.json.jbuilder
+++ b/app/views/shared/_tweet.json.jbuilder
@@ -1,29 +1,26 @@
json.(item, :id, :text, :source, :tweeted_at, :favorites_count, :retweets_count)
json.user do |json|
- unless @include_user
- json.id item.user_id
- else
+ 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|
- unless @include_user
- json.id favorite.user_id
- else
- json.partial! "shared/user", :user => favorite.user || User.new
+ 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|
- unless @include_user
- json.id retweet.user_id
- else
- json.partial! "shared/user", :user => retweet.user || User.new
+ json.id retweet.user_id
+ if @include_user
+ json.partial! "shared/user", :user => retweet.user
end
end
end
diff --git a/app/views/shared/_user.json.jbuilder b/app/views/shared/_user.json.jbuilder
index 1bac0ad..fe64d8d 100644
--- a/app/views/shared/_user.json.jbuilder
+++ b/app/views/shared/_user.json.jbuilder
@@ -1,4 +1,7 @@
-json.(user, :id, :screen_name, :name, :profile_image_url)
-if @include_user_stats && user.registered?
- json.stats user.stats
+if user
+ json.(user, :id, :screen_name, :name, :profile_image_url, :protected)
+ if @include_user_stats && user.registered?
+ json.stats user.stats
+ end
end
+
diff --git a/app/views/shared/tweets.html.haml b/app/views/shared/tweets.html.haml
new file mode 100644
index 0000000..f6a3f12
--- /dev/null
+++ b/app/views/shared/tweets.html.haml
@@ -0,0 +1,4 @@
+.items
+ = render :partial => "shared/tweet", :collection => @items, :as => :item
+- if @items
+ = paginate @items
diff --git a/app/views/shared/tweets.json.jbuilder b/app/views/shared/tweets.json.jbuilder
new file mode 100644
index 0000000..d2637d3
--- /dev/null
+++ b/app/views/shared/tweets.json.jbuilder
@@ -0,0 +1,4 @@
+json.array! @items do |json, item|
+ json.partial! "shared/tweet", :item => item
+end
+
diff --git a/app/views/shared/users.html.haml b/app/views/shared/users.html.haml
new file mode 100644
index 0000000..6393630
--- /dev/null
+++ b/app/views/shared/users.html.haml
@@ -0,0 +1,13 @@
+.users
+ %ul.inline
+ - @usermap.take(50).each do |user_id, count|
+ - user = User.cached(user_id)
+ %li
+ - if user
+ %a{:href => url_for(params.merge(:screen_name_b => user.screen_name))}
+ .avatar= image_tag user.profile_image_url, :alt => user.screen_name, :title => user.name
+ - else
+ .avatar= image_tag asset_path("missing_profile_image.png"), :alt => "Missing User: #{user_id}", :title => "Missing User: #{user_id}"
+ .count= count
+ .type= @event_type
+
diff --git a/app/views/shared/users.json.jbuilder b/app/views/shared/users.json.jbuilder
new file mode 100644
index 0000000..d58c584
--- /dev/null
+++ b/app/views/shared/users.json.jbuilder
@@ -0,0 +1,9 @@
+json.array! @usermap do |json, u|
+ json.count u[1]
+ json.user do |json|
+ json.id u[0]
+ if @include_user
+ json.partial! "shared/user", :user => User.cached(u[0])
+ end
+ end
+end