Revision 1015:52be96e83080

View differences:

.hgignore
29 29
.svn/
30 30
.git/
31 31
*~
32

  
32
public/themes/soundsoftware/stylesheets/fonts/*
33 33

  
34 34
.bundle
35 35
Gemfile.lock
app/controllers/activities_controller.rb
40 40

  
41 41
    events = @activity.events(@date_from, @date_to)
42 42

  
43
    if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language])
43
    @institution_name = params[:institution]
44
    if !@institution_name.blank?
45
      events = events.select do |e|
46
        e.respond_to?(:event_author) and e.event_author and
47
	  e.event_author.respond_to?(:ssamr_user_detail) and
48
          !e.event_author.ssamr_user_detail.nil? and
49
          e.event_author.ssamr_user_detail.institution_name == @institution_name
50
      end
51
      if events.empty?
52
        # We don't want to dump into the output any arbitrary string
53
        # from the URL that has no matching events
54
        @institution_name = ""
55
      end
56
    end
57

  
58
    if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, @institution_name, events.first, User.current, current_language])
44 59
      respond_to do |format|
45 60
        format.html {
46 61
          @events_by_day = events.group_by(&:event_date)
app/controllers/projects_controller.rb
20 20
  menu_item :roadmap, :only => :roadmap
21 21
  menu_item :settings, :only => :settings
22 22

  
23
  before_filter :find_project, :except => [ :index, :list, :new, :create, :copy ]
24
  before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
23
  before_filter :find_project, :except => [ :index, :list, :explore, :new, :create, :copy ]
24
  before_filter :authorize, :except => [ :index, :list, :explore, :new, :create, :copy, :archive, :unarchive, :destroy]
25 25
  before_filter :authorize_global, :only => [:new, :create]
26 26
  before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
27 27
  accept_rss_auth :index
......
43 43
  helper :repositories
44 44
  include RepositoriesHelper
45 45
  include ProjectsHelper
46
  include ActivitiesHelper
47
  helper :activities
46 48

  
47 49
  # Lists visible projects. Paginator is for top-level projects only
48 50
  # (subprojects belong to them)
......
76 78
    end
77 79
  end
78 80

  
81
  # A different view of projects using explore boxes
82
  def explore
83
    respond_to do |format|
84
      format.html {
85
        @projects = Project.visible
86
        render :template => 'projects/explore.html.erb', :layout => !request.xhr?
87
      }
88
    end
89
  end
90

  
79 91
  def new
80 92
    @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
81 93
    @trackers = Tracker.all
app/controllers/welcome_controller.rb
25 25
    @site_project = Project.find_by_identifier "soundsoftware-site"
26 26
    @site_news = []
27 27
    @site_news = News.latest_for @site_project if @site_project
28
    @projects = Project.latest User.current
29 28
    
30 29
    # tests if user is logged in to generate the tips of the day list
31 30
    if User.current.logged?
app/helpers/activities_helper.rb
1

  
2
module ActivitiesHelper
3

  
4
  def busy_projects(events, count)
5
    # Transform events list into hash from project id to number of
6
    # occurrences of project in list (there is surely a tidier way
7
    # to do this, e.g. chunk() in Ruby 1.9 but not in 1.8)
8
    phash = events.map { |e| e.project unless !e.respond_to?(:project) }.sort.group_by { |p| p.id }
9
    phash = phash.merge(phash) { |k,v| v.length }
10
    threshold = phash.values.sort.last(count).first
11
    busy = phash.keys.select { |k| phash[k] >= threshold }.sample(count)
12
    busy.map { |pid| Project.find(pid) }
13
  end
14

  
15
  def busy_institutions(events, count)
16
    authors = events.map do |e|
17
      e.event_author unless !e.respond_to?(:event_author) 
18
    end.compact
19
    institutions = authors.map do |a|
20
      if a.respond_to?(:ssamr_user_detail) and !a.ssamr_user_detail.nil?
21
        a.ssamr_user_detail.institution_name
22
      end
23
    end
24
    insthash = institutions.compact.sort.group_by { |i| i }
25
    insthash = insthash.merge(insthash) { |k,v| v.length }
26
    threshold = insthash.values.sort.last(count).first
27
    insthash.keys.select { |k| insthash[k] >= threshold }.sample(count)
28
  end
29

  
30
end
app/views/activities/_busy.html.erb
1
<% events = @events_by_day %>
2
<% if (events.nil?) 
3
     activity = Redmine::Activity::Fetcher.new(User.current)
4
     events = activity.events(Date.today - 14, Date.today + 1)
5
   end
6
%>
7

  
8
<% if events.empty? %>
9

  
10
<% else %>
11

  
12
   <ul>
13

  
14
   <% 
15
      for project in busy_projects(events, 5)
16
   %>
17

  
18
   <li class="busy">
19
     <span class="title">
20
       <% if !project.root? %>
21
         <% project.ancestors.each do |p| %>
22
           <%= h(p) %>&nbsp;&#187;
23
         <% end %>
24
       <% end %>
25
       <%= link_to_project project %>
26
     </span>
27
     <% if !project.is_public? %>
28
       <span class="private"><%= l(:field_is_private) %></span>
29
     <% end %>
30
     <span class='managers'>
31
     <%
32
	u = project.users_by_role
33
	if ! u.empty? %>
34
     (<%=
35
	   mgmt_roles = u.keys.select{ |r| r.allowed_to?(:edit_project) }
36
	   managers = mgmt_roles.map{ |r| u[r] }.flatten.sort.uniq
37
	   managers.map{ |m| m.name }.join(', ')
38
	 %>)<%
39
	end
40
	%>
41
	</span>
42

  
43
     <%= render_project_short_description project %>
44
   </li>
45

  
46
    <% end %>
47
  </ul>
48
<% end %>
app/views/activities/_busy_institution.html.erb
1
<% events = @events_by_day %>
2
<% if (events.nil?) 
3
     activity = Redmine::Activity::Fetcher.new(User.current)
4
     events = activity.events(Date.today - 14, Date.today + 1)
5
   end
6
%>
7

  
8
<% if events.empty? %>
9

  
10
<% else %>
11

  
12
   <ul>
13

  
14
   <% 
15
      for institution in busy_institutions(events, 5)
16
   %>
17

  
18
   <li class="busy">
19
     <span class="title">
20
       <%= link_to h(institution), { :controller => 'activities', :institution => institution } %>
21
     </span>
22
   </li>
23

  
24
    <% end %>
25
  </ul>
26
<% end %>
app/views/activities/index.html.erb
1
<h2><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)) %></h2>
1
<h2><%=
2
  if @author.nil?
3
    if @institution_name.blank?
4
      l(:label_activity)
5
    else
6
      l(:label_institution_activity, h(@institution_name))
7
    end
8
  else
9
    l(:label_user_activity, link_to_user(@author))
10
  end
11
  %></h2>
2 12
<p class="subtitle"><%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %></p>
3 13

  
4 14
<div id="activity">
app/views/projects/_latest.html.erb
1
    <ul>
2
    <% for project in Project.latest(User.current) %>
3
	<li class="latest">
4
	<span class="title">
5
	  <% if !project.root? %>
6
	    <% project.ancestors.each do |p| %>
7
	      <%= h(p) %>&nbsp;&#187;
8
	    <% end %>
9
	  <% end %>
10
	<%= link_to_project project %>
11
	</span>
12
	<% if !project.is_public? %>
13
	   <span class="private"><%= l(:field_is_private) %></span>
14
	<% end %>
15
	<span class="time"><%= format_time(project.created_on)%></span>
16
	<%= render_project_short_description project %>
17
      </li>
18
    <% end %>
19
    </ul>
app/views/projects/explore.html.erb
1

  
2
<h2><%= l(:label_explore_projects) %></h2>
3

  
4
  <div class="tags box">
5
  <h3><%=l(:label_project_tags_all)%></h3>
6
    <%= render :partial => 'projects/tagcloud' %>
7
  </div>
8
<div class="splitcontentleft">
9
  <div class="institutions box">
10
  <h3><%=l(:label_institutions_busy)%></h3>
11
    <%= render :partial => 'activities/busy_institution' %>
12
  </div>
13
  <div class="projects box">
14
  <h3><%=l(:label_project_latest)%></h3>
15
    <%= render :partial => 'projects/latest' %>
16
  </div>
17
</div>
18
<div class="splitcontentright">
19
  <div class="projects box">
20
  <h3><%=l(:label_projects_busy)%></h3>
21
    <%= render :partial => 'activities/busy' %>
22
  </div>
23
</div>
app/views/welcome/index.html.erb
14 14

  
15 15
<div class="splitcontentright">
16 16
  <% if @site_news.any? %>
17
  <div class="news box">
18
	<h3><%=l(:label_news_site_latest)%></h3>
17
    <div class="news box">
18
       <h3><%=l(:label_news_site_latest)%></h3>
19 19
	<%= render :partial => 'news/news', :locals => { :project => @site_project }, :collection => @site_news %>
20
	
21 20
	<%= link_to l(:label_news_more), { :controller => 'projects', :action => @site_project.identifier, :id => 'news' } %>
22 21
  </div>
23 22
  <% end %>
24
    <% if @projects.any? %>
25 23
  <div class="projects box">
26 24
  <h3><%=l(:label_project_latest)%></h3>
27
    <ul>
28
    <% for project in @projects %>
29
      <% @project = project %>
30
	<li class="latest">
31
	<span class="title">
32
	  <% if !project.root? %>
33
	    <% project.ancestors.each do |p| %>
34
	      <%= h(p) %>&nbsp;&#187;
35
	    <% end %>
36
	  <% end %>
37
	<%= link_to_project project %>
38
	</span>
39
	<% if !project.is_public? %>
40
	   <span class="private"><%= l(:field_is_private) %></span>
41
	<% end %>
42
	<span class="time"><%= format_time(project.created_on)%></span>
43
	<%= render_project_short_description project %>
44
      </li>
45
    <% end %>
46
    <% @project = nil %>
47
    </ul>
48
	<%= link_to l(:label_projects_more), :controller => 'projects' %>
25
    <%= render :partial => 'projects/latest' %>
26
    <%= link_to l(:label_projects_more), :controller => 'projects' %>
49 27
  </div>
50
  <% end %>
51 28
    <%= call_hook(:view_welcome_index_right, :projects => @projects) %>
52 29
</div>
53 30

  
config/locales/en.yml
494 494
  label_project_all: All Projects
495 495
  label_project_latest: Latest projects
496 496
  label_projects_more: More projects
497
  label_project_tags_all: Popular tags
498
  label_projects_busy: Busy projects
499
  label_institutions_busy: Active institutions
497 500
  label_managers: Managed by
498 501
  label_issue: Issue
499 502
  label_issue_new: New issue
......
560 563
  label_activity_my_recent_none: No recent activity
561 564
  label_overall_activity: Overall activity
562 565
  label_user_activity: "%{value}'s activity"
566
  label_institution_activity: "Activity from %{value}"
563 567
  label_new: New
564 568
  label_logged_as: Logged in as
565 569
  label_environment: Environment
......
689 693
  label_repository: Repository
690 694
  label_is_external_repository: Track an external repository
691 695
  label_repository_plural: Repositories
692
  label_browse: Browse
696
  label_explore_projects: Explore projects
693 697
  label_modification: "%{count} change"
694 698
  label_modification_plural: "%{count} changes"
695 699
  label_branch: Branch
config/routes.rb
32 32
  # TODO: wasteful since this is also nested under issues, projects, and projects/issues
33 33
  map.resources :time_entries, :controller => 'timelog'
34 34

  
35
  map.connect 'explore', :controller => 'projects', :action => 'explore'
36

  
35 37
  map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post}
36 38
  map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get}
37 39
  map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post}
extra/soundsoftware/get-statistics.rb
5 5
# ./script/runner -e production extra/soundsoftware/get-statistics.rb 
6 6
#
7 7

  
8
d1 = Date.parse("20101201") # => 1 Dec 2010
8
d1 = Date.parse("20100701") # => 1 Jul 2010
9 9
d2 = Date.today
10 10

  
11
def delta_array (iarray)
12
  # returns an array with the deltas
13
  ## prepends a zero and drops the last element
14
  deltas = [0] + iarray
15
  deltas = deltas.first(deltas.size - 1)
16

  
17
  return iarray.zip(deltas).map { |x, y| x - y }
18

  
19
end
20

  
11 21
def months_between(d1, d2)
12 22
   months = []
13 23
   start_date = Date.civil(d1.year, d1.month, 1)
......
32 42

  
33 43
   while (start_date < end_date)
34 44
     weeks << start_date
35
     start_date = start_date + 1.week
45
     start_date = start_date + 2.week
36 46
   end
37 47

  
38 48
   weeks << end_date
39 49
end
40 50

  
41
# dates = months_between(d1, d2)
42
dates = weeks_between(d1, d2)
51
def get_user_project_evol_stats()
52
  # dates = months_between(d1, d2)
53
  dates = months_between(d1, d2)
54
  
55
  # number of users 
56
  n_users = []
57
  n_projects = []
58
  qm_users = []
59
  
60
  dates.each do |date|
61
    users =  User.find_by_sql ["SELECT * FROM users WHERE users.status = '1' AND users.created_on <= ?;", date]
62
    projects =  Project.find_by_sql ["SELECT * FROM projects WHERE projects.created_on <= ?;", date]
63
    
64
    qm_users_list = User.find_by_sql ["SELECT * FROM users,ssamr_user_details WHERE users.status = '1' AND ssamr_user_details.user_id = users.id AND (users.mail like '%qmul%' OR ssamr_user_details.institution_id = '99') AND users.created_on <= ?;", date ]
65
    
66
    qm_users << qm_users_list.count
67
    n_users << users.count
68
    n_projects << projects.count
69
    
70
    #  private_projects =  Project.find(:all, :conditions => {:created_on  => d1..date, is_public => false})
71
  end
72
  
73
  user_deltas = delta_array(n_users)
74
  proj_deltas = delta_array(n_projects)
75
  qm_user_deltas = delta_array(qm_users)
76
  
77
  puts "Date Users D_Users QM_Users D_QM_users Projects D_Projects"
78
  
79
  dates.zip(n_users, user_deltas, qm_users, qm_user_deltas, n_projects, proj_deltas).each do |a, b, c, d, e, f, g|
80
    puts "#{a} #{b} #{c} #{d} #{e} #{f} #{g}"
81
  end
82
  
83
end
43 84

  
44
dates.each do |date|
45
  users =  User.find(:all, :conditions => {:created_on  => d1..date})
46
  all_projects =  Project.find(:all, :conditions => {:created_on  => d1..date})
47
  private_projects =  Project.find(:all, :conditions => {:created_on  => d1..date, 
48
                                                          :is_public => false})
49
  top_level_and_private_projects =  Project.find(:all, :conditions => {:created_on  => d1..date,
50
                                                                        :is_public => false, 
51
                                                                        :parent_id => nil})
52 85

  
53
  puts "#{date} #{users.count} #{all_projects.count} #{private_projects.count} #{top_level_and_private_projects.count}\n"
86
def get_project_status()
87
  date = "20121101"
88
  
89
   all_projects = Project.find(:all, :conditions => ["created_on < ?", date])
90
  #  all_projects = Project.find(:all, :conditions => ["is_public = ? AND created_on < ?", true, date])
91
#  all_projects = Project.find(:all, :conditions => ["is_public = ? AND created_on < ?", false, date])
92
  
93
  collab = []
94
  users_per_proj = []
95
  
96
  #  puts "Public Users Institutions"
97

  
98
  all_projects.each do |proj| 
99
    insts = []
100

  
101
    proj.users.each do |u|  
102
      if u.institution == "" || u.institution == "No Institution Set"
103
        if u.mail.include?("qmul.ac.uk") || u.mail.include?("andrewrobertson77")
104
          insts << "Queen Mary, University of London"          
105
        else
106
          insts << u.mail
107
        end
108
      else
109
        insts << u.institution
110
      end
111
    end
112

  
113
    users_per_proj << proj.users.count
114
    collab << insts.uniq.count
115
  end
116
  
117
  
118
  #  freq = collab.inject(Hash.new(0)) { |h,v| h[v] += 1; h }
119
  #  freq = freq.sort_by {|key, value| value}
120
  #  puts freq.inspect.sort
121

  
122
  puts "Projects: #{all_projects.count} UpP: #{users_per_proj.sum / users_per_proj.size.to_f} Users1+: #{users_per_proj.count{|x| x> 1}} Users2+: #{users_per_proj.count{|x| x> 2}} Collab1+: #{collab.count{|x| x > 1}} Collab2+: #{collab.count{|x| x > 2}} IpP: #{collab.sum / collab.size.to_f}"
123
end
124

  
125
def get_user_projects_ratios()
126
  user_projects = User.find(:all, :conditions=> {:status => 1})
127
  pub_proj_user = user_projects.map{|u| u.projects.find(:all, :conditions=>{:is_public => true}).count}
128

  
129
  user_projects.zip(pub_proj_user).each do |u, pub|
130
      puts "#{u.projects.count} #{pub}"
131
  end
54 132

  
55 133
end
56 134

  
135
def get_inst_list()
136
  users = User.find(:all, :conditions => {:status => 1})
137
  inst_list = users.map{|user| user.institution}
138
  
139
  freq = inst_list.inject(Hash.new(0)) { |h,v| h[v] += 1; h }
140
  
141
end
57 142

  
58 143

  
144
# get_user_projects_ratios()
145
# get_user_project_evol_stats()
59 146

  
147
get_project_status()
public/stylesheets/application.css
240 240
div.members h3 { background: url(../images/group.png) no-repeat 0% 50%; padding-left: 20px; }
241 241
div.news h3 { background: url(../images/news.png) no-repeat 0% 50%; padding-left: 20px; }
242 242
div.projects h3 { background: url(../images/projects.png) no-repeat 0% 50%; padding-left: 20px; }
243
div.tags h3 { background: url(../images/ticket_note.png) no-repeat 0% 50%; padding-left: 20px; }
244
div.institutions h3 { background: url(../images/group.png) no-repeat 0% 50%; padding-left: 20px; }
243 245

  
244 246
#watchers ul {margin: 0;  padding: 0;}
245 247
#watchers li {list-style-type:none;margin: 0px 2px 0px 0px; padding: 0px 0px 0px 0px;}
vendor/plugins/redmine_tags/app/controllers/tags_controller.rb
1
class TagsController < ApplicationController
2
  
3
  def index
4
    respond_to do |format|
5
      format.html {
6
        render :template => 'tags/index.html.erb', :layout => !request.xhr?
7
      }
8
      format.api  {
9
      }
10
      format.atom {
11
      }
12
    end
13
  end
14

  
15
end
vendor/plugins/redmine_tags/app/helpers/tags_helper.rb
40 40
    content_tag('span', content, :class => 'tag-label')
41 41
  end
42 42

  
43
  def render_project_tag_link(tag)
43
  def render_project_tag_link(tag, options = {})
44 44
    content = link_to tag.name, :controller => :projects, :action => :index, :project => { :tag_list => tag.name } 
45
    if options[:show_count]
46
      content << content_tag('span', "(#{tag.count})", :class => 'tag-count')
47
    end
45 48
    content_tag('span', content, :class => 'tag-label')
46 49
  end
47 50

  
......
73 76
      end
74 77

  
75 78
      tag_cloud tags, (1..8).to_a do |tag, weight|
76
        content << " " + content_tag(item_el, render_tag_link(tag, options), :class => "tag-nube-#{weight}") + " "
79
        content << " " + content_tag(item_el, render_project_tag_link(tag, options), :class => "tag-nube-#{weight}") + " "
77 80
      end
78 81

  
79 82
      content_tag(list_el, content, :class => 'tags')
vendor/plugins/redmine_tags/app/views/projects/_tagcloud.html.erb
1
<% content_for :header_tags do %>
2
    <%= stylesheet_link_tag 'redmine_tags', :plugin => 'redmine_tags' %>
3
<% end %>
4

  
5
<div id="tags">
6
<%= render_tags_list(Project.available_tags, :style => :cloud) %>
7
</div>
8

  
9

  
vendor/plugins/redmine_tags/app/views/projects/index.html.erb
11 11
</div>
12 12

  
13 13

  
14

  
15 14
<div style="clear:both;"></div>
16 15
<% if User.current.logged? %>
17 16
  <%= render :partial => 'my_projects' %>
vendor/plugins/redmine_tags/app/views/tags/index.html.erb
1
<% content_for :header_tags do %>
2
    <%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %>
3
    <%= stylesheet_link_tag 'redmine_tags', :plugin => 'redmine_tags' %>
4
<% end %>
5

  
6

  
7
<div style="clear:both;"></div>
8
<h2>
9
  <%= l("label_project_tags_all") %>
10
</h2>
11

  
12
<%= render_tags_list(Project.available_tags, :style => :cloud) %>
13

  
vendor/plugins/redmine_tags/assets/stylesheets/redmine_tags.css
22 22
ul.tags li { margin: .25em 0px; }
23 23

  
24 24
div.tags { text-align: center; }
25
div.tags h3 { text-align: left; }
25 26
div.tags .tag-label { margin: .25em; }
26 27
div.tags .tag-nube-1 { font-size: .8em; }
27 28
div.tags .tag-nube-2 { font-size: .9em; }
vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb
4 4

  
5 5
      def self.included(base) # :nodoc:
6 6
        base.send(:include, InstanceMethods)
7
        base.send(:include, TagsHelper)
7 8
        base.class_eval do
8 9
          unloadable
9 10
        end

Also available in: Unified diff