# HG changeset patch # User Chris Cannam # Date 1410251693 -3600 # Node ID afce8026aaeb5687a1b138a9f01fccf9cd312273 # Parent 2e8063097240cb3650b6659913d4195e42c5301d# Parent d98d22a98252dcb7c4ffc417728959ad302b3fab Merge from branch "live" diff -r 2e8063097240 -r afce8026aaeb Gemfile --- a/Gemfile Tue Sep 09 09:32:11 2014 +0100 +++ b/Gemfile Tue Sep 09 09:34:53 2014 +0100 @@ -7,6 +7,10 @@ gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby] gem "builder", "3.0.0" +#cc -- CiteProc v1.0.0 broke our citations (CiteProc.process returns nil). +# Until I've managed to work out what's up and fix that... +gem "citeproc", "0.0.6" + # Optional gem for LDAP authentication group :ldap do gem "net-ldap", "~> 0.3.1" diff -r 2e8063097240 -r afce8026aaeb app/controllers/projects_controller.rb --- a/app/controllers/projects_controller.rb Tue Sep 09 09:32:11 2014 +0100 +++ b/app/controllers/projects_controller.rb Tue Sep 09 09:34:53 2014 +0100 @@ -59,7 +59,7 @@ @project_pages = Paginator.new self, @project_count, @limit, params['page'] @offset ||= @project_pages.current.offset @projects = Project.visible_roots.all(:offset => @offset, :limit => @limit, :order => sort_clause) - render :template => 'projects/index.html.erb', :layout => !request.xhr? + render :template => 'projects/index', :layout => !request.xhr? ## Redmine 2.2: # scope = Project @@ -85,7 +85,7 @@ respond_to do |format| format.html { @projects = Project.visible - render :template => 'projects/explore.html.erb', :layout => !request.xhr? + render :template => 'projects/explore', :layout => !request.xhr? } end end diff -r 2e8063097240 -r afce8026aaeb app/helpers/activities_helper.rb --- a/app/helpers/activities_helper.rb Tue Sep 09 09:32:11 2014 +0100 +++ b/app/helpers/activities_helper.rb Tue Sep 09 09:34:53 2014 +0100 @@ -168,7 +168,7 @@ e.event_author unless !e.respond_to?(:event_author) end.compact institutions = authors.map do |a| - if a.respond_to?(:ssamr_user_detail) and !a.ssamr_user_detail.nil? + if a.respond_to?(:ssamr_user_detail) and !a.ssamr_user_detail.nil? and a.ssamr_user_detail.institution_name != "none" a.ssamr_user_detail.institution_name end end diff -r 2e8063097240 -r afce8026aaeb app/helpers/projects_helper.rb --- a/app/helpers/projects_helper.rb Tue Sep 09 09:32:11 2014 +0100 +++ b/app/helpers/projects_helper.rb Tue Sep 09 09:34:53 2014 +0100 @@ -279,7 +279,7 @@ Math.log(1 + nr_downloadables) + Math.log(1 + nr_downloads) + Math.sqrt(nr_members > 1 ? (nr_members - 1) : 0) + - Math.sqrt(nr_publications) + Math.sqrt(nr_publications * 2) end def all_maturity_scores() @@ -291,6 +291,15 @@ phash end + def top_level_maturity_scores() + phash = Hash.new + pp = Project.visible_roots(User.anonymous) + pp.each do |p| + phash[p] = score_maturity p + end + phash + end + def mature_projects(count) phash = all_maturity_scores scores = phash.values.sort @@ -298,4 +307,29 @@ if threshold == 0 then threshold = 1 end phash.keys.select { |k| phash[k] > threshold }.sample(count) end + + def varied_mature_projects(count) + phash = top_level_maturity_scores + scores = phash.values.sort + threshold = scores[scores.length / 2] + if threshold == 0 then threshold = 1 end + mhash = Hash.new + phash.keys.shuffle.select do |k| + if phash[k] < threshold or k.description == "" then + false + else + u = k.users_by_role + mgrs = [] + u.keys.each do |r| + if r.allowed_to?(:edit_project) + u[r].each { |m| mgrs << m } + end + end + novel = (mhash.keys & mgrs).empty? + mgrs.each { |m| mhash[m] = 1 } + novel and not mgrs.empty? + end + end.sample(count) + end + end diff -r 2e8063097240 -r afce8026aaeb app/models/project.rb --- a/app/models/project.rb Tue Sep 09 09:32:11 2014 +0100 +++ b/app/models/project.rb Tue Sep 09 09:34:53 2014 +0100 @@ -163,8 +163,8 @@ allowed_to_condition(user, :view_project, options) end - def self.root_visible_by(user=nil) - return "#{Project.table_name}.parent_id IS NULL AND " + visible_condition(user) + def self.root_visible_by(user, options={}) + return "#{Project.table_name}.parent_id IS NULL AND " + visible_condition(user, options) end # Returns a SQL conditions string used to find all projects for which +user+ has the given +permission+ diff -r 2e8063097240 -r afce8026aaeb app/views/activities/_busy.html.erb --- a/app/views/activities/_busy.html.erb Tue Sep 09 09:32:11 2014 +0100 +++ b/app/views/activities/_busy.html.erb Tue Sep 09 09:34:53 2014 +0100 @@ -13,7 +13,7 @@
{{location}}
.