Commit 4dade837eb3d5988b3a9f3eb0192069c43643564
- Date: Tue Apr 29 21:05:06 +0000 2008
- Committer: Johan Sørensen (johan@johansorensen.com)
- Author: Johan Sørensen (johan@johansorensen.com)
- Commit SHA1: 4dade837eb3d5988b3a9f3eb0192069c43643564
- Tree SHA1: 8ed9c76c43ff4cf41d4363f0f76d014e6a07ccc6
Made the user feed a member action, since usernames can contain dots
Commit diff
| |   |
| 14 | 14 | |
| 15 | 15 | @commits_last_week = @user.events.count(:all, |
| 16 | 16 | :conditions => ["created_at > ? AND action = ?", 7.days.ago, Action::COMMIT]) |
| 17 | | @atom_auto_discovery_url = formatted_user_path(@user, :atom) |
| 17 | @atom_auto_discovery_url = formatted_feed_user_path(@user, :atom) |
| 18 | 18 | |
| 19 | 19 | respond_to do |format| |
| 20 | 20 | format.html { } |
| 21 | format.atom { redirect_to formatted_feed_user_path(@user, :atom) } |
| 22 | end |
| 23 | end |
| 24 | |
| 25 | def feed |
| 26 | @user = User.find_by_login!(params[:id]) |
| 27 | @events = @user.events.find(:all, :order => "events.created_at desc", |
| 28 | :include => [:user, :project], :limit => 30) |
| 29 | respond_to do |format| |
| 30 | format.html { redirect_to user_path(@user) } |
| 21 | 31 | format.atom { } |
| 22 | 32 | end |
| 23 | 33 | end |
| toggle raw diff |
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -14,10 +14,20 @@ class UsersController < ApplicationController
@commits_last_week = @user.events.count(:all,
:conditions => ["created_at > ? AND action = ?", 7.days.ago, Action::COMMIT])
- @atom_auto_discovery_url = formatted_user_path(@user, :atom)
+ @atom_auto_discovery_url = formatted_feed_user_path(@user, :atom)
respond_to do |format|
format.html { }
+ format.atom { redirect_to formatted_feed_user_path(@user, :atom) }
+ end
+ end
+
+ def feed
+ @user = User.find_by_login!(params[:id])
+ @events = @user.events.find(:all, :order => "events.created_at desc",
+ :include => [:user, :project], :limit => 30)
+ respond_to do |format|
+ format.html { redirect_to user_path(@user) }
format.atom { }
end
end |
| |   |
| 1 | atom_feed do |feed| |
| 2 | feed.title("Gitorious: #{@user.login}'s activity") |
| 3 | feed.updated((@events.blank? ? Time.now : @events.first.created_at)) |
| 4 | |
| 5 | @events.each do |event| |
| 6 | action, body, category = action_and_body_for_event(event) |
| 7 | item_url = "http://#{GitoriousConfig['gitorious_host']}" + user_path(@user) |
| 8 | feed.entry(event, :url => item_url) do |entry| |
| 9 | entry.title("#{h(event.user.login)} #{strip_tags(action)}") |
| 10 | entry.content(<<-EOS, :type => 'html') |
| 11 | <p>#{link_to event.user.login, user_path(event.user)} #{action}</p> |
| 12 | <p>#{body}<p> |
| 13 | EOS |
| 14 | entry.author do |author| |
| 15 | author.name(event.user.login) |
| 16 | end |
| 17 | end |
| 18 | end |
| 19 | end |
| toggle raw diff |
--- /dev/null
+++ b/app/views/users/feed.atom.builder
@@ -0,0 +1,19 @@
+atom_feed do |feed|
+ feed.title("Gitorious: #{@user.login}'s activity")
+ feed.updated((@events.blank? ? Time.now : @events.first.created_at))
+
+ @events.each do |event|
+ action, body, category = action_and_body_for_event(event)
+ item_url = "http://#{GitoriousConfig['gitorious_host']}" + user_path(@user)
+ feed.entry(event, :url => item_url) do |entry|
+ entry.title("#{h(event.user.login)} #{strip_tags(action)}")
+ entry.content(<<-EOS, :type => 'html')
+<p>#{link_to event.user.login, user_path(event.user)} #{action}</p>
+<p>#{body}<p>
+EOS
+ entry.author do |author|
+ author.name(event.user.login)
+ end
+ end
+ end
+end
\ No newline at end of file |
| |   |
| 0 | | atom_feed do |feed| |
| 1 | | feed.title("Gitorious: #{@user.login}'s activity") |
| 2 | | feed.updated((@events.blank? ? Time.now : @events.first.created_at)) |
| 3 | | |
| 4 | | @events.each do |event| |
| 5 | | action, body, category = action_and_body_for_event(event) |
| 6 | | item_url = "http://#{GitoriousConfig['gitorious_host']}" + user_path(@user) |
| 7 | | feed.entry(event, :url => item_url) do |entry| |
| 8 | | entry.title("#{h(event.user.login)} #{strip_tags(action)}") |
| 9 | | entry.content(<<-EOS, :type => 'html') |
| 10 | | <p>#{link_to event.user.login, user_path(event.user)} #{action}</p> |
| 11 | | <p>#{body}<p> |
| 12 | | EOS |
| 13 | | entry.author do |author| |
| 14 | | author.name(event.user.login) |
| 15 | | end |
| 16 | | end |
| 17 | | end |
| 18 | | end |
| toggle raw diff |
--- a/app/views/users/show.atom.builder
+++ /dev/null
@@ -1,19 +0,0 @@
-atom_feed do |feed|
- feed.title("Gitorious: #{@user.login}'s activity")
- feed.updated((@events.blank? ? Time.now : @events.first.created_at))
-
- @events.each do |event|
- action, body, category = action_and_body_for_event(event)
- item_url = "http://#{GitoriousConfig['gitorious_host']}" + user_path(@user)
- feed.entry(event, :url => item_url) do |entry|
- entry.title("#{h(event.user.login)} #{strip_tags(action)}")
- entry.content(<<-EOS, :type => 'html')
-<p>#{link_to event.user.login, user_path(event.user)} #{action}</p>
-<p>#{body}<p>
-EOS
- entry.author do |author|
- author.name(event.user.login)
- end
- end
- end
-end
\ No newline at end of file |
| |   |
| 24 | 24 | account.resources :keys |
| 25 | 25 | end |
| 26 | 26 | map.connect "users/activate/:activation_code", :controller => "users", :action => "activate" |
| 27 | | map.resources :users, :requirements => {:id => /[^\/\\\.\s]+/ }, :collection => { # FIXME: fails if login contains . |
| 27 | map.resources :users, :requirements => {:id => /.+/ }, :collection => { |
| 28 | 28 | :forgot_password => :get, |
| 29 | 29 | :reset_password => :post, |
| 30 | | } |
| 30 | }, :member => { :feed => :get } |
| 31 | 31 | map.resources :events |
| 32 | 32 | map.resource :sessions |
| 33 | 33 | map.with_options(:controller => "projects", :action => "category") do |project_cat| |
| toggle raw diff |
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -24,10 +24,10 @@ ActionController::Routing::Routes.draw do |map|
account.resources :keys
end
map.connect "users/activate/:activation_code", :controller => "users", :action => "activate"
- map.resources :users, :requirements => {:id => /[^\/\\\.\s]+/ }, :collection => { # FIXME: fails if login contains .
+ map.resources :users, :requirements => {:id => /.+/ }, :collection => {
:forgot_password => :get,
:reset_password => :post,
- }
+ }, :member => { :feed => :get }
map.resources :events
map.resource :sessions
map.with_options(:controller => "projects", :action => "category") do |project_cat| |
| |   |
| 98 | 98 | (assigns[:commits_last_week] >= 0).should == true |
| 99 | 99 | end |
| 100 | 100 | |
| 101 | it "#show sets atom feed autodiscovery" do |
| 102 | user = users(:johan) |
| 103 | get :show, :id => user.login |
| 104 | assigns[:atom_auto_discovery_url].should == formatted_feed_user_path(user, :atom) |
| 105 | end |
| 106 | |
| 107 | it "has an atom feed" do |
| 108 | user = users(:johan) |
| 109 | get :feed, :id => user.login, :format => "atom" |
| 110 | response.should be_success |
| 111 | assigns[:user].should == user |
| 112 | assigns[:events].should == user.events.find(:all, :limit => 30, :order => "created_at desc") |
| 113 | end |
| 114 | |
| 101 | 115 | describe "#forgot_password" do |
| 102 | 116 | it "GETs the page fine for everyone" do |
| 103 | 117 | get :forgot_password |
| toggle raw diff |
--- a/spec/controllers/users_controller_spec.rb
+++ b/spec/controllers/users_controller_spec.rb
@@ -98,6 +98,20 @@ describe UsersController do
(assigns[:commits_last_week] >= 0).should == true
end
+ it "#show sets atom feed autodiscovery" do
+ user = users(:johan)
+ get :show, :id => user.login
+ assigns[:atom_auto_discovery_url].should == formatted_feed_user_path(user, :atom)
+ end
+
+ it "has an atom feed" do
+ user = users(:johan)
+ get :feed, :id => user.login, :format => "atom"
+ response.should be_success
+ assigns[:user].should == user
+ assigns[:events].should == user.events.find(:all, :limit => 30, :order => "created_at desc")
+ end
+
describe "#forgot_password" do
it "GETs the page fine for everyone" do
get :forgot_password |