# HG changeset patch
# User Chris Cannam
# Date 1353520071 0
# Node ID 9b5b4e7970cda174274eeb4fcadd1f99a5b0d7ff
# Parent 7529d85a20ea95e9e84807e2c8828cfe0fde005d# Parent b665182d9dd90f1de04adf414d979e1db65ea516
Merge from branch "cannam"
diff -r 7529d85a20ea -r 9b5b4e7970cd config/environment.rb
--- a/config/environment.rb Thu Nov 15 14:13:10 2012 +0000
+++ b/config/environment.rb Wed Nov 21 17:47:51 2012 +0000
@@ -36,7 +36,10 @@
# Enable page/fragment caching by setting a file-based store
# (remember to create the caching directory and make it readable to the application)
- # config.action_controller.cache_store = :file_store, "#{RAILS_ROOT}/tmp/cache"
+ config.action_controller.cache_store = :file_store, "#{RAILS_ROOT}/tmp/cache"
+
+ # And for direct uses of the cache
+ config.cache_store = :file_store, "#{RAILS_ROOT}/tmp/cache"
# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector
diff -r 7529d85a20ea -r 9b5b4e7970cd vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Thu Nov 15 14:13:10 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Wed Nov 21 17:47:51 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
diff -r 7529d85a20ea -r 9b5b4e7970cd vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb
--- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Thu Nov 15 14:13:10 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Wed Nov 21 17:47:51 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 << "\n"
s << '
'
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 = "No Authors found that match your search… sorry!"
- 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 = '
'
-
+
publication.authorships.each do |authorship|
s << link_to_authorship(authorship)
s << "
#{authorship.institution}
" if key == "entry_type" s << bibtex_entry.entry_type_label @@ -140,6 +142,6 @@ s << "
" end s - end + end end diff -r 7529d85a20ea -r 9b5b4e7970cd vendor/plugins/redmine_bibliography/app/models/publication.rb --- a/vendor/plugins/redmine_bibliography/app/models/publication.rb Thu Nov 15 14:13:10 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb Wed Nov 21 17:47:51 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 diff -r 7529d85a20ea -r 9b5b4e7970cd vendor/plugins/redmine_bibliography/app/views/projects/_bibliography_box.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/projects/_bibliography_box.html.erb Thu Nov 15 14:13:10 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/projects/_bibliography_box.html.erb Wed Nov 21 17:47:51 2012 +0000 @@ -9,18 +9,18 @@
+ <%= f.text_field :doi, :size => 70 %>
+
+ <%= l(:text_doi) %>
+
<%= show_cite_proc_entry(@publication)%>
- +<%= print_ieee_format(@publication)%>
+<%=h print_bibtex_entry(@publication) %>+
<%=h print_bibtex_format(@publication) %>
<%= render :partial => 'list_projects' %>
- + <%- if User.current.allowed_to?(:edit_publication, @project) -%> - <%= render :partial => 'add_project_form' %> + <%= render :partial => 'add_project_form' %> <%- end -%> <% end %> diff -r 7529d85a20ea -r 9b5b4e7970cd vendor/plugins/redmine_bibliography/config/locales/en.yml --- a/vendor/plugins/redmine_bibliography/config/locales/en.yml Thu Nov 15 14:13:10 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/config/locales/en.yml Wed Nov 21 17:47:51 2012 +0000 @@ -12,8 +12,7 @@ label_my_publications_box: "My Publications" view_all_publications: "View All Project's Publications" publications: Publications - - + identify_author_question: Is the right person selected above? identify_author_yes: "Yes" identify_author_correct: "Yes, but I need to correct some details below" @@ -25,24 +24,25 @@ label_all_publications_for_project: Publications associated with %{project} label_authors_show: "Authorships associated with this author" label_authors_index: "List of authors" - + field_authorship_publication_title: "Publication" field_authorship_name: "Name on Paper" field_authorship_email: "Email" field_authorship_institution: "Institution" - + field_external_url: "External URL" + field_doi: "DOI" field_publication_title: Title field_publication_authors: Authors field_publication_projects: "Associated projects" field_author_name: Author field_author_user: User Name field_author_username: "Associated user" - field_author_publications: "Publications by this Author" + field_author_publications: "Publications by this Author" field_identify_author_yes: "Yes" field_identify_author_correct: "Corrections" field_identify_author_no: "No" - + label_author_is_me: "(I am this author)" label_add_me_as_author: "Add me as an author" label_add_an_author: "Add an author" @@ -54,7 +54,7 @@ label_author_information: "Author Information" remove_author: "Remove this author" - + label_publication_plural: "Publications" label_related_publication_plural: "Related publications" label_publication_new: "Create New Publication" @@ -67,22 +67,23 @@ label_publication_project_index: "Projects associated with this publication" label_publication_index: "View all publications" label_publication_other_details: "Details" - + text_external_url: "Link to the publication or to an external page about it." + text_doi: "DOI (Digital Object Identifier)." text_author_name_on_paper: "Author's name as it appears on the paper." text_author_institution: "Author's institution as on the paper." text_author_email: "Author's email address as on the paper." - + text_author_search: "Search existing authors" - + # authorships model field_institution: "Institution" - field_name_on_paper: "Name" + field_name_on_paper: "Name" field_email: "Email Address" - + # bibtex_entries model field_entry_type: "Publication Type" - field_id: "id" + field_id: "id" field_publication_id: "Publication_id" field_address: "Address" field_annote: "Annote" @@ -122,7 +123,7 @@ field_bibtex_proceedings: Conference proceedings field_bibtex_techreport: Technical report field_bibtex_unpublished: Unpublished - + label_author_1: First author label_author_2: Second author label_author_3: Third author @@ -146,6 +147,6 @@ mail_subject_publication_added: "You have been added as an author to a new publication" mail_body_publication_added: "A new publication (%{publication}) has been added to the project '%{project}.'" - - - + + + diff -r 7529d85a20ea -r 9b5b4e7970cd vendor/plugins/redmine_bibliography/db/migrate/008_add_doi_and_timestamp_columns_to_publications.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/db/migrate/008_add_doi_and_timestamp_columns_to_publications.rb Wed Nov 21 17:47:51 2012 +0000 @@ -0,0 +1,12 @@ +class AddDoiAndTimestampColumnsToPublications < ActiveRecord::Migration + def self.up + add_column :publications, :doi, :string + add_timestamps :publications + + end + + def self.down + remove_column :publications, :doi + remove_timestamps :publications + end +end diff -r 7529d85a20ea -r 9b5b4e7970cd vendor/plugins/redmine_bibliography/db/migrate/009_add_timestamp_columns_to_authors.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/db/migrate/009_add_timestamp_columns_to_authors.rb Wed Nov 21 17:47:51 2012 +0000 @@ -0,0 +1,9 @@ +class AddTimestampColumnsToAuthors < ActiveRecord::Migration + def self.up + add_timestamps :authors + end + + def self.down + remove_timestamps :authors + end +end diff -r 7529d85a20ea -r 9b5b4e7970cd vendor/plugins/redmine_bibliography/init.rb --- a/vendor/plugins/redmine_bibliography/init.rb Thu Nov 15 14:13:10 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/init.rb Wed Nov 21 17:47:51 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 diff -r 7529d85a20ea -r 9b5b4e7970cd vendor/plugins/redmine_bibliography/lib/bibliography/projects_helper_patch.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/lib/bibliography/projects_helper_patch.rb Wed Nov 21 17:47:51 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 + diff -r 7529d85a20ea -r 9b5b4e7970cd vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb --- a/vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb Thu Nov 15 14:13:10 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb Wed Nov 21 17:47:51 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 diff -r 7529d85a20ea -r 9b5b4e7970cd vendor/plugins/redmine_tags/app/views/projects/_filter_search_tags.html.erb --- a/vendor/plugins/redmine_tags/app/views/projects/_filter_search_tags.html.erb Thu Nov 15 14:13:10 2012 +0000 +++ b/vendor/plugins/redmine_tags/app/views/projects/_filter_search_tags.html.erb Wed Nov 21 17:47:51 2012 +0000 @@ -6,7 +6,7 @@ <%= javascript_include_tag 'tags_input', :plugin => 'redmine_tags' -%> - <%= javascript_tag "observeProjectTagsField('#{url_for(:controller => 'auto_completes', :action => 'project_search_tags', :project_id => Project.first.id)}', true)" -%> + <%= javascript_tag "observeProjectTagsField('#{url_for(:controller => 'auto_completes', :action => 'project_search_tags')}', true)" -%>" << l("tags") << " | " s << "" << l("label_managers") << " | " s << sort_header_tag('created_on', :default_order => 'desc') s << sort_header_tag('updated_on', :default_order => 'desc') - + s << "
---|