summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Sørensen <johan@johansorensen.com>2009-12-14 14:51:08 +0100
committerJohan Sørensen <johan@johansorensen.com>2009-12-14 15:00:38 +0100
commit7a97031db4937d3f2664062152ac6dfc5254ba1d (patch)
tree8d5bcbc55473c2fc0b285bb654d29b68165d18ca
parent1a6f4e5150b4f6a85af12ab097f61cac9c2bec03 (diff)
downloadgitorious-mainline-outdated-7a97031db4937d3f2664062152ac6dfc5254ba1d.zip
gitorious-mainline-outdated-7a97031db4937d3f2664062152ac6dfc5254ba1d.tar.gz
gitorious-mainline-outdated-7a97031db4937d3f2664062152ac6dfc5254ba1d.tar.bz2
Re-order the ~user page a bit
* only show the repository list if we're viewing another user (since it's include in his own favorites) * Show projects first, since there's bound to be less of those for most users
-rw-r--r--app/controllers/users_controller.rb7
-rw-r--r--app/helpers/favorites_helper.rb10
-rw-r--r--app/helpers/users_helper.rb4
-rw-r--r--app/models/user.rb5
-rw-r--r--app/views/users/show.html.erb50
5 files changed, 38 insertions, 38 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 2655110..dcb805a 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -43,8 +43,9 @@ class UsersController < ApplicationController
end
def show
- @projects = @user.projects.find(:all, :include => [:tags, { :repositories => :project }])
- @repositories = @user.commit_repositories
+ @projects = @user.projects.find(:all,
+ :include => [:tags, { :repositories => :project }])
+ @repositories = @user.commit_repositories if current_user != @user
if current_user == @user && params[:events] != "outgoing"
@events = @user.paginated_events_in_watchlist(:page => params[:page])
else
@@ -52,9 +53,7 @@ class UsersController < ApplicationController
:page => params[:page], :order => "events.created_at desc",
:include => [:user, :project])
end
-
@messages = @user.messages_in_inbox(3) if @user == current_user
-
@favorites = @user.watched_objects
@atom_auto_discovery_url = feed_user_path(@user, :format => :atom)
diff --git a/app/helpers/favorites_helper.rb b/app/helpers/favorites_helper.rb
index e9ea228..29810cf 100644
--- a/app/helpers/favorites_helper.rb
+++ b/app/helpers/favorites_helper.rb
@@ -26,7 +26,7 @@ module FavoritesHelper
content_tag(:div, link, :class => "white-button round-10 small-button favorite")
end
-
+
def create_favorite_link_to(watchable)
class_name = watchable.class.name
link_to("Start watching",
@@ -48,7 +48,8 @@ module FavoritesHelper
def link_to_watchable(watchable)
case watchable
when Repository
- link_to(repo_title(watchable, watchable.project), repo_owner_path(watchable, [watchable.project, watchable]))
+ link_to(repo_title(watchable, watchable.project),
+ repo_owner_path(watchable, [watchable.project, watchable]))
when MergeRequest
link_to(h(truncate(watchable.summary, :length => 32)),
repo_owner_path(watchable.target_repository,
@@ -60,5 +61,8 @@ module FavoritesHelper
end
end
-
+ # is this +watchable+ included in the users @favorites?
+ def favorited?(watchable)
+ @favorites.include?(watchable)
+ end
end
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index a17f3d7..a91a51c 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -63,11 +63,11 @@ module UsersHelper
end
def favorites_heading_for(user)
- personified(user, "You are watching", "#{user.title} is watching")
+ personified(user, "You are watching", "#{user.login} is watching")
end
def no_watchings_notice_for(user)
- msg = personified(user, "You aren't", "#{user.title} isn't") +
+ msg = personified(user, "You aren't", "#{user.login} isn't") +
" watching anything yet."
if is_current_user?(user)
msg << "Click the watch icon to get events feeded into this page"
diff --git a/app/models/user.rb b/app/models/user.rb
index b96172b..553846d 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -371,7 +371,10 @@ class User < ActiveRecord::Base
end
def watched_objects
- favorites.find(:all, :include => :watchable).collect(&:watchable)
+ favorites.find(:all, {
+ :include => :watchable,
+ :order => "id desc"
+ }).collect(&:watchable)
end
def paginated_events_in_watchlist(pagination_options = {})
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index d59bb9d..e5f1336 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -144,51 +144,45 @@
</ul>
<% end if show_merge_request_count_for_user?(@user) %>
- <% pull_box(favorites_heading_for(@user)) do %>
- <ul class="with_icons">
- <% @favorites.each do |favorite| %>
- <li class="favorite <%= favorite.class.name.underscore -%>">
- <%= link_to_watchable(favorite) -%>
- </li>
- <% end %>
- <p class="hint"><%= no_watchings_notice_for(@user) if @favorites.blank? %></p>
- </ul>
- <% end %>
-
- <% pull_box(t("views.site.dashboard.projects")) do -%>
+ <% pull_box(personified(@user, "Your projects", "Projects")) do -%>
<% if is_current_user?(@user) -%>
<%= white_button_link_to(t("views.projects.create_new"), new_project_path, {
:id => "new-project-button"}) %>
<% end -%>
<ul class="with_icons">
<% @projects.each do |project| -%>
- <li class="project"><%= link_to h(project.title), project -%></li>
+ <li class="project">
+ <%= link_to h(project.title), project -%>
+ <% if favorited?(project) %>
+ <%= image_tag("silk/star.png", :title => "favorited") %>
+ <% end %>
+ </li>
<% end -%>
</ul>
<% end -%>
<% pull_box(t("views.site.dashboard.repositories")) do -%>
- <% if @repositories.blank? -%>
- <p class="hint">
- <% if is_current_user?(@user) -%>
- You currently don't have any repository clones. You can clone
- a repository you wish to contribute to, by going to a
- repository overview page and click the "Clone on Gitorious"
- link in the sidebar.
- <% else -%>
- <%=h @user.title -%> currently doesn't have any repository clones
- <% end -%>
- </p>
- <% else -%>
<ul class="with_icons">
<% @repositories.each do |repo| -%>
<li class="repository">
- <%= link_to h("#{repo.project.slug}/#{repo.name}"), repo_owner_path(repo, [repo.project, repo]) -%>
+ <%= link_to h(repo.url_path),
+ repo_owner_path(repo, [repo.project, repo]) -%>
</li>
<% end -%>
</ul>
- <% end -%>
- <% end -%>
+ <% end unless is_current_user?(@user) -%>
+
+
+ <% pull_box(favorites_heading_for(@user)) do %>
+ <ul class="with_icons">
+ <% @favorites.each do |favorite| %>
+ <li class="favorite <%= favorite.class.name.underscore -%>">
+ <%= link_to_watchable(favorite) -%>
+ </li>
+ <% end %>
+ <p class="hint"><%= no_watchings_notice_for(@user) if @favorites.blank? %></p>
+ </ul>
+ <% end %>
<% pull_box("Team memberships") do -%>
<ul>