# HG changeset patch
# User Chris Cannam
# Date 1316184678 -3600
# Node ID a8e402f4872331049cb53c37e7acf641079f951b
# Parent 7fc15203288c17d1fe18d74e154f4767107a470b# Parent cdddec376920bda759e4cf75cbce46d96449c96e
Merge from branch "live"
diff -r 7fc15203288c -r a8e402f48723 .hgtags
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgtags Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,1 @@
+202986dd17e4e02b3622b65cf38f358b67a393e8 bibliography_plugin_alpha
diff -r 7fc15203288c -r a8e402f48723 app/models/project.rb
--- a/app/models/project.rb Fri Sep 09 13:20:34 2011 +0100
+++ b/app/models/project.rb Fri Sep 16 15:51:18 2011 +0100
@@ -597,7 +597,8 @@
'custom_field_values',
'custom_fields',
'tracker_ids',
- 'issue_custom_field_ids'
+ 'issue_custom_field_ids',
+ 'has_welcome_page'
safe_attributes 'enabled_module_names',
:if => lambda {|project, user| project.new_record? || user.allowed_to?(:select_project_modules, project) }
diff -r 7fc15203288c -r a8e402f48723 app/models/ssamr_user_detail.rb
--- a/app/models/ssamr_user_detail.rb Fri Sep 09 13:20:34 2011 +0100
+++ b/app/models/ssamr_user_detail.rb Fri Sep 16 15:51:18 2011 +0100
@@ -10,5 +10,15 @@
institution_id.blank? and other_institution.blank?
end
-
+ def institution_name()
+ if not self.institution_type.nil?
+ if self.institution_type
+ Institution.find(self.institution_id).name
+ else
+ self.other_institution
+ end
+ else
+ ""
+ end
+ end
end
diff -r 7fc15203288c -r a8e402f48723 app/models/user.rb
--- a/app/models/user.rb Fri Sep 09 13:20:34 2011 +0100
+++ b/app/models/user.rb Fri Sep 16 15:51:18 2011 +0100
@@ -54,6 +54,8 @@
has_one :ssamr_user_detail, :dependent => :destroy, :class_name => 'SsamrUserDetail'
accepts_nested_attributes_for :ssamr_user_detail
+
+ has_one :author
# Active non-anonymous users scope
named_scope :active, :conditions => "#{User.table_name}.status = #{STATUS_ACTIVE}"
diff -r 7fc15203288c -r a8e402f48723 public/stylesheets/application.css
--- a/public/stylesheets/application.css Fri Sep 09 13:20:34 2011 +0100
+++ b/public/stylesheets/application.css Fri Sep 16 15:51:18 2011 +0100
@@ -251,6 +251,11 @@
border: 1px solid #e4e4e4;
}
+.box h4 {
+margin-top: 0;
+padding-top: 0;
+}
+
div.square {
border: 1px solid #999;
float: left;
@@ -400,13 +405,16 @@
p.pagination {margin-top:8px;}
/***** Tabular forms ******/
-.tabular p{
+.tabular p, .tabular ul{
margin: 0;
padding: 5px 0 8px 0;
padding-left: 180px; /*width of left column containing the label elements*/
height: 1%;
clear:left;
}
+.tabular ul{
+margin-top: -4px;
+}
html>body .tabular p {overflow:hidden;}
@@ -419,6 +427,15 @@
margin*/
}
+.tabular .splitcontentleft .box p, .tabular .splitcontentright .box p, .splitcontentleft .tabular p, .splitcontentright .tabular p, .tabular .splitcontentleft .box ul, .tabular .splitcontentright .box ul, .splitcontentleft .tabular ul, .splitcontentright .tabular ul {
+padding-left: 120px;
+}
+
+.tabular .splitcontentleft .box label, .tabular .splitcontentright .box label, .splitcontentleft .tabular label, .splitcontentright .tabular label {
+margin-left: -120px;
+width: 115px;
+}
+
.tabular label.floating{
font-weight: normal;
margin-left: 0px;
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/README.rdoc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/README.rdoc Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,3 @@
+= bibliography
+
+Description goes here
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/controllers/authors_controller.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/controllers/authors_controller.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,13 @@
+class AuthorsController < ApplicationController
+ helper :publications
+ include PublicationsHelper
+
+ def index
+ @authors = Author.find(:all)
+ end
+
+ def show
+ @author = Author.find(params[:id])
+ end
+
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/controllers/authorships_controller.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/controllers/authorships_controller.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,10 @@
+class AuthorshipsController < ApplicationController
+
+ def index
+
+ end
+
+
+ def update
+ end
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/controllers/bibtex_entries_controller.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/controllers/bibtex_entries_controller.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,3 @@
+class BibtexEntriesController < ApplicationController
+
+end
\ No newline at end of file
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,343 @@
+# -*- coding: utf-8 -*-
+# vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb
+
+class PublicationsController < ApplicationController
+ 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_project_by_project_id, :authorize, :only => [ :edit, :new, :update, :create ]
+
+ def new
+ find_project_by_project_id
+ @publication = Publication.new
+
+ # we'll always want a new publication to have its bibtex entry
+ @publication.build_bibtex_entry
+
+ # and at least one 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
+ @project = Project.find(params[:project_id])
+
+ @author_options = []
+
+ @publication = Publication.new(params[:publication])
+ @publication.projects << @project unless @project.nil?
+
+ if @publication.save
+ @publication.notify_authors_publication_added(@project)
+
+ flash[:notice] = "Successfully created publication."
+ redirect_to :action => :show, :id => @publication, :project_id => @project
+ else
+ render :action => 'new', :project_id => @project
+ end
+ end
+
+ def index
+ if !params[:project_id].nil?
+ find_project_by_project_id
+ @project = Project.find(params[:project_id])
+ @publications = Publication.find :all, :joins => :projects, :conditions => ["project_id = ?", @project.id]
+ else
+ @publications = Publication.find :all
+ end
+ end
+
+ def new_from_bibfile
+ @publication.current_step = session[:publication_step]
+
+ # contents of the paste text area
+ bibtex_entry = params[:bibtex_entry]
+
+ # method for creating "pasted" bibtex entries
+ if bibtex_entry
+ parse_bibtex_list bibtex_entry
+ end
+ end
+
+ def get_bibtex_required_fields
+
+ fields = BibtexEntryType.fields(params[:value])
+ all_fields = BibtexEntryType.all_fields
+
+ respond_to do |format|
+ format.js {
+ render(:update) {|page|
+ all_fields.each_with_index do |field, idx|
+ unless fields.include? field
+ page["publication_bibtex_entry_attributes_#{field}"].up('p').hide()
+ else
+ page["publication_bibtex_entry_attributes_#{field}"].up('p').show()
+ end
+ end
+ }
+ }
+ end
+ end
+
+ def add_author
+ if (request.xhr?)
+ render :text => User.find(params[:user_id]).name
+ else
+ # No? Then render an action.
+ #render :action => 'view_attribute', :attr => @name
+ logger.error { "Error while adding Author to publication." }
+ end
+ end
+
+ 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 = []
+
+ @bibtype_fields = BibtexEntryType.fields(@selected_bibtex_entry_type_id)
+ end
+
+ 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."
+
+ if !params[:project_id].nil?
+ redirect_to :action => :show, :id => @publication, :project_id => params[:project_id]
+ else
+ redirect_to :action => :show, :id => @publication
+ end
+ else
+ render :action => 'edit'
+ end
+ end
+
+ def show
+ find_project_by_project_id unless params[:project_id].nil?
+
+ if @publication.nil?
+ @publications = Publication.all
+ render "index", :alert => 'The publication was not found!'
+ else
+ @authors = @publication.authors
+ @bibtext_entry = @publication.bibtex_entry
+ end
+ end
+
+ # parse string with bibtex authors
+ def parse_authors(authors_entry)
+ # in bibtex the authors are always seperated by "and"
+ return authors_entry.split(" and ")
+ end
+
+ # parses a list of bibtex
+ def parse_bibtex_list(bibtex_list)
+ bibliography = BibTeX.parse bibtex_list
+
+ no_entries = bibliography.data.length
+
+ # parses the bibtex entries
+ bibliography.data.map do |d|
+
+ if d.class == BibTeX::Entry
+ create_bibtex_entry d
+ end
+ end
+ end
+
+ def create_bibtex_entry(d)
+ @publication = Publication.new
+ @bentry = BibtexEntry.new
+ authors = []
+ institution = ""
+ email = ""
+
+ d.fields.keys.map do |field|
+ case field.to_s
+ when "author"
+ authors = parse_authors d[field]
+ when "title"
+ @publication.title = d[field]
+ when "institution"
+ institution = d[field]
+ when "email"
+ email = d[field]
+ else
+ @bentry[field] = d[field]
+ end
+ end
+
+ @publication.bibtex_entry = @bentry
+ @publication.save
+
+ # what is this for???
+ # @created_publications << @publication.id
+
+ # need to save all authors
+ # 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!
+ puts "SAVED"
+ else
+ puts "NOT SAVED"
+ end
+
+ author.authorships.create!(
+ :publication => @publication,
+ :institution => institution,
+ :email => email,
+ :order => idx)
+ end
+ end
+
+ # parses the bibtex file
+ def parse_bibtex_file
+
+ end
+
+ def import
+ @publication = Publication.new
+
+
+ end
+
+ def autocomplete_for_project
+ @publication = Publication.find(params[:id])
+
+ @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
+ @results = []
+
+ object_id = params[:object_id]
+ @object_name = "publications[authorships_attributes][#{object_id}][search_results]"
+
+ # cc 20110909 -- revert to like instead of like_unique -- see #289
+ authorships_list = Authorship.like(params[:q]).find(:all, :limit => 100)
+ users_list = User.active.like(params[:q]).find(:all, :limit => 100)
+
+ logger.debug "Query for \"#{params[:q]}\" returned \"#{authorships_list.size}\" authorships and \"#{users_list.size}\" users"
+
+ @results = users_list
+
+ # TODO: can be optimized…
+ authorships_list.each do |authorship|
+ flag = true
+
+ users_list.each do |user|
+ if authorship.name == user.name && authorship.email == user.mail && authorship.institution == user.institution
+ Rails.logger.debug { "Rejecting Authorship #{authorship.id}" }
+ flag = false
+ break
+ end
+ end
+
+ @results << authorship if flag
+ end
+
+ render :layout => false
+ end
+
+
+ def get_user_info
+ object_id = params[:object_id]
+ value = params[:value]
+ classname = Kernel.const_get(value.split('_')[0])
+
+ item = classname.find(value.split('_')[1])
+
+ name_field = "publication_authorships_attributes_#{object_id}_name_on_paper".to_sym
+ email_field = "publication_authorships_attributes_#{object_id}_email".to_sym
+ institution_field = "publication_authorships_attributes_#{object_id}_institution".to_sym
+
+ yes_radio = "publication_authorships_attributes_#{object_id}_identify_author_yes".to_sym
+
+ respond_to do |format|
+ format.js {
+ render(:update) {|page|
+ page[name_field].value = item.name
+ page[email_field].value = item.mail
+ page[institution_field].value = item.institution
+
+ page[yes_radio].checked = true
+ page[name_field].readOnly = true
+ page[email_field].readOnly = true
+ page[institution_field].readOnly = true
+ }
+ }
+ end
+ end
+
+ def sort_author_order
+ params[:authorships].each_with_index do |id, index|
+ Authorship.update_all(['auth_order=?', index+1], ['id=?', id])
+ end
+ render :nothing => true
+ end
+
+ def add_project
+ @projects = Project.find(params[:publication][:project_ids])
+ @publication.projects << @projects
+ @project = Project.find(params[:project_id])
+
+ # 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
+ page.replace_html :list_projects, :partial => 'list_projects'
+ }
+ }
+ end
+ end
+
+
+ def remove_project
+ @project = Project.find(params[:project_id])
+ proj = Project.find(params[:remove_project_id])
+
+ if @publication.projects.length > 1
+ if @publication.projects.exists? proj
+ @publication.projects.delete proj if request.post?
+ end
+ else
+ logger.error { "Cannot remove project from publication list" }
+ end
+
+ logger.error { "CURRENT project name#{proj.name} and wanna delete #{@project.name}" }
+
+ render(:update) {|page|
+ page.replace_html "list_projects", :partial => 'list_projects', :id => @publication
+ }
+ end
+
+ def destroy
+ find_project_by_project_id
+
+ @publication.destroy
+
+ flash[:notice] = "Successfully deleted Publication."
+ redirect_to :controller => :publications, :action => 'index', :project_id => @project
+ end
+
+ private
+
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/helpers/authors_helper.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/helpers/authors_helper.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,28 @@
+module AuthorsHelper
+ unloadable
+
+ def render_author_publications(author)
+ s = ""
+ pubs = []
+
+ author.publications.each do |pub|
+ pubs << link_to(pub.title, pub)
+ end
+
+ if pubs.size < 3
+ s << '' << pubs.join(', ') << ''
+ else
+ s << pubs.join(', ')
+ end
+ s
+ end
+
+
+ # Generates a link to an author
+ # todo: test options
+ def link_to_author(author, options={}, html_options = nil)
+ url = {:controller => 'authors', :action => 'show', :id => author}.merge(options)
+ link_to(h(author.name), url, html_options)
+ end
+
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/helpers/authorships_helper.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/helpers/authorships_helper.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,2 @@
+module AuthorshipsHelper
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/helpers/bibtex_entries_helper.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/helpers/bibtex_entries_helper.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,3 @@
+module BibtexEntriesHelper
+
+end
\ No newline at end of file
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/helpers/my_helper.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/helpers/my_helper.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,38 @@
+module MyHelper
+
+ def get_my_publications()
+ if not User.current.author.nil?
+ @my_publications = Publication.all(:include => :authors, :conditions => "authors.id = #{User.current.author.id}")
+ else
+ @my_publications = []
+ end
+ end
+
+ def render_publications_projects(publication)
+ s = ""
+ projs = []
+
+ publication.projects.each do |proj|
+ projs << link_to(proj.name, proj)
+ end
+
+ s << projs.join(', ')
+
+ s
+ end
+
+ def render_publications_authors(publication)
+ s = ""
+ auths = []
+
+ publication.authorships.each do |auth|
+ auths << h(auth.name_on_paper)
+ end
+
+ s << auths.join(', ')
+
+ s
+ end
+
+
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,118 @@
+# -*- coding: utf-8 -*-
+require 'bibtex'
+
+module PublicationsHelper
+
+ def link_to_publication(publication, options={}, html_options = nil)
+ url = {:controller => 'publications', :action => 'show', :id => publication}.merge(options)
+ link_to(h(publication.title), url, html_options)
+ end
+
+ def projects_check_box_tags(name, projects)
+ s = ''
+ projects.sort.each do |project|
+ s << "\n"
+ end
+ 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]
+ if email_bit != "":
+ email_bit = "(@#{email_bit})"
+ 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
+
+ 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_fields(name, f, association)
+ 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
+ link_to_function(name, h("add_fields(this, '#{association}', '#{escape_javascript(fields)}')"), { :class => 'icon icon-add', :id => "add_another_author" })
+ end
+
+ def sanitized_object_name(object_name)
+ object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/,"_").sub(/_$/,"")
+ end
+
+ 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
+ end
+
+ 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_projects_list(publication)
+ logger.error { "PROJECT NAME #{@project.name unless @project.nil?}" }
+
+ s = ""
+
+ publication.projects.each do |proj|
+ s << link_to_project(proj, {}, :class => 'publication_project')
+
+ if User.current.allowed_to?(:edit_publication, @project)
+ if @project == proj
+ 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 << "
"
+
+ end
+
+ s
+ 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 << "
" + l("field_#{key}") + "
"
+ s << ""
+ if key == "entry_type"
+ s << bibtex_entry.entry_type_label
+ else
+ s << value
+ end
+ s << "
"
+ end
+ s
+ end
+end
+
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/models/author.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/models/author.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,18 @@
+class Author < ActiveRecord::Base
+ has_many :authorships, :dependent => :destroy
+ has_many :publications, :through => :authorships
+
+ belongs_to :user
+
+ def <=>(author)
+ name.downcase <=> author.name.downcase
+ end
+
+ named_scope :like, lambda {|q|
+ s = "%#{q.to_s.strip.downcase}%"
+ {:conditions => ["LOWER(name) LIKE :s", {:s => s}],
+ :order => 'name'
+ }
+ }
+
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/models/authorship.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/models/authorship.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,71 @@
+class Authorship < ActiveRecord::Base
+ unloadable
+
+ belongs_to :author
+ belongs_to :publication
+
+ accepts_nested_attributes_for :author
+ accepts_nested_attributes_for :publication
+
+ validates_presence_of :name_on_paper
+
+ attr_accessor :is_user, :author_user_id, :search_name, :identify_author, :search_results
+ before_save :associate_author_user
+
+ named_scope :like_unique, lambda {|q|
+ s = "%#{q.to_s.strip.downcase}%"
+ {:conditions => ["LOWER(name_on_paper) LIKE :s OR LOWER(email) LIKE :s", {:s => s}],
+ :order => 'name_on_paper',
+ :group => "name_on_paper, institution, email"
+ }
+ }
+
+ named_scope :like, lambda {|q|
+ s = "%#{q.to_s.strip.downcase}%"
+ {:conditions => ["LOWER(name_on_paper) LIKE :s OR LOWER(email) LIKE :s", {:s => s}],
+ :order => 'name_on_paper'
+ }
+ }
+
+ def name
+ return self.name_on_paper
+ end
+
+ def <=>(authorship)
+ name.downcase <=> authorship.name.downcase
+ end
+
+ def mail
+ return self.email
+ end
+
+ protected
+ def associate_author_user
+ case self.identify_author
+ when "no"
+ author = Author.new
+ author.save
+ self.author_id = author.id
+ else
+ selected = self.search_results
+ selected_classname = Kernel.const_get(selected.split('_')[0])
+ selected_id = selected.split('_')[1]
+ object = selected_classname.find(selected_id)
+
+ if object.respond_to? :name_on_paper
+ # Authorship
+ self.author_id = object.author.id
+ else
+ # User
+ unless object.author.nil?
+ self.author_id = object.author.id
+ else
+ author = Author.new
+ object.author = author
+ object.save
+ self.author_id = object.author.id
+ end
+ end
+ end
+ end
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/models/bibtex_entry.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/models/bibtex_entry.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,16 @@
+class BibtexEntry < ActiveRecord::Base
+ unloadable
+
+ belongs_to :publication
+ validates_presence_of :entry_type
+
+ def entry_type_name
+ entry_type = self.entry_type
+ BibtexEntryType.find(entry_type).name
+ end
+
+ def entry_type_label
+ entry_type = self.entry_type
+ BibtexEntryType.find(entry_type).label
+ end
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/models/bibtex_entry_type.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/models/bibtex_entry_type.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,35 @@
+class BibtexEntryType < ActiveRecord::Base
+
+ @@all_fields = [ "editor", "publisher", "chapter", "pages", "volume", "series", "address", "edition", "month", "year", "type", "note", "number", "journal", "howpublished", "key", "school" ]
+
+ @@fields = Hash['article', ['journal', 'year', 'volume', 'number', 'pages', 'month', 'note' ],
+ 'book' , [ 'editor', 'publisher', 'volume', 'series', 'address', 'edition', 'month', 'year', 'note' ],
+ 'booklet' , [ 'howpublished', 'address', 'year', 'month', 'note', 'key' ],
+ 'conference', [ 'booktitle', 'year', 'editor', 'pages', 'organization', 'publisher', 'address', 'month', 'note' ],
+ 'inbook', [ 'editor', 'publisher', 'chapter', 'pages', 'volume', 'series', 'address', 'edition', 'year', 'note' ],
+ 'incollection', [ 'editor', 'publisher', 'chapter', 'pages', 'volume', 'series', 'address', 'edition', 'year', 'note' ],
+ 'inproceedings', [ 'booktitle', 'year', 'editor', 'pages', 'organization', 'publisher', 'address', 'month', 'note' ],
+ 'manual', [ 'organization', 'address', 'edition', 'month', 'year', 'note' ],
+ 'masterthesis', [ 'school', 'year', 'address', 'month', 'note' ],
+ 'misc', [ 'howpublished', 'month', 'year', 'note' ],
+ 'phdthesis', [ 'school', 'year', 'address', 'month', 'note' ],
+ 'proceedings', [ 'booktitle', 'year', 'editor', 'pages', 'organization', 'publisher', 'address', 'month', 'note' ],
+ 'techreport', [ 'year', 'type', 'number', 'address', 'month', 'note' ],
+ 'unpublished', [ 'note', 'month', 'year' ]]
+
+ def redundant?
+ name == 'conference' # conference is a duplicate of inproceedings
+ end
+
+ def label
+ l("field_bibtex_#{name}")
+ end
+
+ def self.fields (type)
+ @@fields[ self.find(type).name ]
+ end
+
+ def self.all_fields
+ @@all_fields
+ end
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/models/publication.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,63 @@
+# vendor/plugins/redmine_bibliography/app/models/publication.rb
+
+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
+ validates_length_of :authorships, :minimum => 1, :message => l("error_no_authors")
+
+ 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
+ # bibtex_entry.entry_type (#268). There has to be a better way to
+ # do this!
+ def self.human_attribute_name(k)
+ if k == 'bibtex_entry.entry_type'
+ l(:field_entry_type)
+ else
+ super
+ end
+ end
+
+ 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)
+ 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
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/authors/index.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/authors/index.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,26 @@
+<%=l(:label_authors_index)%>
+
+
+
+ <%=l(:field_author_name)%> |
+ <%=l(:field_author_username)%> |
+ <%=l(:field_author_publications)%> |
+
+
+
+ <% @authors.each do |author|%>
+
+
+ <%= link_to_author author %>
+ |
+
+ <%= link_to author.user unless author.user.nil? %>
+ |
+
+ <%= render_author_publications(author) %>
+ |
+
+ <% end %>
+
+
+
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/authors/show.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/authors/show.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,24 @@
+<%=l(:label_authors_show)%>
+
+
+
+
+
+ <%=l(:field_authorship_publication_title)%> |
+ <%=l(:field_authorship_name)%> |
+ <%=l(:field_authorship_email)%> |
+ <%=l(:field_authorship_institution)%> |
+
+
+
+ <% @author.authorships.each do |authorship| %>
+
+ <%= link_to_publication(authorship.publication) %> |
+ <%= h authorship.name_on_paper %> |
+ <%= h authorship.email %> |
+ <%= h authorship.institution %> |
+
+ <% end %>
+
+
+
\ No newline at end of file
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/authorships/update.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/authorships/update.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,1 @@
+Authorships#update
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/mailer/publication_added.text.html.rhtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/mailer/publication_added.text.html.rhtml Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,1 @@
+<%= l(:mail_body_publication_added, :publication => @publication.title, :project => @project.name) %>
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/mailer/publication_added.text.plain.rhtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/mailer/publication_added.text.plain.rhtml Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,2 @@
+<%= l(:mail_body_publication_added, :publication => @publication.title, :project => @project.name) %>
+
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/my/blocks/_publications_box.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/my/blocks/_publications_box.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,30 @@
+<% get_my_publications %>
+
+<%=l(:label_my_publications_box) %> <%= "(" + @my_publications.count.to_s + ")" %>
+
+
+
+ <%=l(:field_publication_title)%> |
+ <%=l(:field_publication_authors)%> |
+ <%=l(:field_publication_projects)%> |
+
+
+
+ <% @my_publications.each do |publication|%>
+
+
+ <%= link_to publication.title, publication %>
+ |
+
+ <%= render_publications_authors(publication) %>
+ |
+
+ <%= render_publications_projects(publication) %>
+ |
+
+ <% end %>
+
+
+
+
+
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/projects/_bibliography_box.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/projects/_bibliography_box.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,26 @@
+<% if @project.publications.any? %>
+<%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %>
+
+
+
<%=l(:label_related_publication_plural)%>
+
+
+ <% @project.publications.each do |publication| %>
+ -
+ <%= link_to publication.title, :controller => 'publications', :action => 'show', :id => publication, :project_id => @project %>
+
+ -
+
+ <%= publication.authorships.map { |a| h a.name_on_paper }.join(', ') %>
+
+ <% if publication.bibtex_entry.year.to_s != "" %>
+
+ <%= publication.bibtex_entry.year %>
+
+ <% end %>
+
+ <% end -%>
+
+
+
+<% end %>
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/projects/show.rhtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/projects/show.rhtml Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,119 @@
+
+ <% if User.current.allowed_to?(:add_subprojects, @project) %>
+ <%= link_to l(:label_subproject_new), {:controller => 'projects', :action => 'new', :parent_id => @project}, :class => 'icon icon-add' %>
+ <% end %>
+
+ <% if @project.module_enabled? :redmine_bibliography %>
+ <% if User.current.allowed_to?(:add_publication, @project) %>
+ <%= link_to l(:label_add_publication_to_project), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %>
+ <% end %>
+ <% end %>
+
+
+<% if @project.has_welcome_page %>
+<% page = @project.wiki.find_page("Overview") %>
+<% end %>
+
+<% if page %>
+
+<% if @project.module_enabled? :wiki %>
+<% if User.current.allowed_to?(:edit_wiki_pages, @project) %>
+
+<%= link_to(l(:button_welcome_page_edit_this), {:controller => 'wiki', :action => 'edit', :project_id => @project, :id => Wiki.titleize("Overview")}, :class => 'icon icon-edit') %>
+
+<% end %>
+<% end %>
+
+
+
+<% unless @project.homepage.blank? %>- <%=l(:field_homepage)%>: <%= auto_link(h(@project.homepage)) %>
<% end %>
+<% if @subprojects.any? %>
+ - <%=l(:label_subproject_plural)%>:
+ <%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join(", ") %>
+<% end %>
+
+
+
+<%= render(:partial => "wiki/content", :locals => {:content => page.content_for_version()}) %>
+
+<% else %>
+
+<%=l(:label_overview)%>
+
+
+
+ <%= textilizable @project.description %>
+
+
+ <% unless @project.homepage.blank? %>- <%=l(:field_homepage)%>: <%= auto_link(h(@project.homepage)) %>
<% end %>
+ <% if @subprojects.any? %>
+ - <%=l(:label_subproject_plural)%>:
+ <%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join(", ") %>
+ <% end %>
+ <% @project.visible_custom_field_values.each do |custom_value| %>
+ <% if !custom_value.value.blank? %>
+ - <%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %>
+ <% end %>
+ <% end %>
+
+
+ <% if User.current.allowed_to?(:view_issues, @project) %>
+
+
<%=l(:label_issue_tracking)%>
+
+ <% for tracker in @trackers %>
+ - <%= link_to tracker.name, :controller => 'issues', :action => 'index', :project_id => @project,
+ :set_filter => 1,
+ "tracker_id" => tracker.id %>:
+ <%= l(:label_x_open_issues_abbr_on_total, :count => @open_issues_by_tracker[tracker].to_i,
+ :total => @total_issues_by_tracker[tracker].to_i) %>
+
+ <% end %>
+
+
+ <%= link_to l(:label_issue_view_all), :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1 %>
+ <% if User.current.allowed_to?(:view_calendar, @project, :global => true) %>
+ | <%= link_to(l(:label_calendar), :controller => 'calendars', :action => 'show', :project_id => @project) %>
+ <% end %>
+ <% if User.current.allowed_to?(:view_gantt, @project, :global => true) %>
+ | <%= link_to(l(:label_gantt), :controller => 'gantts', :action => 'show', :project_id => @project) %>
+ <% end %>
+
+
+ <% end %>
+ <%= call_hook(:view_projects_show_left, :project => @project) %>
+
+
+
+
+ <%= render :partial => 'bibliography_box' %>
+
+ <%= render :partial => 'members_box' %>
+
+ <% if @news.any? && authorize_for('news', 'index') %>
+
+
<%=l(:label_news_latest)%>
+ <%= render :partial => 'news/news', :collection => @news %>
+
<%= link_to l(:label_news_view_all), :controller => 'news', :action => 'index', :project_id => @project %>
+
+ <% end %>
+ <%= call_hook(:view_projects_show_right, :project => @project) %>
+
+
+<% content_for :sidebar do %>
+ <% if @total_hours && User.current.allowed_to?(:view_time_entries, @project) %>
+ <%= l(:label_spent_time) %>
+ <%= l_hours(@total_hours) %>
+ <%= link_to(l(:label_details), {:controller => 'timelog', :action => 'index', :project_id => @project}) %> |
+ <%= link_to(l(:label_report), {:controller => 'time_entry_reports', :action => 'report', :project_id => @project}) %>
+ <% end %>
+ <%= call_hook(:view_projects_show_sidebar_bottom, :project => @project) %>
+<% end %>
+
+<% end %>
+
+<% content_for :header_tags do %>
+<%= auto_discovery_link_tag(:atom, {:controller => 'activities', :action => 'index', :id => @project, :format => 'atom', :key => User.current.rss_key}) %>
+<% end %>
+
+<% html_title(l(:label_overview)) -%>
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/publications/_add_project_form.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/_add_project_form.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,29 @@
+<% form_remote_for(:publication,
+ :url => {:controller => 'publications', :action => 'add_project', :id => @publication, :project_id => @project},
+ :method => :post,
+ :html => { :id => 'add_project_form' },
+ :loading => "$('project-add-submit').disable()",
+ :complete => "$('project-add-submit').enable()") do |f| %>
+
+ <% end %>
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,59 @@
+<%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %>
+
+
+
+
+
+
>
+
+ <%= f.text_field :search_name, :size => 25 %>
+ <%= observe_field( form_tag_id(f.object_name, :search_name), :frequency => 0.5, :update => form_tag_id( f.object_name, :search_results), :url => { :controller => 'publications', :action => 'autocomplete_for_author', :object_name => form_object_id(f.object_name) }, :with => 'q' ) %>
+
+ <%# link_to_function l(:label_author_is_me), "update_author_info(this," + User.current.get_author_info.to_json + ")", :id => "add_me_as_author" %>
+
+
+ <%= f.select :search_results, options_for_select(@author_options), {}, {:size => 5,
+ :onChange => remote_function( :url => { :controller => :publications, :action => :get_user_info, :object_id => form_object_id(f.object_name) }, :with => "'value=' +
+ value" )} %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <% if params[:action] == 'new' %>
+ <%= button_to_function l(:label_save_author), {}, { :onclick => "toggle_save_author(#{form_object_id(f.object_name)}); return false;", :id => form_tag_id( f.object_name, :edit_save_button )} %>
+ <% else %>
+<%= button_to_function l(:label_edit_author), {}, { :onclick => "toggle_save_author(#{form_object_id(f.object_name)}); return false;", :id => form_tag_id( f.object_name, :edit_save_button )} %>
+
+ <% end %>
+
+
+ <%= link_to_remove_fields l("remove_author"), f %>
+
+
+
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,80 @@
+
+
+ <%= f.collection_select :entry_type,
+ BibtexEntryType.find(:all).reject { |x| x.redundant? },
+ :id,
+ :label,
+ { :selected => @selected_bibtex_entry_type_id, :prompt => true },
+ :onChange => remote_function( :url => { :controller => :publications, :action => :get_bibtex_required_fields}, :with => "'value=' + value" )
+ %>
+
+
+ <%= f.text_field :year, :size => 4, :class => 'bibtex' %>
+
+
+ <%= f.text_field :month, :size => 4, :class => 'bibtex' %>
+
+
+ <%= f.text_field :chapter, :size => 15, :class => 'bibtex' %>
+
+
+ <%= f.text_field :editor, :size => 33, :class => 'bibtex' %>
+
+
+ <%= f.text_field :booktitle, :size => 33, :class => 'bibtex' %>
+
+
+ <%= f.text_field :publisher,:size => 33, :class => 'bibtex' %>
+
+
+ <%= f.text_field :pages, :size => 12, :class => 'bibtex' %>
+
+
+ <%= f.text_field :address, :class => 'bibtex' %>
+
+
+ <%= f.text_field :annote, :class => 'bibtex' %>
+
+
+ <%= f.text_field :crossref, :class => 'bibtex' %>
+
+
+ <%= f.text_field :edition, :class => 'bibtex' %>
+
+
+ <%= f.text_field :eprint, :class => 'bibtex' %>
+
+
+ <%= f.text_field :howpublished, :class => 'bibtex' %>
+
+
+ <%= f.text_field :journal, :class => 'bibtex' %>
+
+
+ <%= f.text_field :key, :class => 'bibtex' %>
+
+
+ <%= f.text_field :note, :class => 'bibtex' %>
+
+
+ <%= f.text_field :number, :class => 'bibtex' %>
+
+
+ <%= f.text_field :organization, :class => 'bibtex' %>
+
+
+ <%= f.text_field :school, :class => 'bibtex' %>
+
+
+ <%= f.text_field :series, :class => 'bibtex' %>
+
+
+ <%= f.text_field :type, :class => 'bibtex' %>
+
+
+ <%= f.text_field :url, :class => 'bibtex' %>
+
+
+ <%= f.text_field :volume, :class => 'bibtex' %>
+
+
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,31 @@
+<%= f.error_messages %>
+
+<%= f.text_field :title, :required => true, :size => 70 %>
+
+
+
<%= l(:label_publication_other_details) %>
+
+ <% f.fields_for :bibtex_entry do |builder| -%>
+ <%= render :partial => 'bibtex_fields', :locals => { :f => builder} %>
+ <%- end -%>
+
+
+ <%= f.text_field :external_url, :size => 70 %>
+
+ <%= l(:text_external_url) %>
+
+
+
+
+
+
+
<%= l(:authors) %>
+
+ <% f.fields_for :authorships do |builder| -%>
+ <%= render "authorship_fields", :f => builder %>
+ <%- end -%>
+ <%= link_to_add_fields l(:label_add_an_author), f, :authorships %>
+
+
+
+
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/publications/_identify_author_form.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/_identify_author_form.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,25 @@
+
+
+<%= link_to_remote "It's me!",
+ { :url => { :controller => 'publications',
+ :action => 'add_me_as_author',
+ :project_id => @project }, :method => 'post'},
+ { :class => 'icon icon-add', :id => "add_me_as_author" } %>
+
+
+ <%= label_tag "author_search", l(:label_project_search) %><%= text_field_tag 'author_search', nil %>
+
+
+<%= observe_field( form_tag_id(f.object_name, :name),
+ :frequency => 0.5,
+ :update => :identify_author,
+ :url => { :controller => 'publications', :action => 'autocomplete_for_author' },
+ :with => 'q')
+%>
+
+
+ <% if params[:q] && params[:q].length > 1 %>
+ <%= select_author_links 'author[author_ids][]', @authors %>
+ <% end %>
+
+
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,1 @@
+<%= render_projects_list(@publication) %>
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/publications/_new_bibtex_step.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/_new_bibtex_step.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,9 @@
+New Bibtex
+
+Paste your Bibtex entries here
+
+ <%=label_tag :bibtex_entry %>
+ <%=text_area_tag :bibtex_entry%>
+
+
+
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/publications/_review_bibtex_step.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/_review_bibtex_step.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,2 @@
+Review new entries
+
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/publications/add_project.rjs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/add_project.rjs Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,3 @@
+page.replace_html :list_projects, :partial => 'list_projects'
+page[:add_project_form].reset
+
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.rhtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.rhtml Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,4 @@
+<% if params[:q] && params[:q].length > 1 %>
+ <%= choose_author_link @object_name, @results %>
+<% end %>
+
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/publications/autocomplete_for_project.rhtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/autocomplete_for_project.rhtml Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,3 @@
+<% if params[:q] && params[:q].length > 1 %>
+ <%= projects_check_box_tags 'publication[project_ids][]', @projects %>
+<% end %>
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/publications/create.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/create.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,1 @@
+Publications#create
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,18 @@
+<% content_for :header_tags do %>
+ <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %>
+ <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %>
+ <%= javascript_tag 'Event.observe(window, "load", function(e){show_all_required_bibtex_fields(' + @bibtype_fields.to_json + ')});' %>
+<% end %>
+
+<%=l(:label_publication_show)%>
+
+<% form_for @publication, :url => { :project_id => @project, :action => :update }, :builder => TabularFormBuilder do |f| -%>
+ <%= render :partial => 'form', :locals => { :f => f } %>
+
+
+ <%= f.submit %>
+<% end %>
+
+ <%= link_to l(:label_publication_show), { :controller => "publications", :action => "show", :id => @publication, :project_id => @project_id } %> |
+ <%= link_to l(:label_publication_index), { :controller => "publications", :action => "index", :project_id => @project } %>
+
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/publications/import.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/import.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,12 @@
+New Publication
+
+<% form_for @publication, :url => { :action => "create" } do |f| %>
+ <% f.error_messages %>
+
+ <%= render :partial => "#{@publication.current_step}_bibtex_step", :locals => { :f => f } %>
+
+ <%= f.submit "Submit" %>
+ <%= f.submit "Back", :name => "back_button" unless @publication.first_step? %>
+
+<% end %>
+
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,42 @@
+
+ <% if User.current.allowed_to?(:add_publication, @project) %>
+ <%= link_to l(:label_publication_new), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %>
+ <% end %>
+
+
+ <% if @project %>
+ <%= l(:label_all_publications_for_project, :project => @project.name) %>
+ <% else %>
+ <%= l(:label_all_publications) %>
+ <% end %>
+
+
+
+<% content_for :sidebar do %>
+<% end %>
+
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,13 @@
+<% content_for :header_tags do %>
+ <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %>
+ <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %>
+ <%= javascript_tag 'Event.observe(window, "load", hide_all_bibtex_required_fields);' %>
+<% end %>
+
+<%=l(:label_publication_new)%>
+
+<% form_for @publication, :url => { :project_id => @project, :action => :create }, :builder => TabularFormBuilder do |f| -%>
+ <%= render :partial => 'form', :locals => { :f => f } %>
+
+ <%= f.submit %>
+<% end %>
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,60 @@
+<%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %>
+
+<%=l(:label_publication_show)%>
+
+
+
+ <%= h @publication.title %>
+
+
+
<%= l(:authors) %>
+
+ <% for authorship in @publication.authorships.find(:all, :order => :auth_order) %>
+ <% content_tag_for :li, authorship do %>
+ <%- if User.current.allowed_to?(:edit_publication, @project) && @publication.authorships.length > 1 -%>
+ [drag to reorder]
+ <%- end -%>
+ <%= h authorship.name_on_paper %> <%= h authorship.institution %>
+ <%- end -%>
+ <%- end -%>
+
+<%- if User.current.allowed_to?(:edit_publication, @project) && @publication.authorships.length > 1 -%>
+ <%= sortable_element("authorships", :url => { :controller => :publications, :action => :sort_author_order }, :handle => "handle") %>
+<%- end -%>
+
+<%- if @publication.bibtex_entry != nil -%>
+ <%= show_bibtex_fields(@publication.bibtex_entry) %>
+<%- end -%>
+
+
+<% unless @publication.external_url.blank? %>
+
+ <%= l(:field_external_url) %>
+
+
+ <%= link_to h(@publication.external_url), @publication.external_url, {:target => "_blank"} %>
+
+<% end %>
+
+
+ <% if User.current.allowed_to?(:add_publication, @project) %>
+ <%= link_to l(:label_publication_edit), { :controller => "publications", :action => "edit", :id => @publication, :project_id => @project } %> |
+ <%= link_to "Delete", {:controller => 'publications', :action => 'destroy', :id => @publication, :project_id => @project },
+ :confirm => l(:text_are_you_sure), :method => :delete, :title => l(:button_delete) %> |
+ <% end %>
+ <%= link_to l(:view_all_publications), {:controller => 'publications', :action => 'index', :project_id => @project } %>
+
+
+<% projects = Project.active.find(:all, :limit => 100, :order => 'name ASC') - @publication.projects %>
+
+<% content_for :sidebar do %>
+ <%=l(:label_publication_project_index)%>
+
+
+ <%= render :partial => 'list_projects' %>
+
+
+ <%- if User.current.allowed_to?(:edit_publication, @project) -%>
+ <%= render :partial => 'add_project_form' %>
+ <%- end -%>
+<% end %>
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/publications/update.html.erb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/update.html.erb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,1 @@
+Publications#update
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/app/views/settings/_bibliography.rhtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/settings/_bibliography.rhtml Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,3 @@
+
+<%= text_field_tag 'settings[menu]', @settings['menu'], :size => 30 %>
+
Clear this field if you don't want to add a tab to the project menu
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/assets/javascripts/authors.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,72 @@
+function remove_fields(link) {
+ $(link).previous("input[type=hidden]").value = "1";
+ $(link).up(".fields").hide();
+}
+
+function add_fields(link, association, content) {
+ var new_id = new Date().getTime();
+ var regexp = new RegExp("new_" + association, "g")
+ $(link).insert({
+ before: content.replace(regexp, new_id)
+ });
+}
+
+function identify_author_status(status, object_id) {
+ $('publication_authorships_attributes_' + object_id + '_edit_author_info').select('input').each(function(s) {
+ if(status == "no"){
+ s.value = "";
+ s.readOnly = false;
+ };
+
+ if(status == "correct"){s.readOnly = false;};
+ if(status == "yes"){s.readOnly = true;};
+ });
+}
+
+function toggle_div(div_id){
+ Effect.toggle(div_id, "appear", {duration:0.3});
+}
+
+function toggle_input_field(field){
+ if (field.classNames().inspect().include("readonly") == false){
+ field.readOnly = true;
+ field.addClassName('readonly');
+ } else {
+ field.readOnly = false;
+ field.removeClassName('readonly');
+ };
+}
+
+function toggle_edit_save_button(object_id){
+ $button = $('publication_authorships_attributes_' + object_id + '_edit_save_button');
+ if ($button.value == "Edit author"){
+ $button.value = "Save author";
+ } else {
+ $button.value = "Edit author";
+ };
+}
+
+function toggle_save_author(form_object_id, $this){
+ $('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('input').each(function(s) {
+ toggle_input_field(s, $this);
+ });
+ $('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('p.description').each(function(s) {
+ s.toggle();
+ });
+ toggle_edit_save_button(form_object_id);
+ toggle_div("publication_authorships_attributes_" + form_object_id +"_search_author");
+}
+
+function edit_author(form_object_id){}
+
+function hide_all_bibtex_required_fields() {
+ $$('input.bibtex').each(function(s){
+ s.up('p').hide();
+ })}
+
+function show_all_required_bibtex_fields(entrytype_fields) {
+ $$('input.bibtex').each(function(s){
+ if(entrytype_fields.indexOf(s.id.split('_').last()) == -1){s.up('p').hide()};
+ })
+}
+
\ No newline at end of file
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/assets/stylesheets/bibliography.css
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/assets/stylesheets/bibliography.css Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,45 @@
+li .handle {
+ font-size: 12px;
+ cursor: move;
+ color: #777;
+}
+
+input.readonly {
+ border: none;
+ padding: 0;
+ margin: 0;
+ background-color: transparent;
+}
+
+.tabular .author_identify label {
+ font-weight: normal;
+}
+
+.tabular .author_edit p {
+ padding-bottom: 0;
+}
+
+.tabular .author_edit .description {
+ padding-top: 0;
+ font-style: italic;
+}
+
+.publication_project {
+ margin-right: 18px;
+}
+
+#authors select {
+ min-width: 150px;
+}
+
+div#bibliography dl { margin-left: 2em; }
+div#bibliography .box dl { margin-left: 0; }
+div#bibliography dt { margin-bottom: 0px; padding-left: 20px }
+div#bibliography .box dt { margin-bottom: 0px; padding-left: 10px }
+div#bibliography dd { margin-bottom: 1em; padding-left: 18px; font-size: 0.9em; }
+div#bibliography .box dd { margin-bottom: 0.6em; padding-left: 0; }
+div#bibliography dd .authors { font-style: italic; }
+div#bibliography dd span.authors { color: #808080; }
+div#bibliography dd span.year { padding-left: 0.6em; }
+
+div#bibliography h3 { background: url(../../../images/table_multiple.png) no-repeat 0% 50%; padding-left: 20px; }
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/config/locales/en.yml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/config/locales/en.yml Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,148 @@
+# English strings go here for Rails i18n
+en:
+ project_module_redmine_bibliography: Bibliography
+
+ title: "Title"
+ authors: "Authors"
+ author: "Author"
+ name: "Name"
+ year: "Year"
+ publications_box: "My Publications"
+ label_my_publications_box: "My Publications"
+ view_all_publications: "View All Project's 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"
+ identify_author_no: "No, the author was not found in the search"
+
+ error_no_authors: "Please add at least one author to this publication."
+
+ label_all_publications: All Publications
+ label_all_publications_for_project: Publications associated with %{project}
+ label_authors_show: "Authorships by this author"
+ label_authors_index: "List of authors"
+
+ field_authorship_publication_title: "Publication Title"
+ field_authorship_name: "Name"
+ field_authorship_email: "Email Address"
+ field_authorship_institution: "Institution"
+
+ field_external_url: "External URL"
+ 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_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"
+ label_add_another_author: "Add another author"
+ field_search_name: "Search by name"
+ field_search_results: ""
+ label_save_author: "Save author"
+ label_edit_author: "Edit author"
+ 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"
+ label_publication_index: "List of Publication"
+ label_add_publication_to_project: "Add publication to this project"
+ label_publication_edit: "Edit Publication"
+ label_publication_show: "Publication Details"
+ label_add_project_to_publication: "Add this publication to a project"
+ label_project_search: "Find project by name: "
+ 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_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_email: "Email Address"
+
+ # bibtex_entries model
+ field_entry_type: "Publication Type"
+ field_id: "id"
+ field_publication_id: "Publication_id"
+ field_address: "Address"
+ field_annote: "Annote"
+ field_booktitle: "Book Title"
+ field_chapter: "Chapter"
+ field_crossref: "Cross Reference"
+ field_edition: "Edition"
+ field_editor: "Editor"
+ field_eprint: "eprint"
+ field_howpublished: "How was it Published"
+ field_journal: "Journal"
+ field_key: "Key"
+ field_month: "Month"
+ field_note: "Note"
+ field_number: "Number"
+ field_organization: "Organization"
+ field_pages: "Pages"
+ field_publisher: "Publisher"
+ field_school: "School"
+ field_series: "Series"
+ field_type: "Type"
+ field_url: "URL"
+ field_volume: "Volume"
+ field_year: "Year"
+
+ field_bibtex_article: Journal article
+ field_bibtex_book: Book
+ field_bibtex_booklet: Booklet
+ field_bibtex_conference: Article in conference proceedings
+ field_bibtex_inbook: Book chapter or part
+ field_bibtex_incollection: Part of a collection
+ field_bibtex_inproceedings: Article in conference proceedings
+ field_bibtex_manual: Technical manual
+ field_bibtex_masterthesis: "Master's thesis"
+ field_bibtex_misc: Other
+ field_bibtex_phdthesis: "PhD thesis"
+ 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
+ label_author_4: Fourth author
+ label_author_5: Fifth author
+ label_author_6: Sixth author
+ label_author_7: Seventh author
+ label_author_8: Eighth author
+ label_author_9: Ninth author
+ label_author_10: Tenth author
+ label_author_11: Eleventh author
+ label_author_12: Twelfth author
+ label_author_13: Thirteenth author
+ label_author_14: Fourteenth author
+ label_author_15: Fifteenth author
+ label_author_16: Sixteenth author
+ label_author_17: Seventeenth author
+ label_author_18: Eighteenth author
+ label_author_19: Nineteenth author
+ label_author_20: Twentieth author
+
+ 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 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/config/routes.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/config/routes.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,3 @@
+ActionController::Routing::Routes.draw do |map|
+ map.resources :publications, :collection => { :sort_author_order => :post }
+end
\ No newline at end of file
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/db/migrate/001_create_authors.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/db/migrate/001_create_authors.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,12 @@
+class CreateAuthors < ActiveRecord::Migration
+ def self.up
+ create_table :authors do |t|
+ t.column :user_id, :integer
+ t.column :name, :string
+ end
+ end
+
+ def self.down
+ drop_table :authors
+ end
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/db/migrate/002_create_publications.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/db/migrate/002_create_publications.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,12 @@
+class CreatePublications < ActiveRecord::Migration
+ def self.up
+ create_table :publications do |t|
+ t.column :title, :string
+ t.column :reviewed, :boolean, :default => false
+ end
+ end
+
+ def self.down
+ drop_table :publications
+ end
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/db/migrate/003_create_authorships.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/db/migrate/003_create_authorships.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,16 @@
+class CreateAuthorships < ActiveRecord::Migration
+ def self.up
+ create_table :authorships do |t|
+ t.column :author_id, :integer
+ t.column :publication_id, :integer
+ t.column :name_on_paper, :string
+ t.column :auth_order, :integer
+ t.column :institution, :string
+ t.column :email, :string
+ end
+ end
+
+ def self.down
+ drop_table :authorships
+ end
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/db/migrate/004_create_bibtex_entries.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/db/migrate/004_create_bibtex_entries.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,35 @@
+class CreateBibtexEntries < ActiveRecord::Migration
+ def self.up
+ create_table :bibtex_entries do |t|
+ t.column :publication_id, :integer
+ t.column :entry_type, :integer
+ t.column :address, :string
+ t.column :annote, :string
+ t.column :booktitle, :string
+ t.column :chapter, :string
+ t.column :crossref, :string
+ t.column :edition, :string
+ t.column :editor, :string
+ t.column :eprint, :string
+ t.column :howpublished, :string
+ t.column :journal, :string
+ t.column :key, :string
+ t.column :month, :string
+ t.column :note, :text
+ t.column :number, :string
+ t.column :organization, :string
+ t.column :pages, :string
+ t.column :publisher, :string
+ t.column :school, :string
+ t.column :series, :string
+ t.column :type, :string
+ t.column :url, :string
+ t.column :volume, :integer
+ t.column :year, :integer
+ end
+ end
+
+ def self.down
+ drop_table :bibtex_entries
+ end
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/db/migrate/005_create_projects_publications_join_table.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/db/migrate/005_create_projects_publications_join_table.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,12 @@
+class CreateProjectsPublicationsJoinTable < ActiveRecord::Migration
+ def self.up
+ create_table :projects_publications, :id => false do |t|
+ t.integer :project_id
+ t.integer :publication_id
+ end
+ end
+
+ def self.down
+ drop_table :projects_publications
+ end
+end
\ No newline at end of file
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/db/migrate/006_create_bibtex_entry_types.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/db/migrate/006_create_bibtex_entry_types.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,13 @@
+class CreateBibtexEntryTypes < ActiveRecord::Migration
+ def self.up
+ create_table :bibtex_entry_types do |t|
+ t.string :name
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :bibtex_entry_types
+ end
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/db/migrate/007_add_external_url_column_to_publications.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/db/migrate/007_add_external_url_column_to_publications.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,9 @@
+class AddExternalUrlColumnToPublications < ActiveRecord::Migration
+ def self.up
+ add_column :publications, :external_url, :string
+ end
+
+ def self.down
+ remove_column :publications, :external_url
+ end
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/db/seed_data/bibtex_entry_types_list.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/db/seed_data/bibtex_entry_types_list.txt Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,14 @@
+inproceedings
+conference
+article
+masterthesis
+phdthesis
+book
+booklet
+inbook
+incollection
+manual
+techreport
+proceedings
+unpublished
+misc
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/init.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/init.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,51 @@
+require 'redmine'
+require 'dispatcher'
+
+RAILS_DEFAULT_LOGGER.info 'Starting Bibliography Plugin for RedMine'
+
+# Patches to the Redmine core.
+Dispatcher.to_prepare :redmine_model_dependencies do
+ require_dependency 'project'
+ require_dependency 'user'
+ require_dependency 'mailer'
+
+ unless Project.included_modules.include? Bibliography::ProjectPublicationsPatch
+ Project.send(:include, Bibliography::ProjectPublicationsPatch)
+ end
+
+ unless User.included_modules.include? Bibliography::UserAuthorPatch
+ User.send(:include, Bibliography::UserAuthorPatch)
+ end
+
+ unless Mailer.included_modules.include? Bibliography::MailerPatch
+ Mailer.send(:include, Bibliography::MailerPatch)
+ end
+
+
+end
+
+
+# Plugin Info
+Redmine::Plugin.register :redmine_bibliography do
+ name 'Redmine Bibliography plugin'
+ author 'Chris Cannam, Luis Figueira'
+ description 'This is a bibliography management plugin for Redmine'
+ version '0.0.1'
+ url 'http://example.com/path/to/plugin'
+ author_url 'http://example.com/about'
+
+ settings :default => { 'menu' => 'Bibliography' }, :partial => 'settings/bibliography'
+
+ project_module :redmine_bibliography do
+ permission :publications, { :publications => :index }, :public => true
+ permission :edit_publication, {:publications => [:edit, :update]}
+ permission :add_publication, {:publications => [:new, :create]}
+ permission :delete_publication, {:publications => :destroy}
+
+ end
+
+ # 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 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/lang/en.yml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/lang/en.yml Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,2 @@
+# English strings go here
+my_label: "My label"
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/lib/bibliography/mailer_patch.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/lib/bibliography/mailer_patch.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,31 @@
+require_dependency 'mailer'
+
+module Bibliography
+ module MailerPatch
+ def self.included(base) # :nodoc:
+
+ # Builds a tmail object used to email the specified user that a publication was created and the user is
+ # an author of that publication
+ #
+ # Example:
+ # publication_added(user) => tmail object
+ # Mailer.deliver_add_to_project(user) => sends an email to the registered user
+ def publication_added(user, publication, project)
+
+ @publication = publication
+ @project = project
+
+ set_language_if_valid user.language
+ recipients user.mail
+ subject l(:mail_subject_publication_added, Setting.app_title)
+ body :publication_url => url_for( :controller => 'publications', :action => 'show', :id => publication.id ),
+ :publication_title => publication.title
+
+ render_multipart('publication_added', body)
+
+ end
+
+
+ end
+ end
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/lib/bibliography/project_publications_patch.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/lib/bibliography/project_publications_patch.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,25 @@
+require_dependency 'project'
+
+module Bibliography
+ module ProjectPublicationsPatch
+ def self.included(base)
+ base.class_eval do
+ has_and_belongs_to_many :publications, :uniq => true
+
+ named_scope :like, lambda {|q|
+ s = "%#{q.to_s.strip.downcase}%"
+ {:conditions => ["LOWER(name) LIKE :s OR LOWER(homepage) LIKE :s", {:s => s}],
+ :order => 'name'
+ }
+ }
+ end
+ end #self.included
+
+ module ProjectMethods
+
+
+
+
+ end #ProjectMethods
+ end #ProjectPublicationsPatch
+end #RedmineBibliography
\ No newline at end of file
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,45 @@
+require_dependency 'user'
+
+module Bibliography
+ module UserAuthorPatch
+ def self.included(base)
+ base.send(:include, InstanceMethods)
+ extend ClassMethods
+
+ end #self.included
+
+ module ClassMethods
+ end
+
+ module InstanceMethods
+
+ def institution
+ unless self.ssamr_user_detail.nil?
+ institution_name = self.ssamr_user_detail.institution_name
+ else
+ institution_name = "No Institution Set"
+ end
+ return institution_name
+ end
+
+ def get_author_info
+ # TODO: DELETE THIS METHOD??
+ info = {
+ :name_on_paper => self.name,
+ :email => self.mail,
+ :institution => "",
+ :author_user_id => self.id,
+ :is_user => "1"
+ }
+
+ if not self.ssamr_user_detail.nil?
+ info[:institution] = self.ssamr_user_detail.institution_name
+ end
+
+ return info
+ end
+
+ end #InstanceMethods
+
+ end #UserPublicationsPatch
+end #RedmineBibliography
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/lib/tasks/seed_bibtex_entry_types.rake
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/lib/tasks/seed_bibtex_entry_types.rake Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,20 @@
+namespace :redmine do
+ namespace :plugins do
+ namespace :redmine_bibliography do
+
+ task :seed_bibtex_entry_types => :environment do
+ desc "Seeds the Bibtex Entry Types Table"
+
+ quoted = ActiveRecord::Base.connection.quote_table_name('bibtex_entry_types')
+ ActiveRecord::Base.connection.execute("TRUNCATE #{quoted}")
+
+ open(File.dirname(__FILE__) + "/../../db/seed_data/bibtex_entry_types_list.txt") do |bibtex_entry_types|
+ bibtex_entry_types.read.each_line do |bibtex_entry_type|
+ BibtexEntryType.create(:name => bibtex_entry_type.chomp)
+ end
+ end
+ end
+
+ end
+ end
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/test/fixtures/authors.yml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/test/fixtures/authors.yml Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,17 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+one:
+ id: 1
+ user_id:
+ name: MyString
+two:
+ id: 2
+ user_id:
+ name: MyString
+one:
+ id: 3
+ user_id:
+ name: MyString
+two:
+ id: 4
+ user_id:
+ name: MyString
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/test/fixtures/authorships.yml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/test/fixtures/authorships.yml Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,33 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+one:
+ id: 1
+ author_id: 1
+ publication_id: 1
+ name_on_paper: Yih-Farn R. Chen
+ order: 1
+ institution:
+ email: MyString
+two:
+ id: 2
+ author_id: 2
+ publication_id: 1
+ name_on_paper: Glenn S. Fowler
+ order: 2
+ institution:
+ email: MyString
+three:
+ id: 3
+ author_id: 1
+ publication_id: 1
+ name_on_paper: Yih-Farn R. Chen
+ order: 1
+ institution:
+ email: MyString
+four:
+ id: 4
+ author_id: 2
+ publication_id: 1
+ name_on_paper: Glenn S. Fowler
+ order: 2
+ institution:
+ email: MyString
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/test/fixtures/bibtex_entries.yml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/test/fixtures/bibtex_entries.yml Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,6 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+one:
+ id: 1
+ entry_type: InProceedings
+ booktitle: International Conference on Software Maintenance
+ year: 1995
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/test/fixtures/publications.yml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/test/fixtures/publications.yml Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,9 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+one:
+ id: 1
+ title: Test Fixture Title No1
+ bibtex_entry_id: 1
+two:
+ id: 2
+ title: MyString
+ bibtex_entry_id: MyString
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/test/functional/authors_controller_test.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/test/functional/authors_controller_test.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class AuthorsControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/test/functional/authorships_controller_test.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/test/functional/authorships_controller_test.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class AuthorshipsControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/test/functional/publications_controller_test.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/test/functional/publications_controller_test.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class PublicationsControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/test/test_helper.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/test/test_helper.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,24 @@
+# Load the normal Rails helper
+require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper')
+require 'publications_controller'
+
+# Ensure that we are using the temporary fixture path
+Engines::Testing.set_fixture_path
+
+class BibliographyControllerTest < ActionController::TestCase
+ fixtures :all
+
+ def setup
+ end
+
+ def test_publication
+
+ end
+
+
+ def test_routing
+ assert_routing(
+ {:method => :get, :path => '/requirements'},
+ :controller => 'requirements', :action => 'index'
+ )
+ end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/test/unit/author_test.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/test/unit/author_test.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class AuthorTest < ActiveSupport::TestCase
+ fixtures :authors
+
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/test/unit/authorship_test.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/test/unit/authorship_test.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class AuthorshipTest < ActiveSupport::TestCase
+ fixtures :authorships
+
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/test/unit/bibtex_entry_test.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/test/unit/bibtex_entry_test.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class BibtexEntryTest < ActiveSupport::TestCase
+ fixtures :bibtex_entries
+
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end
diff -r 7fc15203288c -r a8e402f48723 vendor/plugins/redmine_bibliography/test/unit/publication_test.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/test/unit/publication_test.rb Fri Sep 16 15:51:18 2011 +0100
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class PublicationTest < ActiveSupport::TestCase
+ fixtures :publications
+
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end