Avoid displaying feed items in user page where the watchable is nil
[gitorious:mainline.git] / app / views / users / show.html.erb
1 <div class="with_divider">
2         <div id="left">
3                 <div class="user-profile not-dash">
4                         <%= link_to(avatar(@user, { :size => 64 }), @user, {:class => "avatar"}) %>
5                         <div class="profile-data">
6                                 <h1>
7                                         ~<%= link_to h(@user.login), @user -%>
8                                 </h1>
9                                 <ul class="details">
10                                         <% unless @user.fullname.blank? %>
11                                         <li>
12                                                 <%= h(@user.fullname) -%>
13                                         </li><% end %><% if @user.public_email? -%>
14                                         <li class="email">
15                                                 <%= mail_to(@user.email, mangled_mail(@user.email), :encode => "javascript") -%>
16                                         </li><% end -%><% if @user.url %>
17                                         <li>
18                                                 <a rel="me" href="<%=h @user.url -%>"><%=h @user.url -%></a>
19                                         </li><% end -%>
20                                         <li>
21                                                 <%= t("views.users.member_for") %> <%= time_ago_in_words(@user.created_at) %>
22                                         </li>
23                                 </ul>
24                         </div>
25                         
26                   <ul class="buttons">
27         <% if is_current_user?(@user) -%>
28           <li class="hint"><strong>This is your public profile! </strong><br />(<%= link_to "Go to your dashboard", root_path -%>)</li>
29         <% end -%>
30         <% if !is_current_user?(@user) -%>
31         <li class="new_email">
32           <%= link_button_link_to(t("views.users.send_user_msg", :username=>h(@user.login)),
33                 new_message_path(:to => @user.login), :class => "new_email") -%>
34         </li>
35         <% end -%>
36       </ul>
37       <div class="clear"></div>
38     </div>
39
40                 <div class="content-container w-510">
41                         <h2 class="activities">
42                                 <% if showing_newsfeed? %> Your news feed <% else %> <%= t("views.site.dashboard.activities") -%> <% end %> <%= feed_icon @atom_auto_discovery_url -%> <% if is_current_user?(@user) -%> <small>(<%= newsfeed_or_user_events_link -%>)</small> <% end -%>
43                         </h2><% if @events.empty? -%>
44                         <p class="hint">
45                                 <%= personified(@user, "You have", "#{@user.title} has") -%> no news.
46                         </p><% else -%>
47                         <div id="user_events" class="w-510">
48                                 <%= render :partial => "events/events", :locals => { :events => @events, :container_css_class => "w-510" } -%>
49                         </div><% end -%>
50                 </div>
51         </div>
52         <div id="right" class="w-390">
53                 <% pull_box(t("views.site.dashboard.projects"), :class => "your-projects pull-box-390") do -%>
54                 <ul class="with_icons">
55                         <% @projects.each do |project| -%>
56                           <li class="project">
57                                   <%= link_to h(project.title), project -%>
58           <% if favorited?(project) %>
59             <%= image_tag("silk/star.png", :title => "favorited") %>
60           <% end %>
61                           </li>
62       <% end -%>
63                 </ul><% if is_current_user?(@user) -%>
64                 <div class="pull-box-links">
65                         <%= link_button_link_to(t("views.projects.create_new"), new_project_path, {
66                                                 :id => "new-project-button"}) %>
67                                 </div><% end -%><% end -%><% pull_box(t("views.site.dashboard.repositories"), :class => "your-repositories pull-box-390") do -%><% if @repositories.blank? -%><% if is_current_user?(@user) -%>You currently do not have any repository clones. You can clone a repository you wish to contribute to by going to a repository overview page and clicking the "Clone repository" button in the repository information box.<% else -%>
68                 <p class="hint">
69                         <%=h @user.title -%> currently does not have any repository clones.
70                 </p><% end -%><% else -%>
71                 <ul class="with_icons">
72                         <% @repositories.each do |repo| -%>
73                         <li class="repository">
74                                 <%= link_to h(repo.url_path),
75                                                                   repo_owner_path(repo, [repo.project, repo]) -%>
76                         </li><% end -%>
77                 </ul><% end -%><% end %><% pull_box("#{@user.title} is watching", :class => "your-favorites favorite pull-box-390") do %>
78                 <div class="filters">
79                         <ul>
80                                 <li>
81                                         <strong>Sort by:</strong>
82                                 </li><% if is_current_user?(@user) -%>
83                                 <li>
84                                         <a class="foreign" href="#not-mine">Not yours</a>
85                                 </li>
86                                 <li>
87                                         <a class="mine" href="#mine">Yours</a>
88                                 </li><% end -%>
89                                 <li>
90                                         <a href="#merge-requests" class="merge-requests">Merge requests</a>
91                                 </li>
92                                 <li>
93                                         <a href="#repos" class="repositories">Repositories</a>
94                                 </li>
95                                 <li>
96                                         <a href="#all" class="all">All</a>
97                                 </li>
98                         </ul>
99                 </div>
100                 <ul class="with_icons">
101                         <% @favorites.reject { |favorite| favorite.watchable.nil? }.each do |favorite| %>
102                           <li class="<%= css_classes_for(favorite.watchable) -%>">
103                                   <%= link_to_watchable(favorite.watchable) -%>
104                           </li>
105       <% end %>
106       <% if @favorites.blank? -%>
107                           <li style="list-style: none">
108                                   <p class="hint">
109                                           <%= no_watchings_notice_for(@user) -%>
110                                   </p>
111                         </li>
112       <% end -%>
113                 </ul><% end %><% pull_box("Team memberships", :class => "teams pull-box-390") do -%>
114                 <ul>
115                         <% @user.groups.each do |group| -%>
116                         <li style="clear:left">
117                                 <span style="float:left; padding: 2px 10px 2px 2px"><%= image_tag(group.avatar.url(:thumb), :alt => "Avatar", :width => "16") %></span> <%= link_to h(group.name), group_path(group) -%>
118                         </li><% end -%>
119                 </ul><% end unless @user.groups.blank? -%>
120         </div>
121         <div class="clear"></div>
122 </div>