System notice: In light of the Debian OpenSSL security issue we've regenerated the server keys. See this thread for instructions and the new key fingerprints.

Commit 4dade837eb3d5988b3a9f3eb0192069c43643564

Made the user feed a member action, since usernames can contain dots

Commit diff

app/controllers/users_controller.rb

 
1414
1515 @commits_last_week = @user.events.count(:all,
1616 :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)
1818
1919 respond_to do |format|
2020 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) }
2131 format.atom { }
2232 end
2333 end
toggle raw diff

app/views/users/feed.atom.builder

 
1atom_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>
13EOS
14 entry.author do |author|
15 author.name(event.user.login)
16 end
17 end
18 end
19end
toggle raw diff

app/views/users/show.atom.builder

 
0atom_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>
12EOS
13 entry.author do |author|
14 author.name(event.user.login)
15 end
16 end
17 end
18end
toggle raw diff

config/routes.rb

 
2424 account.resources :keys
2525 end
2626 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 => {
2828 :forgot_password => :get,
2929 :reset_password => :post,
30 }
30 }, :member => { :feed => :get }
3131 map.resources :events
3232 map.resource :sessions
3333 map.with_options(:controller => "projects", :action => "category") do |project_cat|
toggle raw diff

spec/controllers/users_controller_spec.rb

 
9898 (assigns[:commits_last_week] >= 0).should == true
9999 end
100100
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
101115 describe "#forgot_password" do
102116 it "GETs the page fine for everyone" do
103117 get :forgot_password
toggle raw diff