| |   |
| 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 |
| |   |
| 2 | 2 | module ApplicationHelper |
| 3 | 3 | include TagsHelper |
| 4 | 4 | |
| 5 | def feed_icon(url, alt_title = "Atom feed", size = :small) |
| 6 | link_to image_tag("feed_12.png", :class => "feed_icon"), url, |
| 7 | :alt => alt_title, :title => alt_title |
| 8 | end |
| 9 | |
| 5 | 10 | def default_css_tag_sizes |
| 6 | 11 | %w(tag_size_1 tag_size_2 tag_size_3 tag_size_4) |
| 7 | 12 | end |
| … | … | |
| 149 | 149 | action = "<strong>deleted repository</strong> #{link_to h(target.title), project_path(target)}/#{event.data}" |
| 150 | 150 | category = "project" |
| 151 | 151 | when Action::COMMIT |
| 152 | | project = target.project |
| 152 | project = event.project |
| 153 | 153 | action = "<strong>committed</strong> #{link_to event.data[0,8], project_repository_commit_path(project, target, event.data)} to #{link_to h(project.slug), project_path(project)}/#{link_to h(target.name), project_repository_url(project, target)}" |
| 154 | | body = truncate(event.body, 150) |
| 154 | body = link_to(h(truncate(event.body, 150)), project_repository_commit_path(project, target, event.data)) |
| 155 | 155 | category = "commit" |
| 156 | 156 | when Action::CREATE_BRANCH |
| 157 | 157 | project = target.project |
| toggle raw diff |
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -2,6 +2,11 @@
module ApplicationHelper
include TagsHelper
+ def feed_icon(url, alt_title = "Atom feed", size = :small)
+ link_to image_tag("feed_12.png", :class => "feed_icon"), url,
+ :alt => alt_title, :title => alt_title
+ end
+
def default_css_tag_sizes
%w(tag_size_1 tag_size_2 tag_size_3 tag_size_4)
end
@@ -144,9 +149,9 @@ module ApplicationHelper
action = "<strong>deleted repository</strong> #{link_to h(target.title), project_path(target)}/#{event.data}"
category = "project"
when Action::COMMIT
- project = target.project
+ project = event.project
action = "<strong>committed</strong> #{link_to event.data[0,8], project_repository_commit_path(project, target, event.data)} to #{link_to h(project.slug), project_path(project)}/#{link_to h(target.name), project_repository_url(project, target)}"
- body = truncate(event.body, 150)
+ body = link_to(h(truncate(event.body, 150)), project_repository_commit_path(project, target, event.data))
category = "commit"
when Action::CREATE_BRANCH
project = target.project |
| |   |
| 5 | 5 | <%= auto_link(markdown(sanitize(@project.description)), :urls) -%> |
| 6 | 6 | </div> |
| 7 | 7 | |
| 8 | | <h2>Activities<%= link_to image_tag("feed.png", :width => 24, :height => 24), @atom_auto_discovery_url %></h2> |
| 8 | <h2>Activities<%= feed_icon @atom_auto_discovery_url %></h2> |
| 9 | 9 | <%= render :partial => "events/events", :locals => { :events => @events } -%> |
| 10 | 10 | |
| 11 | 11 | <% content_for :submenu do -%> |
| toggle raw diff |
--- a/app/views/projects/show.html.erb
+++ b/app/views/projects/show.html.erb
@@ -5,7 +5,7 @@
<%= auto_link(markdown(sanitize(@project.description)), :urls) -%>
</div>
-<h2>Activities<%= link_to image_tag("feed.png", :width => 24, :height => 24), @atom_auto_discovery_url %></h2>
+<h2>Activities<%= feed_icon @atom_auto_discovery_url %></h2>
<%= render :partial => "events/events", :locals => { :events => @events } -%>
<% content_for :submenu do -%> |
| |   |
| 7 | 7 | |
| 8 | 8 | <%= render :partial => "infobox" -%> |
| 9 | 9 | |
| 10 | | <%= render_readme(@repository) %> |
| 10 | <%#= render_readme(@repository) %> |
| 11 | 11 | |
| 12 | | <h2>Activities <%= link_to image_tag("feed.png", :width => 24, :height => 24), @atom_auto_discovery_url %></h2> |
| 12 | <h2>Activities <%= feed_icon @atom_auto_discovery_url %></h2> |
| 13 | 13 | <%= render :partial => "events/events", :locals => { :events => @events } -%> |
| 14 | 14 | <% end -%> |
| 15 | 15 | |
| toggle raw diff |
--- a/app/views/repositories/show.html.erb
+++ b/app/views/repositories/show.html.erb
@@ -7,9 +7,9 @@
<%= render :partial => "infobox" -%>
- <%= render_readme(@repository) %>
+ <%#= render_readme(@repository) %>
- <h2>Activities <%= link_to image_tag("feed.png", :width => 24, :height => 24), @atom_auto_discovery_url %></h2>
+ <h2>Activities <%= feed_icon @atom_auto_discovery_url %></h2>
<%= render :partial => "events/events", :locals => { :events => @events } -%>
<% 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 |
| |   |
| 1 | 1 | <% @page_title = h(@user.login) -%> |
| 2 | 2 | |
| 3 | 3 | <% unless @events.empty? -%> |
| 4 | | <h2>Activities<%= link_to image_tag("feed.png", :width => 24, :height => 24), @atom_auto_discovery_url %></h2> |
| 4 | <h2>Activities<%= feed_icon @atom_auto_discovery_url %></h2> |
| 5 | 5 | <%= render :partial => "events/events", :locals => { :events => @events } -%> |
| 6 | 6 | <% end -%> |
| 7 | 7 | |
| toggle raw diff |
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -1,7 +1,7 @@
<% @page_title = h(@user.login) -%>
<% unless @events.empty? -%>
- <h2>Activities<%= link_to image_tag("feed.png", :width => 24, :height => 24), @atom_auto_discovery_url %></h2>
+ <h2>Activities<%= feed_icon @atom_auto_discovery_url %></h2>
<%= render :partial => "events/events", :locals => { :events => @events } -%>
<% end -%>
|
| |   |
| 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| |
| |   |
| 1156 | 1156 | background: #b6babc; |
| 1157 | 1157 | } |
| 1158 | 1158 | |
| 1159 | .event_instance .event_category.comment { background: #a49d98; } |
| 1160 | .event_instance .event_category.project { background: #98a49f; } |
| 1161 | .event_instance .event_category.merge_request { background: #a2a498; } |
| 1162 | |
| 1159 | 1163 | /* repository meta (overview apge) */ |
| 1160 | 1164 | table.repository_meta { |
| 1161 | 1165 | /* border: 1px solid #ddd;*/ |
| … | … | |
| 1198 | 1198 | table.repository_meta .meta td .bignum { |
| 1199 | 1199 | font-size: 20px; |
| 1200 | 1200 | } |
| 1201 | | table.repository_meta .graph td { text-align:center; } |
| 1201 | table.repository_meta .graph td { text-align:center; } |
| 1202 | |
| 1203 | .feed_icon { margin: 0 4px 0 4px; } |
| toggle raw diff |
--- a/public/stylesheets/base.css
+++ b/public/stylesheets/base.css
@@ -1156,6 +1156,10 @@ ul.diff_stats small.deletions { color: #DC0000; }
background: #b6babc;
}
+.event_instance .event_category.comment { background: #a49d98; }
+.event_instance .event_category.project { background: #98a49f; }
+.event_instance .event_category.merge_request { background: #a2a498; }
+
/* repository meta (overview apge) */
table.repository_meta {
/* border: 1px solid #ddd;*/
@@ -1194,4 +1198,6 @@ table.repository_meta .meta td.commit_count, table.repository_meta .meta td.bran
table.repository_meta .meta td .bignum {
font-size: 20px;
}
-table.repository_meta .graph td { text-align:center; }
\ No newline at end of file
+table.repository_meta .graph td { text-align:center; }
+
+.feed_icon { margin: 0 4px 0 4px; }
\ No newline at end of file |
| |   |
| 7 | 7 | |
| 8 | 8 | abort("Usage: #{$0} repo_id") unless ARGV[0] |
| 9 | 9 | |
| 10 | $stdout.sync = true |
| 11 | |
| 10 | 12 | def create_repo_creation_events_for(project) |
| 11 | 13 | project.repository_clones.each do |repo| |
| 12 | 14 | puts "creating Repository clone event in #{project.slug}/#{repo.name}" |
| 13 | | # project.create_event(Action::CLONE_REPOSITORY, repo, repo.user, repo.parent_id) |
| 14 | 15 | project.events.create({ |
| 15 | 16 | :action => Action::CLONE_REPOSITORY, |
| 16 | 17 | :target => repo, |
| … | … | |
| 25 | 25 | def create_comment_events_for(repo, project) |
| 26 | 26 | repo.comments.each do |comment| |
| 27 | 27 | puts "creating Comment event on #{project.slug}/#{repo.name}" |
| 28 | | #project.create_event(Action::COMMENT, comment, comment.user) |
| 29 | 28 | project.events.create({ |
| 30 | 29 | :action => Action::COMMENT, |
| 31 | 30 | :target => comment, |
| … | … | |
| 67 | 67 | users_commits[commit.committer.email] ||= [] |
| 68 | 68 | users_commits[commit.committer.email] << commit |
| 69 | 69 | end |
| 70 | | |
| 70 | |
| 71 | 71 | users = User.find(:all, :conditions => ['email in (?)', users_commits.keys] ) |
| 72 | 72 | users.each do |user| |
| 73 | 73 | commits = users_commits[user.email] |
| 74 | | |
| 74 | puts "\nindexing #{commits.size} commits for #{user.email} in #{project.slug}/#{repo.name}:#{head.name}" |
| 75 | 75 | commits.each_index do |i| |
| 76 | 76 | commit = commits[i] |
| 77 | 77 | previous_commit = commits[i-1] |
| … | … | |
| 152 | 152 | end |
| 153 | 153 | end |
| 154 | 154 | |
| 155 | | puts "#{current_rev_type}#{action.inspect} in #{project.slug}/#{repo.name}:#{head.name}: #{commit.short_message}" |
| 156 | | #project.create_event(action_id, repo, user, commit.id, commit.message) |
| 155 | print "." if (i % 10 == 1) |
| 156 | #puts "#{current_rev_type}#{action.inspect} in #{project.slug}/#{repo.name}:#{head.name}: #{commit.short_message}" |
| 157 | 157 | project.events.create({ |
| 158 | 158 | :action => action_id || Action::COMMIT, |
| 159 | 159 | :target => repo, |
| … | … | |
| 163 | 163 | :created_at => commit.committed_date}) |
| 164 | 164 | end |
| 165 | 165 | commits = nil |
| 166 | puts |
| 166 | 167 | end |
| 167 | 168 | users_commits = nil |
| 168 | 169 | end |
| toggle raw diff |
--- a/script/rebuild_events
+++ b/script/rebuild_events
@@ -7,10 +7,11 @@ require File.dirname(__FILE__) + "/../config/environment"
abort("Usage: #{$0} repo_id") unless ARGV[0]
+$stdout.sync = true
+
def create_repo_creation_events_for(project)
project.repository_clones.each do |repo|
puts "creating Repository clone event in #{project.slug}/#{repo.name}"
- # project.create_event(Action::CLONE_REPOSITORY, repo, repo.user, repo.parent_id)
project.events.create({
:action => Action::CLONE_REPOSITORY,
:target => repo,
@@ -24,7 +25,6 @@ end
def create_comment_events_for(repo, project)
repo.comments.each do |comment|
puts "creating Comment event on #{project.slug}/#{repo.name}"
- #project.create_event(Action::COMMENT, comment, comment.user)
project.events.create({
:action => Action::COMMENT,
:target => comment,
@@ -67,11 +67,11 @@ def create_events_for_repository(repo, project)
users_commits[commit.committer.email] ||= []
users_commits[commit.committer.email] << commit
end
-
+
users = User.find(:all, :conditions => ['email in (?)', users_commits.keys] )
users.each do |user|
commits = users_commits[user.email]
-
+ puts "\nindexing #{commits.size} commits for #{user.email} in #{project.slug}/#{repo.name}:#{head.name}"
commits.each_index do |i|
commit = commits[i]
previous_commit = commits[i-1]
@@ -152,8 +152,8 @@ def create_events_for_repository(repo, project)
end
end
- puts "#{current_rev_type}#{action.inspect} in #{project.slug}/#{repo.name}:#{head.name}: #{commit.short_message}"
- #project.create_event(action_id, repo, user, commit.id, commit.message)
+ print "." if (i % 10 == 1)
+ #puts "#{current_rev_type}#{action.inspect} in #{project.slug}/#{repo.name}:#{head.name}: #{commit.short_message}"
project.events.create({
:action => action_id || Action::COMMIT,
:target => repo,
@@ -163,6 +163,7 @@ def create_events_for_repository(repo, project)
:created_at => commit.committed_date})
end
commits = nil
+ puts
end
users_commits = nil
end |
| |   |
| 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 |