changeset 1074:b98e55985cb7 luisf

Merge
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Wed, 21 Nov 2012 16:04:55 +0000
parents 7f360105e175 (current diff) 3af6f66496a5 (diff)
children 2cc9845228b3 413d1d9c3efa
files
diffstat 11 files changed, 196 insertions(+), 204 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Tue Nov 20 10:36:09 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Wed Nov 21 16:04:55 2012 +0000
@@ -5,7 +5,7 @@
   unloadable
 
   model_object Publication
-  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 ]  
+  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 ]
   before_filter :find_project_by_project_id, :authorize, :only => [ :edit, :new, :update, :create ]
 
   def new
@@ -16,13 +16,11 @@
     @publication.build_bibtex_entry
 
     # and at least one author
-    # @publication.authorships.build.build_author        
+    # @publication.authorships.build.build_author
     @author_options = [["#{User.current.name} (@#{User.current.mail.partition('@')[2]})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]]
-
-
   end
 
-  def create    
+  def create
     @project = Project.find(params[:project_id])
 
     @author_options = []
@@ -30,7 +28,7 @@
     @publication = Publication.new(params[:publication])
     @publication.projects << @project unless @project.nil?
 
-    if @publication.save 
+    if @publication.save
       @publication.notify_authors_publication_added(@project)
 
       flash[:notice] = "Successfully created publication."
@@ -58,19 +56,19 @@
 
     # method for creating "pasted" bibtex entries
     if bibtex_entry
-      parse_bibtex_list bibtex_entry    
+      parse_bibtex_list bibtex_entry
     end
   end
 
   def get_bibtex_required_fields
 
     unless params[:value].empty?
-      fields = BibtexEntryType.fields(params[:value]) 
+      fields = BibtexEntryType.fields(params[:value])
     end
 
     respond_to do |format|
       format.js {
-        render(:update) {|page|       
+        render(:update) {|page|
           if params[:value].empty?
             page << "hideOnLoad();"
           else
@@ -92,28 +90,29 @@
     end
   end
 
-  def edit   
+  def edit
     find_project_by_project_id unless params[:project_id].nil?
 
     @edit_view = true;
     @publication = Publication.find(params[:id])
     @selected_bibtex_entry_type_id = @publication.bibtex_entry.entry_type
 
-    @author_options = []  
+    @author_options = []
 
-    @bibtype_fields = BibtexEntryType.fields(@selected_bibtex_entry_type_id)    
+    @bibtype_fields = BibtexEntryType.fields(@selected_bibtex_entry_type_id)
   end
 
-  def update    
-    @publication = Publication.find(params[:id])        
-
+  def update
+    @publication = Publication.find(params[:id])
     @author_options = []
 
-    logger.error { "INSIDE THE UPDATE ACTION IN THE PUBLICATION CONTROLLER" }
-
     if @publication.update_attributes(params[:publication])
       flash[:notice] = "Successfully updated Publication."
 
+      # expires the previosly cached entries
+      Rails.cache.delete "publication-#{@publication.id}-ieee"
+      Rails.cache.delete "publication-#{@publication.id}-bibtex"
+
       if !params[:project_id].nil?
         redirect_to :action => :show, :id => @publication, :project_id => params[:project_id]
       else
@@ -121,7 +120,7 @@
       end
     else
       render :action => 'edit'
-    end   
+    end
   end
 
 
@@ -143,7 +142,7 @@
     return authors_entry.split(" and ")
   end
 
-  # parses a list of bibtex 
+  # parses a list of bibtex
   def parse_bibtex_list(bibtex_list)
     bibliography = BibTeX.parse bibtex_list
 
@@ -156,11 +155,11 @@
         create_bibtex_entry d
       end
     end
-  end 
+  end
 
-  def create_bibtex_entry(d)        
+  def create_bibtex_entry(d)
     @publication = Publication.new
-    @bentry = BibtexEntry.new        
+    @bentry = BibtexEntry.new
     authors = []
     institution = ""
     email = ""
@@ -178,17 +177,17 @@
       else
         @bentry[field] = d[field]
       end
-    end 
+    end
 
     @publication.bibtex_entry = @bentry
     @publication.save
 
-    # what is this for??? 
+    # what is this for???
     # @created_publications << @publication.id
 
     # need to save all authors
-    #   and establish the author-publication association 
-    #   via the authorships table 
+    #   and establish the author-publication association
+    #   via the authorships table
     authors.each_with_index.map do |authorname, idx|
       author = Author.new(:name => authorname)
       if author.save!
@@ -220,12 +219,12 @@
   def autocomplete_for_project
     @publication = Publication.find(params[:id])
 
-    @projects = Project.active.like(params[:q]).find(:all, :limit => 100) - @publication.projects            
+    @projects = Project.active.like(params[:q]).find(:all, :limit => 100) - @publication.projects
     logger.debug "Query for \"#{params[:q]}\" returned \"#{@projects.size}\" results"
     render :layout => false
   end
 
-  def autocomplete_for_author    
+  def autocomplete_for_author
     @results = []
 
     object_id = params[:object_id]
@@ -239,8 +238,8 @@
 
     @results = users_list
 
-    # TODO: can be optimized…    
-    authorships_list.each do |authorship|      
+    # TODO: can be optimized…
+    authorships_list.each do |authorship|
       flag = true
 
       users_list.each do |user|
@@ -254,7 +253,7 @@
       @results << authorship if flag
     end
 
-    render :layout => false    
+    render :layout => false
   end
 
   def get_user_info
@@ -272,7 +271,7 @@
 
     respond_to do |format|
       format.js {
-        render(:update) {|page| 
+        render(:update) {|page|
           page[name_field].value = item.name
           page[email_field].value = item.mail
           page[institution_field].value = item.institution
@@ -294,16 +293,16 @@
   end
 
   def add_project
-    @projects = Project.find(params[:publication][:project_ids])    
+    @projects = Project.find(params[:publication][:project_ids])
     @publication.projects << @projects
-    @project = Project.find(params[:project_id])    
+    @project = Project.find(params[:project_id])
 
-    # TODO luisf should also respond to HTML??? 
+    # TODO luisf should also respond to HTML???
     respond_to do |format|
       format.html { redirect_to :back }
-      format.js { 
-        render(:update) {|page| 
-          page[:add_project_form].reset          
+      format.js {
+        render(:update) {|page|
+          page[:add_project_form].reset
           page.replace_html :list_projects, :partial => 'list_projects'
         }
       }
@@ -320,14 +319,14 @@
         @publication.projects.delete proj if request.post?
       end
     else
-      logger.error { "Cannot remove project from publication list" }      
+      logger.error { "Cannot remove project from publication list" }
     end
 
     logger.error { "CURRENT project name#{proj.name} and wanna delete #{@project.name}" }
 
-    render(:update) {|page| 
+    render(:update) {|page|
       page.replace_html "list_projects", :partial => 'list_projects', :id  => @publication
-    }    
+    }
   end
 
   def destroy
--- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb	Tue Nov 20 10:36:09 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb	Wed Nov 21 16:04:55 2012 +0000
@@ -12,20 +12,20 @@
   def projects_check_box_tags(name, projects)
     s = ''
     projects.sort.each do |project|
-      if User.current.allowed_to?(:edit_publication, project) 
+      if User.current.allowed_to?(:edit_publication, project)
         s << "<label>#{ check_box_tag name, project.id, false } #{link_to_project project}</label>\n"
         s << '<br />'
       end
     end
 
-    s 
+    s
   end
-  
+
   def choose_author_link(object_name, items)
     # called by autocomplete_for_author (publications' action/view)
     # creates the select list based on the results array
     # results is an array with both Users and Authorships objects
-        
+
     @author_options = []
     @results.each do |result|
       email_bit = result.mail.partition('@')[2]
@@ -34,26 +34,26 @@
       end
       @author_options << ["#{result.name} #{email_bit}", "#{result.class.to_s}_#{result.id.to_s}"]
     end
-    
+
    if @results.size > 0
      s = select_tag( form_tag_name(object_name, :author_search_results), options_for_select(@author_options), { :id => form_tag_id(object_name, :author_search_results), :size => 3} )
      s << observe_field( form_tag_id(object_name, :author_search_results), :on => 'click', :function => "alert('Element changed')", :with => 'q')
    else
      s = "<em>No Authors found that match your search… sorry!</em>"
-   end      
+   end
   end
 
   def link_to_remove_fields(name, f)
     f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)", :class => 'icon icon-del')
   end
-    
+
   def link_to_add_author_fields(name, f, association, action)
     new_object = f.object.class.reflect_on_association(association).klass.new
     fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
       render(association.to_s.singularize + "_fields", :f => builder)
-    end    
+    end
     link_to_function(name, h("add_author_fields(this, '#{association}', '#{escape_javascript(fields)}', '#{action}')"), { :class => 'icon icon-add', :id => "add_another_author" })
-  end  
+  end
 
   def sanitized_object_name(object_name)
     object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/,"_").sub(/_$/,"")
@@ -62,75 +62,77 @@
   def sanitized_method_name(method_name)
     method_name.sub(/\?$/, "")
   end
-  
+
   def form_tag_name(object_name, method_name)
       str = "#{object_name.to_s}[#{sanitized_method_name(method_name.to_s)}]"
-      str.to_sym 
+      str.to_sym
   end
-  
-  def form_tag_id(object_name, method_name)    
+
+  def form_tag_id(object_name, method_name)
     str = "#{sanitized_object_name(object_name.to_s)}_#{sanitized_method_name(method_name.to_s)}"
     str.to_sym
   end
-  
+
   def form_object_id(object_name)
     str = object_name.split("\[").last().gsub("\]","")
     str.to_sym
   end
 
-  def render_authorships_list(publication)   
+  def render_authorships_list(publication)
     s = '<p>'
-    
+
     publication.authorships.each do |authorship|
       s << link_to_authorship(authorship)
       s << "<br /><em>#{authorship.institution}</em></p>"
-    end    
+    end
 
-    s   
+    s
   end
-  
-  def render_projects_list(publication, show_delete_icon)    
+
+  def render_projects_list(publication, show_delete_icon)
     s= ""
-    
+
     publication.projects.visible.each do |proj|
       s << link_to_project(proj, {}, :class => 'publication_project')
-    
-      if show_delete_icon  
+
+      if show_delete_icon
         if User.current.allowed_to?(:edit_publication, @project)
           if @project == proj
             # todo: move this message to yml file
             confirm_msg = 'Are you sure you want to remove the current project from this publication\'s projects list?'
           else
             confirm_msg = false
-          end 
-          
-          s << link_to_remote(l(:button_delete), { :url => { :controller => 'publications', :action => 'remove_project', :id => publication, :remove_project_id => proj,  :project_id => @project }, :method => :post, :confirm => confirm_msg }, :class => 'icon icon-del') 
+          end
+
+          s << link_to_remote(l(:button_delete), { :url => { :controller => 'publications', :action => 'remove_project', :id => publication, :remove_project_id => proj,  :project_id => @project }, :method => :post, :confirm => confirm_msg }, :class => 'icon icon-del')
         end
       end
-      
-      s << "<br />"      
-    end    
 
-    s  
+      s << "<br />"
+    end
+
+    s
   end
-  
-  def show_cite_proc_entry(publication)
-    # code that should be moved either to the model or to the controller?
-    
-    publication.print_entry(:ieee)
+
+  def print_ieee_format(publication)
+    Rails.cache.fetch("publication-#{publication.id}-ieee") do
+      publication.print_entry(:ieee)
+    end
   end
-  
-  def print_bibtex_entry(publication)
-    publication.print_entry(:bibtex)
+
+  def print_bibtex_format(publication)
+    Rails.cache.fetch("publication-#{publication.id}-bibtex") do
+      publication.print_entry(:bibtex)
+    end
   end
-    
-  
+
+
   def show_bibtex_fields(bibtex_entry)
     s = ""
     bibtex_entry.attributes.keys.sort.each do |key|
       value = bibtex_entry.attributes[key].to_s
       next if key == 'id' or key == 'publication_id' or value == ""
-      s << "<h4>" + l("field_#{key}") + "</h4>" 
+      s << "<h4>" + l("field_#{key}") + "</h4>"
       s << "<p>"
       if key == "entry_type"
         s << bibtex_entry.entry_type_label
@@ -140,6 +142,6 @@
       s << "</p>"
     end
     s
-  end 
+  end
 end
 
--- a/vendor/plugins/redmine_bibliography/app/models/publication.rb	Tue Nov 20 10:36:09 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb	Wed Nov 21 16:04:55 2012 +0000
@@ -2,10 +2,10 @@
 
 class Publication < ActiveRecord::Base
   unloadable
-  
+
   has_many :authorships, :dependent => :destroy, :order => "auth_order ASC"
   has_many :authors, :through => :authorships, :uniq => true
-  
+
   has_one :bibtex_entry, :dependent => :destroy
 
   validates_presence_of :title
@@ -14,9 +14,9 @@
   accepts_nested_attributes_for :authorships
   accepts_nested_attributes_for :authors, :allow_destroy => true
   accepts_nested_attributes_for :bibtex_entry, :allow_destroy => true
-  
+
   has_and_belongs_to_many :projects, :uniq => true
-  
+
   before_save :set_initial_author_order
 
   # Ensure error message uses proper text instead of
@@ -30,62 +30,62 @@
     end
   end
 
-  def notify_authors_publication_added(project)  
+  def notify_authors_publication_added(project)
     self.authors.each do |author|
       Rails.logger.debug { "Sending mail to \"#{self.title}\" publication authors." }
       Mailer.deliver_publication_added(author.user, self, project) unless author.user.nil?
     end
   end
-  
-  def notify_authors_publication_updated(project)  
+
+  def notify_authors_publication_updated(project)
     self.authors.each do |author|
       Rails.logger.debug { "Sending mail to \"#{self.title}\" publication authors." }
       Mailer.deliver_publication_updated(author.user, self, project) unless author.user.nil?
     end
   end
-  
-  
+
+
   def set_initial_author_order
     authorships = self.authorships
-    
+
     logger.debug { "Publication \"#{self.title}\" has #{authorships.size} authors." }
-    
+
     authorships.each_with_index do |authorship, index|
       if authorship.auth_order.nil?
          authorship.auth_order = index
       end
-    end    
+    end
   end
-  
+
   def print_bibtex_author_names
-    # this authors are correctly sorted because the authorships model 
+    # this authors are correctly sorted because the authorships model
     # already outputs the author names ASC by auth_order
     self.authorships.map{|a| a.name_on_paper}.join(' and ')
-  end  
-  
+  end
+
   def print_entry(style)
     bib = BibTeX::Entry.new
 
     bib.author = self.print_bibtex_author_names
     bib.title = self.title
 
-    self.bibtex_entry.attributes.keys.sort.each do |key|      
+    self.bibtex_entry.attributes.keys.sort.each do |key|
       value = self.bibtex_entry.attributes[key].to_s
       next if key == 'id' or key == 'publication_id' or value == ""
 
-      if key == "entry_type"        
+      if key == "entry_type"
         bib.type = BibtexEntryType.find(self.bibtex_entry.entry_type).name
       else
         bib[key.to_sym] = value
-      end               
+      end
     end
-    
+
     if style == :ieee
-      CiteProc.process bib.to_citeproc, :style => :ieee, :format => :html      
-    else 
+      CiteProc.process bib.to_citeproc, :style => :ieee, :format => :html
+    else
       bibtex = bib.to_s :include => :meta_content
       bibtex.strip!
       logger.error { bibtex }
-    end  
+    end
   end
 end
--- a/vendor/plugins/redmine_bibliography/app/views/projects/_bibliography_box.html.erb	Tue Nov 20 10:36:09 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/projects/_bibliography_box.html.erb	Wed Nov 21 16:04:55 2012 +0000
@@ -9,18 +9,18 @@
     <div class="box">
     <h3><%=l(:label_related_publication_plural)%></h3>
 
-     <dl>       
-     <% @project.publications.each do |publication| %>       
+     <dl>
+     <% @project.publications.each do |publication| %>
        <dt>
-          <%= publication.print_entry(:ieee) -%>
+          <%= print_ieee_format(publication) %>
        </dt>
        <dd>
-         <%= link_to("[More Details]", {:controller => :publications, :action => :show, :id => publication.id, :project_id => @project.id}) -%> 
-         
-         <%= link_to_function "[B<small>IB</small>T<sub>E</sub>X]", onclick="toggleBibtex(this)" -%> 
+         <%= link_to("[More Details]", {:controller => :publications, :action => :show, :id => publication.id, :project_id => @project.id}) -%>
+
+         <%= link_to_function "[B<small>IB</small>T<sub>E</sub>X]", onclick="toggleBibtex(this)" -%>
        </dd>
        <dd class="bibtex-textarea collapsed" style="display: none;">
-         <textarea readonly><%= publication.print_entry(:bibtex) -%></textarea>         
+         <textarea readonly> <%= print_bibtex_format(publication) %> </textarea>
        </dd>
    <% end -%>
      </dl>
--- a/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb	Tue Nov 20 10:36:09 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb	Wed Nov 21 16:04:55 2012 +0000
@@ -2,10 +2,10 @@
 
 <div class="box">
   <h3>Publication Info</h3>
-  <p><%= show_cite_proc_entry(@publication)%></p>
+  <p><%= print_ieee_format(@publication)%></p>
 
   <h3>B<small>IB</small>T<sub>E</sub>X Format</h3>
-  <pre><%=h print_bibtex_entry(@publication) %></pre>
+  <pre><%=h print_bibtex_format(@publication) %></pre>
 </div>
 
 <div class="box">
--- a/vendor/plugins/redmine_bibliography/init.rb	Tue Nov 20 10:36:09 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/init.rb	Wed Nov 21 16:04:55 2012 +0000
@@ -4,9 +4,6 @@
 require 'bibtex'
 require 'citeproc'
 
-
-RAILS_DEFAULT_LOGGER.info 'Starting Bibliography Plugin for RedMine'
-
 # Patches to the Redmine core.
 Dispatcher.to_prepare :redmine_model_dependencies do
   require_dependency 'project'
@@ -25,7 +22,9 @@
     Mailer.send(:include, Bibliography::MailerPatch)
   end
 
-
+  unless ProjectsHelper.included_modules.include?(Bibliography::ProjectsHelperPatch)
+    ProjectsHelper.send(:include, Bibliography::ProjectsHelperPatch)
+  end
 end
 
 
@@ -51,5 +50,5 @@
   # extending the Project Menu
   menu :project_menu, :publications, { :controller => 'publications', :action => 'index', :path => nil }, :after => :activity, :param => :project_id, :caption => Proc.new { Setting.plugin_redmine_bibliography['menu'] },
    :if => Proc.new { !Setting.plugin_redmine_bibliography['menu'].blank? }
-    
+
 end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/lib/bibliography/projects_helper_patch.rb	Wed Nov 21 16:04:55 2012 +0000
@@ -0,0 +1,17 @@
+module Bibliography
+  module ProjectsHelperPatch
+
+    def self.included(base) # :nodoc:
+      base.send(:include, InstanceMethods)
+      base.send(:include, PublicationsHelper)
+
+      base.class_eval do
+        unloadable
+      end
+    end
+
+    module InstanceMethods
+    end
+  end
+end
+
--- a/vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb	Tue Nov 20 10:36:09 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb	Wed Nov 21 16:04:55 2012 +0000
@@ -1,16 +1,16 @@
 require_dependency 'user'
 
 module Bibliography
-  module UserAuthorPatch    
+  module UserAuthorPatch
     def self.included(base)
-      base.send(:include, InstanceMethods) 
-      extend ClassMethods     
-          
+      base.send(:include, InstanceMethods)
+      extend ClassMethods
+
     end #self.included
-    
+
     module ClassMethods
-    end  
-    
+    end
+
     module InstanceMethods
 
       def institution
@@ -18,28 +18,28 @@
           institution_name = self.ssamr_user_detail.institution_name
         else
           institution_name = "No Institution Set"
-        end        
-        return institution_name        
+        end
+        return institution_name
       end
 
       def get_author_info
         # TODO: DELETE THIS METHOD??
-        info = { 
+        info = {
           :name_on_paper =>  self.name,
           :email => self.mail,
           :institution => "",
           :author_user_id => self.id,
-          :is_user => "1"                    
+          :is_user => "1"
         }
 
         if not self.ssamr_user_detail.nil?
           info[:institution]  = self.ssamr_user_detail.institution_name
         end
 
-        return info        
+        return info
       end
-                
+
     end #InstanceMethods
-    
+
   end #UserPublicationsPatch
 end #RedmineBibliography
--- a/vendor/plugins/redmine_tags/lib/redmine_tags/patches/project_patch.rb	Tue Nov 20 10:36:09 2012 +0000
+++ b/vendor/plugins/redmine_tags/lib/redmine_tags/patches/project_patch.rb	Wed Nov 21 16:04:55 2012 +0000
@@ -13,38 +13,12 @@
           unloadable
 
           attr_accessor :tag_list
-
           acts_as_taggable
 
         end
       end
 
-      def before_save_with_save_tags()
-#        debugger
-        logger.error { "GONNA SAVE TAG LIST" }
-
-
-#        params[:tag_list]
-        
-        
-        # logger.error { @project.name }
-
-    #    if params && params[:project] && !params[:project][:tag_list].nil?
-    #      old_tags = context[:project].tag_list.to_s
-    #      context[:project].tag_list = params[:project][:tag_list]
-    #      new_tags = context[:project].tag_list.to_s
-    #
-    #      unless (old_tags == new_tags || context[:project].current_journal.blank?)
-    #        context[:project].current_journal.details << JournalDetail.new(:property => 'attr',
-    #                                                                     :prop_key => 'tag_list',
-    #                                                                     :old_value => old_tags,
-    #                                                                     :value => new_tags)
-    #      end
-    #    end
-      end
-      
       module InstanceMethods
-        
       end
 
       module ClassMethods
@@ -64,7 +38,7 @@
           name_like = options[:name_like]
           options = {}
           visible   = ARCondition.new
-                  
+
           visible << ["#{Project.table_name}.is_public = '1'"]
 
           if name_like
@@ -73,7 +47,7 @@
 
           options[:conditions] = visible.conditions
 
-          self.all_tag_counts(options)          
+          self.all_tag_counts(options)
         end
       end
     end
--- a/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb	Tue Nov 20 10:36:09 2012 +0000
+++ b/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb	Wed Nov 21 16:04:55 2012 +0000
@@ -3,11 +3,11 @@
 
 module RedmineTags
   module Patches
-    module ProjectsControllerPatch      
+    module ProjectsControllerPatch
       def self.included(base)
         base.send(:include, InstanceMethods)
-        base.class_eval do          
-          unloadable 
+        base.class_eval do
+          unloadable
           skip_before_filter :authorize, :only => [:set_fieldset_status]
           skip_before_filter :find_project, :only => [:set_fieldset_status]
           before_filter :add_tags_to_project, :only => [:save, :update]
@@ -17,7 +17,7 @@
       end
 
       module InstanceMethods
-                
+
         def add_tags_to_project
 
           if params && params[:project] && !params[:project][:tag_list].nil?
@@ -57,17 +57,17 @@
           else
             @myproj_status = session[:my_projects_fieldset_status]
           end
-                    
+
           if session[:filters_fieldset_status].nil?
             @filter_status = "false"
           else
             @filter_status = session[:filters_fieldset_status]
           end
-          
+
           if params && params[:project] && !params[:project][:tag_list].nil?
             @filter_status = "true"
           end
-                                      
+
         end
 
         # Lists visible projects. Paginator is for top-level projects only
@@ -78,17 +78,17 @@
           get_fieldset_statuses
 
           respond_to do |format|
-            format.html { 
+            format.html {
               paginate_projects
-              
-              @projects = Project.visible_roots.find(@projects, :offset => @offset, :limit => @limit, :order => sort_clause) 
+
+              @projects = Project.visible_roots.find(@projects, :offset => @offset, :limit => @limit, :order => sort_clause)
 
               if User.current.logged?
                 # seems sort_by gives us case-sensitive ordering, which we don't want
                 #          @user_projects = User.current.projects.sort_by(&:name)
                 @user_projects = User.current.projects.all(:order => :name)
               end
-              
+
               render :template => 'projects/index.html.erb', :layout => !request.xhr?
             }
             format.api {
@@ -112,8 +112,8 @@
 
         private
 
-        def filter_projects                  
-          @question = (params[:q] || "").strip     
+        def filter_projects
+          @question = (params[:q] || "").strip
 
           if params.has_key?(:project)
             @tag_list = (params[:project][:tag_list] || "").strip.split(",")
@@ -126,7 +126,7 @@
           else
             @projects = Project.visible_roots.find(Project.visible.search_by_question(@question))
           end
-  
+
           unless @tag_list.empty?
             @tagged_projects_ids = Project.visible.tagged_with(@tag_list).collect{ |project| Project.find(project.id).root }
             @projects = @projects & @tagged_projects_ids
--- a/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb	Tue Nov 20 10:36:09 2012 +0000
+++ b/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb	Wed Nov 21 16:04:55 2012 +0000
@@ -5,12 +5,13 @@
       def self.included(base) # :nodoc:
         base.send(:include, InstanceMethods)
         base.send(:include, TagsHelper)
+
         base.class_eval do
           unloadable
         end
       end
 
-      module InstanceMethods        
+      module InstanceMethods
         # Renders a tree of projects that the current user does not belong
         # to, or of all projects if the current user is not logged in.  The
         # given collection may be a subset of the whole project tree
@@ -19,30 +20,30 @@
         # description, manager(s), creation date, last activity date,
         # general activity level, whether there is anything actually hosted
         # here for the project, etc.
-        def render_project_table_with_filtering(projects, question)          
+        def render_project_table_with_filtering(projects, question)
           custom_fields = ""
           s = ""
           if projects.any?
             tokens = RedmineProjectFiltering.calculate_tokens(question, custom_fields)
-            
+
             s << "<div class='autoscroll'>"
             s << "<table class='list projects'>"
             s << "<thead><tr>"
-        
+
             s << sort_header_tag('name', :caption => l("field_name"))
             s << "<th class='tags'>" << l("tags") << "</th>"
             s << "<th class='managers'>" << l("label_managers") << "</th>"
             s << sort_header_tag('created_on', :default_order => 'desc')
             s << sort_header_tag('updated_on', :default_order => 'desc')
-        
+
             s << "</tr></thead><tbody>"
-        
+
             original_project = @project
-        
+
             projects.each do |project|
               s << render_project_in_table_with_filtering(project, cycle('odd', 'even'), 0, tokens)
             end
-        
+
             s << "</table>"
           else
             s << "\n"
@@ -52,7 +53,7 @@
           s
         end
 
-        def render_project_in_table_with_filtering(project, oddeven, level, tokens)          
+        def render_project_in_table_with_filtering(project, oddeven, level, tokens)
           # set the project environment to please macros.
           @project = project
 
@@ -72,7 +73,7 @@
           s << "<td class='tags' align=top>" << project.tag_counts.collect{ |t| render_project_tag_link(t) }.join(', ') << "</td>"
 
           s << "<td class='managers' align=top>"
-           
+
           u = project.users_by_role
           if u
             u.keys.each do |r|
@@ -91,7 +92,7 @@
           end
 
           s << "</td>"
-          
+
           s << "<td class='created_on' align=top>" << format_date(project.created_on) << "</td>"
           s << "<td class='updated_on' align=top>" << format_date(project.updated_on) << "</td>"
 
@@ -105,9 +106,9 @@
 
           s
         end
-        
-        
-        
+
+
+
         # Renders a tree of projects as a nested set of unordered lists
         # The given collection may be a subset of the whole project tree
         # (eg. some intermediate nodes are private and can not be seen)
@@ -116,7 +117,7 @@
           if projects.any?
             tokens = RedmineProjectFiltering.calculate_tokens(question, custom_fields)
             debugger
-            
+
 
             ancestors = []
             original_project = @project
@@ -128,14 +129,14 @@
               else
                 ancestors.pop
                 s << "</li>"
-                while (ancestors.any? && !project.is_descendant_of?(ancestors.last)) 
+                while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
                   ancestors.pop
                   s << "</ul></li>"
                 end
               end
               classes = (ancestors.empty? ? 'root' : 'child')
               s << "<li class='#{classes}'><div class='#{classes}'>" +
-                link_to( highlight_tokens(project.name, tokens), 
+                link_to( highlight_tokens(project.name, tokens),
                   {:controller => 'projects', :action => 'show', :id => project},
                   :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}"
                 )
@@ -146,7 +147,7 @@
            #    value = value_model.present? ? value_model.value : nil
            #    s << "<li><b>#{field.name.humanize}:</b> #{highlight_tokens(value, tokens)}</li>" if value.present?
            #  end
-              
+
               s << "</ul>"
               s << "<div class='clear'></div>"
               unless project.description.blank?
@@ -163,7 +164,7 @@
           end
           s.join "\n"
         end
-        
+
         # Renders a tree of projects where the current user belongs
         # as a nested set of unordered lists
         # The given collection may be a subset of the whole project tree
@@ -193,9 +194,9 @@
           s
 
         end
-        
-        
-        
+
+
+
 
         def render_my_project_in_hierarchy_with_tags(project)
 
@@ -215,7 +216,7 @@
             else
               s << " <span class='private'>" << l(:field_is_private) << "</span>"
             end
-           
+
             tc = project.tag_counts
             if tc.empty?
               s << " <span class='no-tags'>" << l(:field_no_tags) << "</span>"
@@ -242,15 +243,15 @@
 
         end
 
-        
-        
+
+
         private
-        
+
         # copied from search_helper. This one doesn't escape html or limit the text length
         def highlight_tokens(text, tokens)
           return text unless text && tokens && !tokens.empty?
           re_tokens = tokens.collect {|t| Regexp.escape(t)}
-          regexp = Regexp.new "(#{re_tokens.join('|')})", Regexp::IGNORECASE    
+          regexp = Regexp.new "(#{re_tokens.join('|')})", Regexp::IGNORECASE
           result = ''
           text.split(regexp).each_with_index do |words, i|
             words = words.mb_chars
@@ -263,7 +264,7 @@
           end
           result
         end
-      
+
       end
     end
   end