This repository has been archived by the owner on Mar 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
96 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<% if !@followed_topics.blank? %> | ||
<div class="box gray"> | ||
<h2>关注 <a href="<%= following_topics_user_path(@user.slug) %>"><%= @user.followed_topic_ids.size %>个话题</a></h2> | ||
<ul class="followed-item topic-listing"> | ||
<% for topic in @followed_topics %> | ||
<li> | ||
<div class="item"> | ||
<a href="<%= topic_path(topic.name) %>"><%= topic.name %></a> | ||
</div> | ||
<% if @current_user %> | ||
<div class="action"> | ||
<% if @current_user.topic_followed?(topic) %> | ||
<a class="flat_button small" href="#" onclick="return Topics.unfollow(this, '<%= topic.name %>','small');">取消关注</a> | ||
<% else %> | ||
<a class="green_button small" href="#" onclick="return Topics.follow(this, '<%= topic.name %>','small');">关注</a> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<% if [email protected]? %> | ||
<div class="box standard gray"> | ||
<h2>最近关注<%= user_sex_title(@user) %>的人</h2> | ||
<div class="inner"> | ||
<div class="followers"> | ||
<% for follower in @followers %> | ||
<a href="/users/<%= follower.slug %>" title="<%= follower.name %>"> | ||
<%= user_avatar_tag(follower, :small) %> | ||
</a> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<% if [email protected]? %> | ||
<div class="box standard gray"> | ||
<h2><%= user_sex_title(@user) %>最近关注的人</h2> | ||
<div class="inner"> | ||
<div class="followers"> | ||
<% for follower in @following %> | ||
<a href="/users/<%= follower.slug %>" title="<%= follower.name %>"> | ||
<%= user_avatar_tag(follower, :small) %> | ||
</a> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
class UserCell < Cell::Rails | ||
helper :users | ||
cache :followers, :followers_key, :expires_in => 3.days | ||
cache :following, :following_key, :expires_in => 3.days | ||
|
||
def followed_topics(opts = {}) | ||
@user = opts[:user] || nil | ||
@current_user = opts[:current_user] || nil | ||
if @user | ||
@followed_topics = @user.followed_topics.desc("$natural").limit(7) | ||
end | ||
render | ||
end | ||
|
||
def followers(opts = {}) | ||
@user = opts[:user] || nil | ||
if @user | ||
@followers = @user.followers.desc("$natural").limit(42) | ||
end | ||
render | ||
end | ||
|
||
def following(opts = {}) | ||
@user = opts[:user] || nil | ||
if @user | ||
@following = @user.following.desc("$natural").limit(42) | ||
end | ||
render | ||
end | ||
|
||
private | ||
def followers_key(opts = {}) | ||
return "followers/nil" if opts[:user].blank? | ||
"followers/#{opts[:user].id}/#{opts[:user].follower_ids.to_s.md5}" | ||
end | ||
|
||
def following_key(opts = {}) | ||
return "following/nil" if opts[:user].blank? | ||
"following/#{opts[:user].id}/#{opts[:user].following_ids.to_s.md5}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters