summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/favorites_controller.rb12
-rw-r--r--app/helpers/favorites_helper.rb10
-rw-r--r--app/views/repositories/_overview.html.erb3
-rw-r--r--app/views/repositories/_statistics.html.erb3
-rw-r--r--app/views/repositories/show.html.erb5
5 files changed, 19 insertions, 14 deletions
diff --git a/app/controllers/favorites_controller.rb b/app/controllers/favorites_controller.rb
index cd05e34..d56ff07 100644
--- a/app/controllers/favorites_controller.rb
+++ b/app/controllers/favorites_controller.rb
@@ -27,8 +27,10 @@ class FavoritesController < ApplicationController
flash[:notice] = "You are now watching this #{@watchable.class.name.downcase}"
redirect_to repo_owner_path(@watchable, [@watchable.project, @watchable])
}
- wants.js {render :status => :created, :nothing => true,
- :location => polymorphic_path(@favorite)}
+ wants.js {
+ render :status => :created, :nothing => true,
+ :location => polymorphic_path(@favorite)
+ }
end
end
@@ -41,8 +43,10 @@ class FavoritesController < ApplicationController
flash[:notice] = "You no longer watch this #{watchable.class.name.downcase}"
redirect_to repo_owner_path(watchable, [watchable.project, watchable])
}
- wants.js {head :ok, :location => url_for(:action => "create", :watchable_id => watchable.id,
- :watchable_type => watchable.class.name, :only_path => true)}
+ wants.js {
+ head :ok, :location => url_for(:action => "create", :watchable_id => watchable.id,
+ :watchable_type => watchable.class.name, :only_path => true)
+ }
end
end
diff --git a/app/helpers/favorites_helper.rb b/app/helpers/favorites_helper.rb
index f8123a9..3c3314d 100644
--- a/app/helpers/favorites_helper.rb
+++ b/app/helpers/favorites_helper.rb
@@ -18,7 +18,7 @@
module FavoritesHelper
def favorite_link_to(watchable)
- if favorite = current_user.favorites.detect{|f| f.watchable == watchable}
+ if logged_in? && favorite = current_user.favorites.detect{|f| f.watchable == watchable}
destroy_favorite_link_to(favorite, watchable)
else
create_favorite_link_to(watchable)
@@ -27,15 +27,15 @@ module FavoritesHelper
def create_favorite_link_to(watchable)
class_name = watchable.class.name
- link_to("Start watching this #{class_name.downcase}",
+ link_to("Start watching",
favorites_path(:watchable_id => watchable.id,:watchable_type => class_name),
- :method => :post, :"data-request-method" => "post", :class => "disabled"
+ :method => :post, :"data-request-method" => "post", :class => "watch-link disabled"
)
end
def destroy_favorite_link_to(favorite, watchable)
- link_to("Stop watching this #{watchable.class.name.downcase}",
+ link_to("Stop watching",
favorite_path(favorite),
- :method => :delete, :"data-request-method" => "delete", :class => "enabled")
+ :method => :delete, :"data-request-method" => "delete", :class => "watch-link enabled")
end
end
diff --git a/app/views/repositories/_overview.html.erb b/app/views/repositories/_overview.html.erb
index f85caf3..26d3527 100644
--- a/app/views/repositories/_overview.html.erb
+++ b/app/views/repositories/_overview.html.erb
@@ -33,6 +33,9 @@
<%= link_to "Clone of #{h(repository.parent.name)}", [repository.parent.project, repository.parent] -%>
</li>
<% end -%>
+ <li class="favorite">
+ <%= favorite_link_to(repository) -%>
+ </li>
</ul>
</td>
</tr>
diff --git a/app/views/repositories/_statistics.html.erb b/app/views/repositories/_statistics.html.erb
index 91a8dba..7814de0 100644
--- a/app/views/repositories/_statistics.html.erb
+++ b/app/views/repositories/_statistics.html.erb
@@ -36,6 +36,9 @@
<%= link_to "Clone of #{h(repository.parent.name)}", repo_owner_path(repository.parent, [repository.parent.project, repository.parent]) -%>
</li>
<% end -%>
+ <li class="favorite">
+ <%= favorite_link_to(repository) -%>
+ </li>
</ul>
</td>
</tr>
diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb
index 9e4eecf..a6be1bf 100644
--- a/app/views/repositories/show.html.erb
+++ b/app/views/repositories/show.html.erb
@@ -74,11 +74,6 @@
new_project_repository_merge_request_path(@repository.project, @repository) %>
</li>
<% end -%>
- <% if logged_in? -%>
- <li class="favorite">
- <%= favorite_link_to(@repository) -%>
- </li>
- <% end -%>
</ul>
<ul class="links">