Revision 1078:b9e34a051f82

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
36 36
Gemfile.local
37 37

  
38
re:^config\.ru$
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/attachments_controller.rb
17 17

  
18 18
class AttachmentsController < ApplicationController
19 19

  
20
  include AttachmentsHelper
21
  helper :attachments
22

  
20 23
  before_filter :find_project
21 24
  before_filter :file_readable, :read_authorize, :except => :destroy
22 25
  before_filter :delete_authorize, :only => :destroy
......
49 52
  end
50 53

  
51 54
  def download
52
    if @attachment.container.is_a?(Version) || @attachment.container.is_a?(Project)
55
    # cc: formerly this happened only if "@attachment.container.is_a?(Version)"
56
    # or Project. Not good for us, we want to tally all downloads [by humans]
57
    if not user_is_search_bot?
53 58
      @attachment.increment_download
54 59
    end
55 60

  
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
......
99 111
    end
100 112
    # end of code to be removed
101 113

  
102

  
103
    if validate_parent_id && @project.save
114
    if validate_is_public_key && validate_parent_id && @project.save
104 115
      @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
105 116
      # Add current user as a project member if he is not admin
106 117
      unless User.current.admin?
......
288 299
    render_404
289 300
  end
290 301

  
302
  def validate_is_public_key
303
    # Although is_public isn't mandatory in the project model (it gets
304
    # defaulted), it must be present in params -- it can be true or
305
    # false, but it must be there. This permits us to make forms in
306
    # which the user _has_ to select public or private (rather than
307
    # defaulting it) if we want to
308
    if params.nil? || params[:project].nil? || !params[:project].has_key?(:is_public)
309
      @project.errors.add :is_public, :public_or_private
310
      return false
311
    end
312
    true
313
  end
314

  
291 315
  # Validates parent_id param according to user's permissions
292 316
  # TODO: move it to Project model in a validation that depends on User.current
293 317
  def validate_parent_id
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/helpers/attachments_helper.rb
42 42
      api.created_on attachment.created_on
43 43
    end
44 44
  end
45

  
46
  # Returns true if user agent appears (approximately) to be a search
47
  # bot or crawler
48
  def user_is_search_bot?
49
    agent = request.env['HTTP_USER_AGENT']
50
    agent and agent =~ /(bot|slurp|crawler|spider)\b/i
51
  end
45 52
end
app/helpers/projects_helper.rb
162 162
    
163 163
  end
164 164

  
165
  # Renders a tree of projects that the current user does not belong
166
  # to, or of all projects if the current user is not logged in.  The
167
  # given collection may be a subset of the whole project tree
168
  # (eg. some intermediate nodes are private and can not be seen).  We
169
  # are potentially interested in various things: the project name,
170
  # description, manager(s), creation date, last activity date,
171
  # general activity level, whether there is anything actually hosted
172
  # here for the project, etc.
165
  # Renders a tree of projects.  The given collection may be a subset
166
  # of the whole project tree (eg. some intermediate nodes are private
167
  # and can not be seen).  We are potentially interested in various
168
  # things: the project name, description, manager(s), creation date,
169
  # last activity date, general activity level, whether there is
170
  # anything actually hosted here for the project, etc.
173 171
  def render_project_table(projects)
174 172

  
175 173
    s = ""
app/views/activities/_busy.html.erb
1
<% events = @events_by_day %>
2
<% if (events.nil?) 
3
     activity = Redmine::Activity::Fetcher.new(User.anonymous)
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.anonymous)
4
     days = Setting.activity_days_default.to_i
5
     events = activity.events(Date.today - days, Date.today + 1)
6
   end
7
%>
8

  
9
<% if events.empty? %>
10

  
11
<% else %>
12

  
13
   <ul>
14

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

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

  
25
    <% end %>
26
  </ul>
27
<% end %>
28

  
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/attachments/_form.html.erb
2 2
  <span>
3 3
    <%= file_field_tag 'attachments[1][file]', :size => 30, :id => nil, :class => 'file',
4 4
          :onchange => "checkFileSize(this, #{Setting.attachment_max_size.to_i.kilobytes}, '#{escape_javascript(l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)))}');"  -%>
5
    <label class="inline"><%= l(:label_optional_description) %><%= text_field_tag 'attachments[1][description]', '', :size => 60, :id => nil, :class => 'description' %></label>
6
    <%= link_to_function(image_tag('delete.png'), 'removeFileField(this)', :title => (l(:button_delete))) %>
5
    <nobr><label class="inline"><%= l(:label_optional_description) %><%= text_field_tag 'attachments[1][description]', '', :size => 60, :id => nil, :class => 'description' %></label>
6
    <%= link_to_function(image_tag('delete.png'), 'removeFileField(this)', :title => (l(:button_delete))) %></nobr>
7 7
  </span>
8 8
</span>
9
<small><%= link_to l(:label_add_another_file), '#', :onclick => 'addFileField(); return false;' %>
9
<br><small><%= link_to l(:label_add_another_file), '#', :onclick => 'addFileField(); return false;' %>
10 10
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
11 11
</small>
app/views/attachments/_links.html.erb
2 2
<% for attachment in attachments %>
3 3
<p><%= link_to_attachment attachment, :class => 'icon icon-attachment' -%>
4 4
<%= h(" - #{attachment.description}") unless attachment.description.blank? %>
5
  <span class="size">(<%= number_to_human_size attachment.filesize %>)</span>
5
  <span class="size_and_count"><%= number_to_human_size attachment.filesize %><%= ", " + l(:label_x_downloads, :count => attachment.downloads) unless attachment.downloads == 0 %></span>
6 6
  <% if options[:deletable] %>
7 7
    <%= link_to image_tag('delete.png'), attachment_path(attachment),
8 8
                                         :confirm => l(:text_are_you_sure),
app/views/projects/_form.html.erb
21 21
<br />
22 22
  <em> <%= l(:text_project_homepage_info) %></em>
23 23
</p>
24
<p><%= f.check_box :is_public %>
24
<p>
25
<%= label(:project, :is_public_1, l(:field_public_or_private) + content_tag("span", " *", :class => "required")) %>
26
<%
27
   # if the project hasn't been created fully yet, then we don't
28
   # want to set either public or private (make the user decide)
29
   initialised = !@project.id.nil?
30
%>
31
  <%= f.radio_button :is_public, 1, :checked => (initialised && @project.is_public?) %>
32
  <%= l(:text_project_public_info) %>
25 33
<br />
26
  <em> <%= l(:text_project_visibility_info) %></em>
34
  <%= f.radio_button :is_public, 0, :checked => (initialised && !@project.is_public?) %> 
35
  <%= l(:text_project_private_info) %>
36
<br>
37
  <em><%= l(:text_project_visibility_info) %></em>
27 38
</p>
28 39
<%= wikitoolbar_for 'project_description' %>
29 40

  
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/_members_box.html.erb
1 1
  <% if @users_by_role.any? %>
2
  <div class="members box">
2
  <div id="memberbox"><div class="box">
3 3
    <h3><%=l(:label_member_plural)%></h3>
4 4
    <p><% @users_by_role.keys.sort.each do |role| %>
5 5
    <%=h role %>: <%= @users_by_role[role].sort.collect{|u| link_to_user u}.join(", ") %><br />
6 6
    <% end %></p>
7
  </div>
7
  </div></div>
8 8
  <% end %>
app/views/projects/explore.html.erb
1
<% content_for :header_tags do %>
2
    <%= stylesheet_link_tag 'redmine_tags', :plugin => 'redmine_tags' %>
3
<% end %>
4

  
5
<% cache(:action => 'explore', :action_suffix => 'tags', :expires_in => 1.hour) do %>
6
<h2><%= l(:label_explore_projects) %></h2>
7
  <div class="tags box">
8
  <h3><%=l(:label_project_tags_all)%></h3>
9
    <%= render :partial => 'projects/tagcloud' %>
10
  </div>
11
<% end %>
12

  
13
<div class="splitcontentleft">
14
  <% cache(:action => 'explore', :action_suffix => 'busy_institutions', :expires_in => 1.hour) do %>
15
  <div class="institutions box">
16
  <h3><%=l(:label_institutions_busy)%></h3>
17
    <%= render :partial => 'activities/busy_institution' %>
18
  </div>
19
  <% end %>
20
  <div class="projects box">
21
  <h3><%=l(:label_project_latest)%></h3>
22
    <%= render :partial => 'projects/latest' %>
23
  </div>
24
</div>
25
<div class="splitcontentright">
26
  <% cache(:action => 'explore', :action_suffix => 'busy_projects', :expires_in => 1.hour) do %>
27
  <div class="projects box">
28
  <h3><%=l(:label_projects_busy)%></h3>
29
    <%= render :partial => 'activities/busy' %>
30
  </div>
31
  <% end %>
32
</div>
app/views/projects/new.html.erb
3 3
<% labelled_tabular_form_for @project do |f| %>
4 4
<%= render :partial => 'form', :locals => { :f => f } %>
5 5
<%= submit_tag l(:button_create) %>
6
<%= submit_tag l(:button_create_and_continue), :name => 'continue' %>
7 6
<%= javascript_tag "Form.Element.focus('project_name');" %>
8 7
<% end %>
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/environment.rb
36 36

  
37 37
  # Enable page/fragment caching by setting a file-based store
38 38
  # (remember to create the caching directory and make it readable to the application)
39
  # config.action_controller.cache_store = :file_store, "#{RAILS_ROOT}/tmp/cache"
39
  config.action_controller.cache_store = :file_store, "#{RAILS_ROOT}/tmp/cache"
40

  
41
  # And for direct uses of the cache
42
  config.cache_store = :file_store, "#{RAILS_ROOT}/tmp/cache"
40 43

  
41 44
  # Activate observers that should always be running
42 45
  # config.active_record.observers = :cacher, :garbage_collector
config/locales/en.yml
130 130
        circular_dependency: "This relation would create a circular dependency"
131 131
        cant_link_an_issue_with_a_descendant: "An issue cannot be linked to one of its subtasks"
132 132
        must_accept_terms_and_conditions: "You must accept the Terms and Conditions"        
133
        public_or_private: "You must select either public or private"
133 134

  
134 135
  actionview_instancetag_blank_option: Please select
135 136

  
......
328 329
  field_root_directory: Root directory
329 330
  field_cvsroot: CVSROOT
330 331
  field_cvs_module: Module
332
  field_public_or_private: "Public or Private?"
331 333

  
332 334
  setting_external_repository: "Select this if the project's main repository is hosted somewhere else"
333 335
  setting_external_repository_url: "The URL of the existing external repository. Must be publicly accessible without a password"
......
487 489
    zero:  no projects
488 490
    one:   1 project
489 491
    other: "%{count} projects"
492
  label_x_downloads:
493
    zero:  never downloaded
494
    one:   downloaded once
495
    other: "downloaded %{count} times"
490 496
  label_project_all: All Projects
491 497
  label_project_latest: Latest projects
492 498
  label_projects_more: More projects
499
  label_project_tags_all: Popular tags
500
  label_projects_busy: Busy projects
501
  label_institutions_busy: Active institutions
493 502
  label_managers: Managed by
494 503
  label_issue: Issue
495 504
  label_issue_new: New issue
......
539 548
  label_home: Home
540 549
  label_home_heading: Welcome!
541 550
  label_my_page: My page
542
  label_my_account: My account
551
  label_my_account: Account
543 552
  label_my_projects: My projects
544 553
  label_my_page_block: My page block
545 554
  label_administration: Administration
......
556 565
  label_activity_my_recent_none: No recent activity
557 566
  label_overall_activity: Overall activity
558 567
  label_user_activity: "%{value}'s activity"
568
  label_institution_activity: "Activity from %{value}"
559 569
  label_new: New
560 570
  label_logged_as: Logged in as
561 571
  label_environment: Environment
......
685 695
  label_repository: Repository
686 696
  label_is_external_repository: Track an external repository
687 697
  label_repository_plural: Repositories
688
  label_browse: Browse
698
  label_explore_projects: Explore projects
689 699
  label_modification: "%{count} change"
690 700
  label_modification_plural: "%{count} changes"
691 701
  label_branch: Branch
......
883 893
  button_expand_all: Expand all
884 894
  button_delete: Delete
885 895
  button_create: Create
886
  button_create_and_continue: Create and continue
896
  button_create_and_continue: Create and Add Another
887 897
  button_test: Test
888 898
  button_edit: Edit
889 899
  button_edit_associated_wikipage: "Edit associated Wiki page: %{page_title}"
......
958 968
  text_caracters_minimum: "Must be at least %{count} characters long."
959 969
  text_length_between: "Length between %{min} and %{max} characters."
960 970
  text_project_name_info: "This will be the name of your project as it appears throughout this site.<br /> You can change it at any time, in the project's settings."
961
  text_project_visibility_info: "If your project is not public, it will be visible only to you and to users that you have added as project members.<br/>You can change this later if you wish."
971
  text_project_public_info: "Public: visible to anybody browsing the site."
972
  text_project_private_info: "Private: visible only to you, and to users you have added as project members."
973
  text_project_visibility_info: "You can change whether your project is public or private later if you wish."
962 974
  text_user_ssamr_description_info: 'Please describe your current research or development interests.<br/>This information will be used at registration to determine that you are a real person &ndash; so please be descriptive, or your application may be delayed or rejected.<br/>After registration, the description is publicly visible in your profile and you can edit it at any time.'
963 975
  text_issue_parent_issue_info: 'If this is a subtask, please insert its parent task number or write the main task name.'
964 976

  
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/extract-javadoc.sh
35 35
# package declarations
36 36

  
37 37
find "$projectdir" -type f -name \*.java \
38
    -exec grep '^ *package [a-zA-Z][a-zA-Z0-9\._-]*; *$' \{\} /dev/null \; |
39
    sed -e 's/\/[^\/]*: *package */:/' -e 's/; *$//' |
38
    -exec egrep '^ *package +[a-zA-Z][a-zA-Z0-9\._-]*;.*$' \{\} /dev/null \; |
39
    sed -e 's/\/[^\/]*: *package */:/' -e 's/;.*$//' |
40 40
    sort | uniq | (
41 41
	current_prefix=
42 42
	current_packages=
extra/soundsoftware/get-apache-log-stats.rb
1

  
2
# Read an Apache log file in SoundSoftware site format from stdin and
3
# produce some per-project stats.
4
#
5
# Invoke with e.g.
6
#
7
# cat /var/log/apache2/code-access.log | \
8
#   script/runner -e production extra/soundsoftware/get-apache-log-stats.rb
9

  
10

  
11
# Use the ApacheLogRegex parser, a neat thing
12
# See http://www.simonecarletti.com/blog/2009/02/apache-log-regex-a-lightweight-ruby-apache-log-parser/
13
require 'apachelogregex'
14

  
15
# This is the format defined in our httpd.conf
16
vhost_combined_format = '%v:%p %h %{X-Forwarded-For}i %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"'
17

  
18
parser = ApacheLogRegex.new(vhost_combined_format)
19

  
20
# project name -> count of hg clones
21
clones = Hash.new(0)
22

  
23
# project name -> count of hg pulls
24
pulls = Hash.new(0)
25

  
26
# project name -> count of hg pushes
27
pushes = Hash.new(0)
28

  
29
# project name -> count of hg archive requests (i.e. Download as Zip)
30
zips = Hash.new(0)
31

  
32
# project name -> count of hits to pages under /projects/projectname
33
hits = Hash.new(0)
34

  
35
# project name -> Project object
36
@projects = Hash.new
37

  
38
parseable = 0
39
unparseable = 0
40

  
41
def is_public_project?(project)
42
  if !project
43
    false
44
  elsif project =~ /^\d+$/
45
    # ignore numerical project ids, they are only used when editing projects
46
    false
47
  elsif @projects.key?(project)
48
    @projects[project].is_public? 
49
  else
50
    pobj = Project.find_by_identifier(project)
51
    if pobj
52
      @projects[project] = pobj
53
      pobj.is_public?
54
    else
55
      print "Project not found: ", project, "\n"
56
      false
57
    end
58
  end
59
end
60

  
61
def print_stats(h)
62
  h.keys.sort { |a,b| h[b] <=> h[a] }.each do |p|
63
    if h[p] > 0
64
      print h[p], " ", @projects[p].name, " [", p, "]\n"
65
    end
66
  end
67
end
68

  
69
STDIN.each do |line|
70

  
71
  record = parser.parse(line)
72

  
73
  # most annoyingly, the parser can't handle the comma-separated list
74
  # in X-Forwarded-For where it has more than one element. If it has
75
  # failed, remove any IP addresses or the word "unknown" with
76
  # trailing commas and try again
77
  if not record
78
    filtered = line.gsub(/(unknown|([0-9]+\.){3}[0-9]+),\s*/, "")
79
    record = parser.parse(filtered)
80
  end
81

  
82
  # discard, but count, unparseable lines
83
  if not record
84
    print "Line not parseable: ", line, "\n"
85
    unparseable += 1
86
    next
87
  end
88

  
89
  # discard everything that isn't a 200 OK response
90
  next if record["%>s"] != "200"
91

  
92
  # discard anything apparently requested by a crawler
93
  next if record["%{User-Agent}i"] =~ /(bot|slurp|crawler|spider|Redmine)\b/i
94

  
95
  # pull out request e.g. GET / HTTP/1.0
96
  request = record["%r"]
97

  
98
  # split into method, path, protocol
99
  if not request =~ /^[^\s]+ ([^\s]+) [^\s]+$/
100
    print "Line not parseable (bad method, path, protocol): ", line, "\n"
101
    unparseable += 1
102
    next
103
  end
104

  
105
  # get the path e.g. /projects/weevilmatic and split on /
106
  path = $~[1]
107
  components = path.split("/")
108
  
109
  # should have at least two elements unless path is "/"; first should
110
  # be empty (begins with /)
111
  if path != "/" and (components.size < 2 or components[0] != "")
112
    print "Line not parseable (degenerate path): ", line, "\n"
113
    unparseable += 1
114
    next
115
  end
116

  
117
  if components[1] == "hg"
118
    
119
    # path is /hg/project?something or /hg/project/something
120

  
121
    project = components[2].split("?")[0]
122
    if not is_public_project?(project)
123
      next
124
    end
125

  
126
    if components[2] =~ /&roots=00*$/
127
      clones[project] += 1
128
    elsif components[2] =~ /cmd=capabilities/
129
      pulls[project] += 1
130
    elsif components[2] =~ /cmd=unbundle/
131
      pushes[project] += 1
132
    elsif components[3] == "archive"
133
      zips[project] += 1
134
    end
135

  
136
  elsif components[1] == "projects"
137

  
138
    # path is /projects/project or /projects/project/something
139

  
140
    project = components[2]
141
    project = project.split("?")[0] if project
142
    if not is_public_project?(project)
143
      next
144
    end
145

  
146
    hits[project] += 1
147

  
148
  end
149

  
150
  parseable += 1
151
end
152

  
153
# Each clone is also a pull; deduct it from the pulls hash, because we
154
# want that to contain only non-clone pulls
155

  
156
clones.keys.each do |project|
157
  pulls[project] -= 1
158
end
159

  
160
print parseable, " parseable\n"
161
print unparseable, " unparseable\n"
162

  
163

  
164
print "\nMercurial clones:\n"
165
print_stats clones
166

  
167
print "\nMercurial pulls (excluding clones):\n"
168
print_stats pulls
169

  
170
print "\nMercurial pushes:\n"
171
print_stats pushes
172

  
173
print "\nMercurial archive (zip file) downloads:\n"
174
print_stats zips
175

  
176
print "\nProject page hits (excluding crawlers):\n"
177
print_stats hits
178

  
179

  
extra/soundsoftware/get-statistics.rb
1
# this script will get stats from the repo and print them to stdout
2

  
3
# USAGE: 
4

  
5
# ./script/runner -e production extra/soundsoftware/get-statistics.rb 
6
#
7

  
8
d1 = Date.parse("20100701") # => 1 Jul 2010
9
d2 = Date.today
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

  
21
def months_between(d1, d2)
22
   months = []
23
   start_date = Date.civil(d1.year, d1.month, 1)
24
   end_date = Date.civil(d2.year, d2.month, 1)
25

  
26
   raise ArgumentError unless d1 <= d2
27

  
28
   while (start_date < end_date)
29
     months << start_date
30
     start_date = start_date >>1
31
   end
32

  
33
   months << end_date
34
end
35

  
36
def weeks_between(d1, d2)
37
   weeks = []
38
   start_date = Date.civil(d1.year, d1.month, d1.day)
39
   end_date = Date.civil(d2.year, d2.month, d2.day)
40

  
41
   raise ArgumentError unless d1 <= d2
42

  
43
   while (start_date < end_date)
44
     weeks << start_date
45
     start_date = start_date + 2.week
46
   end
47

  
48
   weeks << end_date
49
end
50

  
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
84

  
85

  
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
132

  
133
end
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
142

  
143

  
144
# get_user_projects_ratios()
145
# get_user_project_evol_stats()
146

  
147
get_project_status()
public/help/wiki_syntax.html
44 44
<tr><th><img src="../images/jstoolbar/bt_h2.png" style="border: 1px solid #bbb;" alt="Heading 2" /></th><td>h2. Title 2</td><td><h2>Title 2</h2></td></tr>
45 45
<tr><th><img src="../images/jstoolbar/bt_h3.png" style="border: 1px solid #bbb;" alt="Heading 3" /></th><td>h3. Title 3</td><td><h3>Title 3</h3></td></tr>
46 46

  
47
<tr><th colspan="3">Table of contents</th></tr>
48
<tr><th></th><td><pre>{{toc}}</pre></td><td>Left-aligned table of contents</td></tr>
49
<tr><th></th><td><pre>{{>toc}}</pre></td><td>Right-aligned table of contents</td></tr>
50

  
47 51
<tr><th colspan="3">Links</th></tr>
48 52
<tr><th></th><td>http://foo.bar</td><td><a href="#">http://foo.bar</a></td></tr>
49 53
<tr><th></th><td>"Foo":http://foo.bar</td><td><a href="#">Foo</a></td></tr>
50 54

  
51
<tr><th colspan="3">Redmine links</th></tr>
55
<tr><th colspan="3">Magic links</th></tr>
52 56
<tr><th><img src="../images/jstoolbar/bt_link.png" style="border: 1px solid #bbb;" alt="Link to a Wiki page" /></th><td>[[Wiki page]]</td><td><a href="#">Wiki page</a></td></tr>
53 57
<tr><th></th><td>Issue #12</td><td>Issue <a href="#">#12</a></td></tr>
54 58
<tr><th></th><td>Revision r43</td><td>Revision <a href="#">r43</a></td></tr>
public/stylesheets/application.css
5 5
h1 {margin:0; padding:0; font-size: 24px;}
6 6
h2, .wiki h1 {font-size: 20px;padding: 2px 10px 1px 0px;margin: 0 0 10px 0; border-bottom: 1px solid #bbbbbb; color: #444;}
7 7
h3, .wiki h2 {font-size: 16px;padding: 2px 10px 1px 0px;margin: 0 0 10px 0; border-bottom: 1px solid #bbbbbb; color: #444;}
8
h4, .wiki h3 {font-size: 13px;padding: 2px 10px 1px 0px;margin-bottom: 5px; border-bottom: 1px dotted #bbbbbb; color: #444;}
8
h4, .wiki h3 {font-size: 14px;padding: 2px 10px 1px 0px;margin-bottom: 5px; border-bottom: 1px dotted #bbbbbb; color: #444;}
9 9

  
10 10
/***** Layout *****/
11 11
#wrapper {background: white;}
......
24 24

  
25 25
#account {float:right;}
26 26

  
27
#header {height:5.3em;margin:0;background-color:#507AAA;color:#f8f8f8; padding: 4px 8px 0px 6px; position:relative;}
27
#header {height:68px;margin:0;background-color:#507AAA;color:#f8f8f8; padding: 4px 8px 0px 6px; position:relative;}
28 28
#header a {color:#f8f8f8;}
29 29
#header h1 a.ancestor { font-size: 80%; }
30 30

  
31 31
#project-search-jump {float:right; }
32 32

  
33 33

  
34
#main-menu {position: absolute;  bottom: 0px;  left:6px; margin-right: -500px;}
34
#main-menu {position: absolute;  bottom: 0px;  left:8px; margin-right: -500px;}
35 35
#main-menu ul {margin: 0;  padding: 0;}
36 36
#main-menu li {
37 37
  float:left;
......
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;}
......
254 256
.highlight.token-3 { background-color: #aaf;}
255 257

  
256 258
.box{
257
padding:6px;
258
margin-bottom: 10px;
259
background-color:#f6f6f6;
260
color:#505050;
261
line-height:1.5em;
262
border: 1px solid #e4e4e4;
259
    padding:6px;
260
    margin-bottom: 10px;
261
    background-color:#f6f6f6;
262
    color:#505050;
263
    line-height:1.5em;
264
    border: 1px solid #e4e4e4;
263 265
}
264 266

  
265 267
.box h4 {
266
margin-top: 0;
267
padding-top: 0;
268
    margin-top: 0;
269
    padding-top: 0;
268 270
}
269 271

  
270 272
div.square {
......
342 344
div#members dt .email { color: #777; font-size: 80%; }
343 345
div#members dd .roles { font-style: italic; }
344 346

  
347
div#memberbox h3 { 
348
  background: url(../images/group.png) no-repeat 0% 50%; 
349
  padding-left: 20px;
350
}
351
div#memberbox p { 
352
  padding-left: 20px;
353
  margin-left: 0;
354
}
355

  
356
div.issues ul {
357
  padding-left: 20px;
358
  margin-left: 0;
359
  list-style-type: none;
360
}
361
div.issues p {
362
  padding-left: 20px;
363
  margin-left: 0;
364
}
365

  
345 366
.projects .latest .title { margin-right: 0.5em; }
346 367
.tipoftheday .tip { margin-left: 2em; margin-top: 0.5em; }
347 368

  
......
500 521
.summary {font-style: italic;}
501 522

  
502 523
#attachments_fields input[type=text] {margin-left: 8px; }
503
#attachments_fields span {display:block; white-space:nowrap;}
524
/*#attachments_fields span {display:block; white-space:nowrap;} */
504 525
#attachments_fields img {vertical-align: middle;}
505 526

  
506 527
div.attachments { margin-top: 12px; }
507 528
div.attachments p { margin:4px 0 2px 0; }
508 529
div.attachments img { vertical-align: middle; }
509
div.attachments span.author { font-size: 0.9em; color: #888; }
530
div.attachments span.author { font-size: 0.9em; color: #888; font-style: italic; padding-left: 4px }
531
div.attachments span.size_and_count { font-size: 0.9em; color: #888; padding-left: 4px; }
510 532

  
511 533
p.other-formats { text-align: right; font-size:0.9em; color: #666; }
512 534
.other-formats span + span:before { content: "| "; }
public/themes/soundsoftware/stylesheets/application.css
34 34

  
35 35
h2,h3,h4,.wiki h1 {
36 36
  color: #3e442c;
37
  font-weight: bold;
37
/*  font-weight: bold; */
38 38
}
39 39

  
40 40
.wiki h2,.wiki h3,.wiki h4 {
......
119 119
#quick-search { margin-right: 6px; margin-top: 1em; color: #000; }
120 120
#project-jump-box { float: right;  margin-right: 6px; margin-top: 5px; color: #000; }
121 121
#project-ancestors-title {
122
    margin-bottom: 0px;
122
    margin-bottom: -6px;
123 123
    margin-left: 12px;
124 124
    margin-top: 6px;
125 125
}
126 126

  
127
#main-menu { position: absolute; top: 100px; /* background-color: #be5700; */ left: 0; border-top: 0; width: 100%;/* height: 1.82em; */ padding: 0; margin: 0; border: 0; }
127
#main-menu { position: absolute; top: 100px; /* background-color: #be5700; */ left: 2px; border-top: 0; width: 100%;/* height: 1.82em; */ padding: 0; margin: 0; border: 0; }
128 128
#main-menu li { margin: 0; padding: 0; }
129
#main-menu li a { background-color: #fdfbf5; color: #be5700; border-right: 1px solid #a9b680; font-size: 97%; padding: 0em 8px 0.2em 10px; font-weight: normal; }
129
#main-menu li a { background-color: #fdfbf5; color: #be5700; border-right: 1px solid #a9b680; font-size: 97%; padding: 0em 8px 0em 10px; font-weight: normal; }
130 130
#main-menu li:last-child a { border-right: 0; }
131 131
#main-menu li a:hover { background-color: #fdfbf5; color: #be5700; text-decoration: underline; }
132 132
#main-menu li a.selected, #main-menu li a.selected:hover { background-color: #fdfbf5; color: #3e442c; }
......
145 145
h2, h3, h4, .wiki h1, .wiki h2, .wiki h3 { border-bottom: 0px; }
146 146
/*h2, .wiki h1 { letter-spacing:-1px; }
147 147
*/
148
h4 { border-bottom: dotted 1px #c0c0c0; }
148
/* h4 { border-bottom: dotted 1px #c0c0c0; } */
149

  
150
.wiki p, .wiki li { margin-left: 30px; margin-right: 3em; }
151

  
152
.repository-info .wiki p { margin-left: 0 }
149 153

  
150 154
div.issue { background: #fdfaf0; border: 1px solid #a9b680; border-left: 4px solid #a9b680; }
151 155

  
public/themes/soundsoftware/stylesheets/fonts-generic.css
1
@import url(fonts.css);
1
@import url(fonts.css?2);
2 2

  
3
h1, #project-ancestors-title {
4
  font-family: GilliusADFNo2, 'Gill Sans', Tahoma, sans-serif;
5
  font-weight: normal;
3
h1, #project-ancestors-title, #top-menu a {
4
  font-family: Insider, 'Gill Sans', Tahoma, sans-serif;
5
  font-weight: bold;
6 6
}    
7 7

  
8
body,p,h2,h3,h4,li,table,.wiki h1,.embedded h1 { 
9
  font-family: DroidSans, 'Liberation Sans', tahoma, verdana, sans-serif; 
8
#top-menu div, #top-menu li {
9
  font-size: 12px;
10
}
11

  
12
body,p,li,table { 
13
  font-family: Insider, DroidSans, 'Liberation Sans', tahoma, verdana, sans-serif; 
14
  font-size: 14px;
15
  line-height: 1.34;
16
  font-weight: normal;
17
}
18

  
19
h2,h3,h4,.wiki h1,.embedded h1 { 
20
  font-family: Insider, DroidSans, 'Liberation Sans', tahoma, verdana, sans-serif; 
21
  font-weight: bold;
10 22
  line-height: 1.34;
11 23
}
12 24

  
public/themes/soundsoftware/stylesheets/fonts-mac.css
1
@import url(fonts.css);
1
@import url(fonts.css?2);
2 2

  
3
h1, #project-ancestors-title {
4
  font-family: GilliusADFNo2, 'Gill Sans', Tahoma, sans-serif;
5
  font-weight: normal;
3
h1, #project-ancestors-title, #top-menu a {
4
  font-family: Insider, "Lucida Grande", sans-serif;
5
  font-weight: bold;
6 6
}    
7 7

  
8
body,p,h2,h3,h4,li,table,.wiki h1,.embedded h1 { 
9
  font-family: 'Lucida Grande', 'Lucida Sans Unicode', DroidSans, 'Liberation Sans', tahoma, verdana, sans-serif; 
8
#top-menu div, #top-menu li {
9
  font-size: 12px;
10
}
11

  
12
body,p,li,table { 
13
  font-family: Insider, "Lucida Grande", sans-serif;
14
  font-size: 14px;
15
  line-height: 1.34;
16
  font-weight: normal;
17
}
18

  
19
h2,h3,h4,.wiki h1,.embedded h1 { 
20
  font-family: Insider, "Lucida Grande", sans-serif;
21
  font-weight: bold;
10 22
  line-height: 1.34;
11 23
}
24

  
public/themes/soundsoftware/stylesheets/fonts-ms.css
1
@import url(fonts.css);
1
@import url(fonts.css?2);
2 2

  
3
h1, #project-ancestors-title {
4
  font-family: GilliusADFNo2, 'Gill Sans', Tahoma, sans-serif;
3
/* IE likes us to separate out normal & bold into different fonts
4
   rather than use the selectors on the same font */
5

  
6
h1, #project-ancestors-title, #top-menu a {
7
  font-family: Insider-Medium, Tahoma, sans-serif;
5 8
  font-weight: normal;
6 9
}    
7 10

  
8
body,p,h2,h3,h4,li,table,.wiki h1,.embedded h1 { 
9
  font-family: Calibri, DroidSans, 'Liberation Sans', tahoma, verdana, sans-serif; 
11
#top-menu div, #top-menu li {
12
  font-size: 12px;
13
}
14

  
15
body,p,li,table { 
16
  font-family: Insider-Regular, tahoma, verdana, sans-serif; 
17
  font-size: 14px;
18
  line-height: 1.34;
19
  font-weight: normal;
20
}
21

  
22
h2,h3,h4,.wiki h1,.embedded h1 { 
23
  font-family: Insider-Medium, tahoma, verdana, sans-serif; 
24
  font-weight: normal;
10 25
  line-height: 1.34;
11 26
}
public/themes/soundsoftware/stylesheets/fonts.css
1

  
2
/* Font pack generated by FontSquirrel */
3 1

  
4 2
@font-face {
5
	font-family: 'GilliusADFNo2';
6
	src: url('fonts/gilliusadfno2-bolditalic-webfont.eot');
7
	src: local('☺'), url('fonts/gilliusadfno2-bolditalic-webfont.woff') format('woff'), url('fonts/gilliusadfno2-bolditalic-webfont.ttf') format('truetype'), url('fonts/GilliusADFNo2-BoldItalic.otf') format('opentype'), url('fonts/gilliusadfno2-bolditalic-webfont.svg#webfontLmhvPwzc') format('svg');
8
	font-weight: bold;
9
	font-style: italic;
3
    font-family: 'Insider';
4
    font-weight: bold;
5
    font-style: normal;
6
    src: url('fonts/24BC0E_0_0.eot');
7
    src: url('fonts/24BC0E_0_0.eot?#iefix') format('embedded-opentype'), url('fonts/24BC0E_0_0.woff') format('woff'), url('fonts/24BC0E_0_0.ttf') format('truetype');
8
}
9
 
10
@font-face {
11
    font-family: 'Insider';
12
    font-weight: normal;
13
    font-style: normal;
14
    src: url('fonts/24BC35_0_0.eot');
15
    src: url('fonts/24BC35_0_0.eot?#iefix') format('embedded-opentype'), url('fonts/24BC35_0_0.woff') format('woff'), url('fonts/24BC35_0_0.ttf') format('truetype');
10 16
}
11 17

  
12 18
@font-face {
13
	font-family: 'GilliusADFNo2';
14
	src: url('fonts/gilliusadfno2-italic-webfont.eot');
15
	src: local('☺'), url('fonts/gilliusadfno2-italic-webfont.woff') format('woff'), url('fonts/gilliusadfno2-italic-webfont.ttf') format('truetype'), url('fonts/GilliusADFNo2-Italic.otf') format('opentype'), url('fonts/gilliusadfno2-italic-webfont.svg#webfonteHBtzgS0') format('svg');
16
	font-weight: normal;
17
	font-style: italic;
19
    font-family: 'Insider-Medium';
20
    font-weight: normal;
21
    font-style: normal;
22
    src: url('fonts/24BC0E_0_0.eot');
23
    src: url('fonts/24BC0E_0_0.eot?#iefix') format('embedded-opentype'), url('fonts/24BC0E_0_0.woff') format('woff'), url('fonts/24BC0E_0_0.ttf') format('truetype');
18 24
}
19

  
25
 
20 26
@font-face {
21
	font-family: 'GilliusADFNo2';
22
	src: url('fonts/gilliusadfno2-bold-webfont.eot');
23
	src: local('☺'), url('fonts/gilliusadfno2-bold-webfont.woff') format('woff'), url('fonts/gilliusadfno2-bold-webfont.ttf') format('truetype'), url('fonts/GilliusADFNo2-Bold.otf') format('opentype'), url('fonts/gilliusadfno2-bold-webfont.svg#webfontntXmQMqk') format('svg');
24
	font-weight: bold;
25
	font-style: normal;
27
    font-family: 'Insider-Regular';
28
    font-weight: normal;
29
    font-style: normal;
30
    src: url('fonts/24BC35_0_0.eot');
31
    src: url('fonts/24BC35_0_0.eot?#iefix') format('embedded-opentype'), url('fonts/24BC35_0_0.woff') format('woff'), url('fonts/24BC35_0_0.ttf') format('truetype');
26 32
}
27

  
28
@font-face {
29
	font-family: 'GilliusADFNo2';
30
	src: url('fonts/gilliusadfno2-regular-webfont.eot');
31
	src: local('☺'), url('fonts/gilliusadfno2-regular-webfont.woff') format('woff'), url('fonts/gilliusadfno2-regular-webfont.ttf') format('truetype'), url('fonts/GilliusADFNo2-Regular.otf') format('opentype'), url('fonts/gilliusadfno2-regular-webfont.svg#webfontvJUiAdi3') format('svg');
32
	font-weight: normal;
33
	font-style: normal;
34
}
35

  
36
@font-face {
37
	font-family: 'DroidSans';
38
	src: url('fonts/DroidSans-webfont.eot');
39
	src: local('☺'), url('fonts/DroidSans-webfont.woff') format('woff'), url('fonts/DroidSans-webfont.ttf') format('truetype'), url('fonts/DroidSans-webfont.svg#webfontKYIQSBQk') format('svg');
40
	font-weight: normal;
41
	font-style: normal;
42
}
43

  
44
@font-face {
45
	font-family: 'DroidSans';
46
	src: url('fonts/DroidSans-Bold-webfont.eot');
47
	src: local('☺'), url('fonts/DroidSans-Bold-webfont.woff') format('woff'), url('fonts/DroidSans-Bold-webfont.ttf') format('truetype'), url('fonts/DroidSans-Bold-webfont.svg#webfontljpTCDjw') format('svg');
48
	font-weight: bold;
49
	font-style: normal;
50
}
51

  
vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb
3 3

  
4 4
class PublicationsController < ApplicationController
5 5
  unloadable
6
  
6

  
7 7
  model_object Publication
8
  before_filter :find_model_object, :except => [:new, :create, :index, :get_bibtex_required_fields, :autocomplete_for_project, :add_author, :sort_author_order, :autocomplete_for_author, :get_user_info ]  
8
  before_filter :find_model_object, :except => [:new, :create, :index, :get_bibtex_required_fields, :autocomplete_for_project, :add_author, :sort_author_order, :autocomplete_for_author, :get_user_info ]
9 9
  before_filter :find_project_by_project_id, :authorize, :only => [ :edit, :new, :update, :create ]
10
    
10

  
11 11
  def new
12 12
    find_project_by_project_id
13 13
    @publication = Publication.new
14
    
14

  
15 15
    # we'll always want a new publication to have its bibtex entry
16 16
    @publication.build_bibtex_entry
17
    
17

  
18 18
    # and at least one author
19
    # @publication.authorships.build.build_author        
19
    # @publication.authorships.build.build_author
20 20
    @author_options = [["#{User.current.name} (@#{User.current.mail.partition('@')[2]})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]]
21

  
22

  
23 21
  end
24 22

  
25
  def create    
23
  def create
26 24
    @project = Project.find(params[:project_id])
27 25

  
28 26
    @author_options = []
29 27

  
30 28
    @publication = Publication.new(params[:publication])
31 29
    @publication.projects << @project unless @project.nil?
32
        
33
    if @publication.save 
30

  
31
    if @publication.save
34 32
      @publication.notify_authors_publication_added(@project)
35
      
33

  
36 34
      flash[:notice] = "Successfully created publication."
37 35
      redirect_to :action => :show, :id => @publication, :project_id => @project
38 36
    else
......
52 50

  
53 51
  def new_from_bibfile
54 52
    @publication.current_step = session[:publication_step]
55
    
53

  
56 54
    # contents of the paste text area
57 55
    bibtex_entry = params[:bibtex_entry]
58 56

  
59 57
    # method for creating "pasted" bibtex entries
60 58
    if bibtex_entry
61
      parse_bibtex_list bibtex_entry    
59
      parse_bibtex_list bibtex_entry
62 60
    end
63 61
  end
64 62

  
65 63
  def get_bibtex_required_fields
66 64

  
67 65
    unless params[:value].empty?
68
      fields = BibtexEntryType.fields(params[:value]) 
66
      fields = BibtexEntryType.fields(params[:value])
69 67
    end
70 68

  
71 69
    respond_to do |format|
72 70
      format.js {
73
        render(:update) {|page|       
71
        render(:update) {|page|
74 72
          if params[:value].empty?
75 73
            page << "hideOnLoad();"
76 74
          else
......
78 76
          end
79 77
        }
80 78
      }
81
    
79

  
82 80
    end
83 81
  end
84 82

  
......
92 90
    end
93 91
  end
94 92

  
95
  def edit   
93
  def edit
96 94
    find_project_by_project_id unless params[:project_id].nil?
97
    
95

  
98 96
    @edit_view = true;
99 97
    @publication = Publication.find(params[:id])
100 98
    @selected_bibtex_entry_type_id = @publication.bibtex_entry.entry_type
101 99

  
102
    @author_options = []  
103
    
104
    @bibtype_fields = BibtexEntryType.fields(@selected_bibtex_entry_type_id)    
100
    @author_options = []
101

  
102
    @bibtype_fields = BibtexEntryType.fields(@selected_bibtex_entry_type_id)
105 103
  end
106 104

  
107
  def update    
108
    @publication = Publication.find(params[:id])        
109

  
105
  def update
106
    @publication = Publication.find(params[:id])
110 107
    @author_options = []
111 108

  
112
    logger.error { "INSIDE THE UPDATE ACTION IN THE PUBLICATION CONTROLLER" }
113

  
114 109
    if @publication.update_attributes(params[:publication])
115 110
      flash[:notice] = "Successfully updated Publication."
116 111

  
112
      # expires the previosly cached entries
113
      Rails.cache.delete "publication-#{@publication.id}-ieee"
114
      Rails.cache.delete "publication-#{@publication.id}-bibtex"
115

  
117 116
      if !params[:project_id].nil?
118 117
        redirect_to :action => :show, :id => @publication, :project_id => params[:project_id]
119 118
      else
......
121 120
      end
122 121
    else
123 122
      render :action => 'edit'
124
    end   
123
    end
125 124
  end
126 125

  
126

  
127 127
  def show
128 128
    find_project_by_project_id unless params[:project_id].nil?
129
        
129

  
130 130
    if @publication.nil?
131 131
      @publications = Publication.all
132 132
      render "index", :alert => 'The publication was not found!'
......
142 142
    return authors_entry.split(" and ")
143 143
  end
144 144

  
145
  # parses a list of bibtex 
145
  # parses a list of bibtex
146 146
  def parse_bibtex_list(bibtex_list)
147 147
    bibliography = BibTeX.parse bibtex_list
148 148

  
......
155 155
        create_bibtex_entry d
156 156
      end
157 157
    end
158
  end 
158
  end
159 159

  
160
  def create_bibtex_entry(d)        
160
  def create_bibtex_entry(d)
161 161
    @publication = Publication.new
162
    @bentry = BibtexEntry.new        
162
    @bentry = BibtexEntry.new
163 163
    authors = []
164 164
    institution = ""
165 165
    email = ""
......
177 177
      else
178 178
        @bentry[field] = d[field]
179 179
      end
180
    end 
180
    end
181 181

  
182 182
    @publication.bibtex_entry = @bentry
183 183
    @publication.save
184 184

  
185
    # what is this for??? 
185
    # what is this for???
186 186
    # @created_publications << @publication.id
187 187

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff