Revision 1009:066b55d7c053 app

View differences:

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.ssamr_user_detail.institution_name == @institution_name
48
      end
49
      if events.empty?
50
        # We don't want to dump into the output any arbitrary string
51
        # from the URL that has no matching events
52
        @institution_name = ""
53
      end
54
    end
55

  
56
    if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, @institution_name, events.first, User.current, current_language])
44 57
      respond_to do |format|
45 58
        format.html {
46 59
          @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, :browse, :new, :create, :copy ]
24
  before_filter :authorize, :except => [ :index, :list, :browse, :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
......
76 76
    end
77 77
  end
78 78

  
79
  # A different view of projects using browse boxes
80
  def browse
79
  # A different view of projects using explore boxes
80
  def explore
81 81
    respond_to do |format|
82 82
      format.html {
83 83
        @projects = Project.visible
84
        render :template => 'projects/browse.html.erb', :layout => !request.xhr?
84
        render :template => 'projects/explore.html.erb', :layout => !request.xhr?
85 85
      }
86 86
    end
87 87
  end
app/views/activities/_busy.html.erb
16 16
      # Transform events list into hash from project id to number of
17 17
      # occurrences of project in list (there is surely a tidier way
18 18
      # to do this, e.g. chunk() in Ruby 1.9 but not in 1.8)
19
      phash = events.map { |e| e.project }.sort.group_by { |p| p.id }
19
      phash = events.map { |e| e.project unless !e.respond_to?(:project) }.sort.group_by { |p| p.id }
20 20
      phash = phash.merge(phash) { |k,v| v.length }
21 21
      threshold = phash.values.sort.last(max).first
22 22
      busy = phash.keys.select { |k| phash[k] >= threshold }.sample(max)
app/views/activities/_busy_institution.html.erb
1
<% events = @events_by_day %>
2
<% max = 5 %>
3
<% if (events.nil?) 
4
     activity = Redmine::Activity::Fetcher.new(User.current)
5
     events = activity.events(Date.today - 14, Date.today + 1)
6
   end
7
%>
8

  
9
<% if events.empty? %>
10

  
11
<% else %>
12

  
13
   <ul>
14

  
15
   <% 
16
      authors = events.map { |e| e.event_author unless !e.respond_to?(:event_author) }.compact
17
      institutions = authors.map { |a| a.ssamr_user_detail.institution_name }
18
      insthash = institutions.compact.sort.group_by { |i| i }
19
      insthash = insthash.merge(insthash) { |k,v| v.length }
20
      threshold = insthash.values.sort.last(max).first
21
      busy = insthash.keys.select { |k| insthash[k] >= threshold }.sample(max)
22

  
23
      for institution in busy
24
   %>
25

  
26
   <li class="busy">
27
     <span class="title">
28
       <%= link_to h(institution), { :controller => 'activities', :institution => institution } %>
29
     </span>
30
   </li>
31

  
32
    <% end %>
33
  </ul>
34
<% 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/browse.html.erb
1

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

  
4
<div class="splitcontentleft">
5
  <div class="projects box">
6
  <h3><%=l(:label_project_latest)%></h3>
7
    <%= render :partial => 'projects/latest' %>
8
    <%= link_to l(:label_projects_more), :controller => 'projects' %>
9
  </div>
10
</div>
11
<div class="splitcontentleft">
12
  <div class="projects box">
13
  <h3><%=l(:label_project_tags_all)%></h3>
14
    <%= render :partial => 'projects/tagcloud' %>
15
    <%= link_to l(:label_projects_more), :controller => 'projects' %>
16
  </div>
17
  <div class="projects box">
18
  <h3><%=l(:label_projects_busy)%></h3>
19
    <%= render :partial => 'activities/busy' %>
20
    <%= link_to l(:label_projects_more), :controller => 'projects' %>
21
  </div>
22
</div>
app/views/projects/explore.html.erb
1

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

  
4
<div class="splitcontentleft">
5
  <div class="projects box">
6
  <h3><%=l(:label_project_latest)%></h3>
7
    <%= render :partial => 'projects/latest' %>
8
    <%= link_to l(:label_projects_more), :controller => 'projects' %>
9
  </div>
10
</div>
11
<div class="splitcontentleft">
12
  <div class="projects box">
13
  <h3><%=l(:label_project_tags_all)%></h3>
14
    <%= render :partial => 'projects/tagcloud' %>
15
    <%= link_to l(:label_projects_more), :controller => 'projects' %>
16
  </div>
17
  <div class="projects box">
18
  <h3><%=l(:label_projects_busy)%></h3>
19
    <%= render :partial => 'activities/busy' %>
20
    <%= link_to l(:label_projects_more), :controller => 'projects' %>
21
  </div>
22
  <div class="projects box">
23
  <h3><%=l(:label_institutions_busy)%></h3>
24
    <%= render :partial => 'activities/busy_institution' %>
25
    <%= link_to l(:label_projects_more), :controller => 'projects' %>
26
  </div>
27
</div>
app/views/welcome/index.html.erb
25 25
    <%= render :partial => 'projects/latest' %>
26 26
    <%= link_to l(:label_projects_more), :controller => 'projects' %>
27 27
  </div>
28
  <div class="projects box">
29
  <h3><%=l(:label_project_tags_all)%></h3>
30
    <%= render :partial => 'projects/tagcloud' %>
31
    <%= link_to l(:label_projects_more), :controller => 'projects' %>
32
  </div>
33
  <div class="projects box">
34
  <h3><%=l(:label_projects_busy)%></h3>
35
    <%= render :partial => 'activities/busy' %>
36
    <%= link_to l(:label_projects_more), :controller => 'projects' %>
37
  </div>
38 28
    <%= call_hook(:view_welcome_index_right, :projects => @projects) %>
39 29
</div>
40 30

  

Also available in: Unified diff