# HG changeset patch # User luisf # Date 1316194819 -3600 # Node ID 1710ec37bb6aa18d21013e1b01187eb49f0efff1 # Parent 3954b253cdb3cecb34ca1aba4d33767703adc1f4# Parent f098cfb337217f92bcbf16cea794cb1ab14052f5 Merge from branch "feature_36" diff -r 3954b253cdb3 -r 1710ec37bb6a .hgtags --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgtags Fri Sep 16 18:40:19 2011 +0100 @@ -0,0 +1,1 @@ +202986dd17e4e02b3622b65cf38f358b67a393e8 bibliography_plugin_alpha diff -r 3954b253cdb3 -r 1710ec37bb6a app/models/project.rb --- a/app/models/project.rb Fri Jul 29 19:28:55 2011 +0100 +++ b/app/models/project.rb Fri Sep 16 18:40:19 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 3954b253cdb3 -r 1710ec37bb6a app/views/members/_list.rhtml --- a/app/views/members/_list.rhtml Fri Jul 29 19:28:55 2011 +0100 +++ b/app/views/members/_list.rhtml Fri Sep 16 18:40:19 2011 +0100 @@ -10,7 +10,7 @@
<%= avatar(member.user, :size => "24") %> <%= link_to_user member.principal %> - +
<%=h member.roles.sort.collect(&:to_s).join(', ') %>
diff -r 3954b253cdb3 -r 1710ec37bb6a app/views/my/blocks/_issueswatched.rhtml --- a/app/views/my/blocks/_issueswatched.rhtml Fri Jul 29 19:28:55 2011 +0100 +++ b/app/views/my/blocks/_issueswatched.rhtml Fri Sep 16 18:40:19 2011 +0100 @@ -3,7 +3,7 @@ <%= render :partial => 'issues/list_simple', :locals => { :issues => watched_issues } %> <% if watched_issues.length > 0 %> -

<%= link_to l(:label_issue_view_all), :controller => 'issues', +

<%= link_to l(:label_issue_view_all_watched), :controller => 'issues', :action => 'index', :set_filter => 1, :watcher_id => 'me', diff -r 3954b253cdb3 -r 1710ec37bb6a app/views/projects/index.rhtml --- a/app/views/projects/index.rhtml Fri Jul 29 19:28:55 2011 +0100 +++ b/app/views/projects/index.rhtml Fri Sep 16 18:40:19 2011 +0100 @@ -4,7 +4,6 @@

<%= link_to l(:label_overall_activity), { :controller => 'activities', :action => 'index' }%> - <%= '| ' + link_to(l(:label_issue_view_all), { :controller => 'issues' }) if User.current.allowed_to?(:view_issues, nil, :global => true) %> <%= '| ' + link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %>
diff -r 3954b253cdb3 -r 1710ec37bb6a app/views/settings/_general.rhtml --- a/app/views/settings/_general.rhtml Fri Jul 29 19:28:55 2011 +0100 +++ b/app/views/settings/_general.rhtml Fri Sep 16 18:40:19 2011 +0100 @@ -9,8 +9,8 @@

<%= setting_text_area :welcome_text, :cols => 60, :rows => 5, :class => 'wiki-edit' %>

<%= wikitoolbar_for 'settings_welcome_text' %> -

<%= setting_text_field :attachment_max_size, :size => 6 %> <%= l(:"number.human.storage_units.units.kb") %>

- <%= wikitoolbar_for 'settings_tipoftheday_text' %> +

<%= setting_text_area :tipoftheday_text, :cols => 60, :rows => 5, :class => 'wiki-edit' %>

+<%= wikitoolbar_for 'settings_tipoftheday_text' %>

<%= setting_text_field :attachment_max_size, :size => 6 %> <%= l(:"number.human.storage_units.units.kb") %>

diff -r 3954b253cdb3 -r 1710ec37bb6a app/views/users/show.rhtml --- a/app/views/users/show.rhtml Fri Jul 29 19:28:55 2011 +0100 +++ b/app/views/users/show.rhtml Fri Sep 16 18:40:19 2011 +0100 @@ -24,7 +24,7 @@ <%= textilizable @description %>

<%=l(:label_ssamr_institution)%>

-<%= h @institution_name %> +

<%= h @institution_name %>

<% unless @memberships.empty? %> diff -r 3954b253cdb3 -r 1710ec37bb6a config/locales/en.yml --- a/config/locales/en.yml Fri Jul 29 19:28:55 2011 +0100 +++ b/config/locales/en.yml Fri Sep 16 18:40:19 2011 +0100 @@ -390,6 +390,8 @@ setting_commit_logtime_enabled: Enable time logging setting_commit_logtime_activity_id: Activity for logged time setting_gantt_items_limit: Maximum number of items displayed on the gantt chart + setting_tipoftheday_text: Tip of the Day + setting_notifications_text: Notifications permission_add_project: Create project permission_add_subprojects: Create subprojects @@ -473,7 +475,7 @@ label_user_new: New user label_user_anonymous: Anonymous label_project: Project - label_project_new: New project + label_project_new: Start a new project label_project_plural: Projects label_my_project_plural: My Projects label_other_project_plural: Other Projects @@ -489,6 +491,7 @@ label_issue_new: New issue label_issue_plural: Issues label_issue_view_all: View all issues + label_issue_view_all_watched: View all watched issues label_issues_by: "Issues by %{value}" label_issue_added: Issue added label_issue_updated: Issue updated diff -r 3954b253cdb3 -r 1710ec37bb6a public/stylesheets/application.css --- a/public/stylesheets/application.css Fri Jul 29 19:28:55 2011 +0100 +++ b/public/stylesheets/application.css Fri Sep 16 18:40:19 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 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/controllers/authors_controller.rb --- a/vendor/plugins/redmine_bibliography/app/controllers/authors_controller.rb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/authors_controller.rb Fri Sep 16 18:40:19 2011 +0100 @@ -1,7 +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 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Fri Sep 16 18:40:19 2011 +0100 @@ -1,9 +1,12 @@ +# -*- coding: utf-8 -*- # vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb class PublicationsController < ApplicationController unloadable - # before_filter :find_project, :except => [:autocomplete_for_project, :add_author, :sort_authors, :autocomplete_for_author] + 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 @@ -13,26 +16,27 @@ @publication.build_bibtex_entry # and at least one author - # @publication.authorships.build.build_author - - @project_id = params[:project_id] - @current_user = User.current + # @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]) - def create - find_project_by_project_id - + @author_options = [] + @publication = Publication.new(params[:publication]) - - # @project = Project.find(params[:project_id]) - @publication.projects << @project - + @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.id + redirect_to :action => :show, :id => @publication, :project_id => @project else - render :action => 'new' + render :action => 'new', :project_id => @project end end @@ -58,26 +62,53 @@ 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 { "ERRO ADD AUTHOR" } + 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 + @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]) @@ -95,12 +126,10 @@ def show find_project_by_project_id unless params[:project_id].nil? - - @publication = Publication.find(params[:id]) - + if @publication.nil? - @publications = Publication.all - render "index", :alert => 'The publication was not found!' + @publications = Publication.all + render "index", :alert => 'The publication was not found!' else @authors = @publication.authors @bibtext_entry = @publication.bibtex_entry @@ -186,17 +215,6 @@ end - def add_project - @projects = Project.find(params[:publication][:project_ids]) - @publication = Publication.find(params[:id]) - @publication.projects << @projects - - # TODO luisf should also respond to HTML??? - respond_to do |format| - format.js - end - end - def autocomplete_for_project @publication = Publication.find(params[:id]) @@ -205,36 +223,119 @@ render :layout => false end - def autocomplete_for_author + def autocomplete_for_author @results = [] - authors_list = Author.like(params[:q]).find(:all, :limit => 100) + 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 \"#{authors_list.size}\" authors and \"#{users_list.size}\" users" + logger.debug "Query for \"#{params[:q]}\" returned \"#{authorships_list.size}\" authorships and \"#{users_list.size}\" users" - # need to subtract both lists - # give priority to the users - users_list.each do |user| - @results << user + @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 - authors_list.each do |author| - @results << author unless users_list.include?(author.user_id) + 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 - - render :layout => false end - def sort_authors - params[:authors].each_with_index do |id, index| - Author.update_all(['order=?', index+1], ['id=?', id]) + 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 identify_author + 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 diff -r 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/helpers/authors_helper.rb --- a/vendor/plugins/redmine_bibliography/app/helpers/authors_helper.rb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/helpers/authors_helper.rb Fri Sep 16 18:40:19 2011 +0100 @@ -17,4 +17,12 @@ 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 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/helpers/my_helper.rb --- a/vendor/plugins/redmine_bibliography/app/helpers/my_helper.rb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/helpers/my_helper.rb Fri Sep 16 18:40:19 2011 +0100 @@ -13,14 +13,10 @@ projs = [] publication.projects.each do |proj| - projs << link_to(proj.name, proj) + projs << link_to(proj.name, proj) end - if projs.size < 3 - s << '' << projs.join(', ') << '' - else - s << projs.join(', ') - end + s << projs.join(', ') s end @@ -33,11 +29,8 @@ auths << h(auth.name_on_paper) end - if auths.size < 3 - s << '' << auths.join(', ') << '' - else - s << auths.join(', ') - end + s << auths.join(', ') + s end diff -r 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb --- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Fri Sep 16 18:40:19 2011 +0100 @@ -1,6 +1,13 @@ +# -*- 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| @@ -9,36 +16,30 @@ s end - def identify_author(author) - if author.class == User - author_info = { - :name_on_paper => author.name, - :user_id => author.id - } + 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 - else - if author.class == Author - author_info = { - :name_on_paper => author.name, - :user_id => author.user_id, - :id => author.id - } - end - end - - link_to_function(author.name, "update_author_info(this," + author_info.to_json + ")") - end - - def choose_author_link(name, authors_users) - s = '' - authors_users.sort.each do |author_user| - s << "#{identify_author author_user}\n" - end - s + 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)") + f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)", :class => 'icon icon-del') end def link_to_add_fields(name, f, association) @@ -56,41 +57,81 @@ 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 render_projects_list(publication) - s = "" - projs = [] + def form_object_id(object_name) + str = object_name.split("\[").last().gsub("\]","") + str.to_sym + end + + def render_authorships_list(publication) + s = '

' - publication.projects.each do |proj| - projs << link_to_project(proj) + publication.authorships.each do |authorship| + + if authorship.author.nil? + # legacy reasons… + s << h(authorship.name_on_paper) + else + if authorship.author.user.nil? + s << link_to(authorship.name_on_paper, :controller => 'authors', :action => 'show', :id => authorship.author) + else + s << link_to(authorship.name_on_paper, :controller => 'users', :action => 'show', :id => authorship.author.user) + end end + s << "
#{authorship.institution}

" + end + + s + end + - if projs.size < 3 - s << '' << projs.join(', ') << '' - else - s << projs.join(', ') - end - s + def render_projects_list(publication, show_delete_icon) + s= "" + + publication.projects.visible.each do |proj| + s << link_to_project(proj, {}, :class => 'publication_project') + + if show_delete_icon + if 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 + end + + s << "
" + end + + s end def show_bibtex_fields(bibtex_entry) s = "" - - bibtex_entry.attributes.each do |field| - if field[1] != nil - s << "

" + field[0].titleize + "

" - - if field[0] == "entry_type" - s << bibtex_entry.entry_type_name.capitalize - else - s << bibtex_entry.attributes[field[0]].to_s - end + 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 diff -r 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/models/authorship.rb --- a/vendor/plugins/redmine_bibliography/app/models/authorship.rb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/authorship.rb Fri Sep 16 18:40:19 2011 +0100 @@ -1,27 +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' + } + } - # setter and getter for virtual attribute :user_id - def user_id - end + def name + return self.name_on_paper + end - def user_id=(uid) - unless uid.blank? - user = User.find(uid) - if user.author.nil? - # TODO: should reflect the name_on_paper parameter - author = Author.new :name => user.name - author.save! - user.author = author - user.save! - end - - self.author_id = user.author.id - 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 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/models/bibtex_entry.rb --- a/vendor/plugins/redmine_bibliography/app/models/bibtex_entry.rb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/bibtex_entry.rb Fri Sep 16 18:40:19 2011 +0100 @@ -9,6 +9,8 @@ BibtexEntryType.find(entry_type).name end - - + def entry_type_label + entry_type = self.entry_type + BibtexEntryType.find(entry_type).label + end end diff -r 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/models/bibtex_entry_type.rb --- a/vendor/plugins/redmine_bibliography/app/models/bibtex_entry_type.rb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/bibtex_entry_type.rb Fri Sep 16 18:40:19 2011 +0100 @@ -1,2 +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 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/models/publication.rb --- a/vendor/plugins/redmine_bibliography/app/models/publication.rb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb Fri Sep 16 18:40:19 2011 +0100 @@ -3,12 +3,13 @@ class Publication < ActiveRecord::Base unloadable - has_many :authorships, :dependent => :destroy + 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 @@ -16,4 +17,47 @@ 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 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/views/authors/index.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/authors/index.html.erb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/authors/index.html.erb Fri Sep 16 18:40:19 2011 +0100 @@ -1,4 +1,4 @@ -

Authors#index

+

<%=l(:label_authors_index)%>

@@ -11,7 +11,7 @@ <% @authors.each do |author|%>
- <%= h author.name %> + <%= link_to_author author %> <%= link_to author.user unless author.user.nil? %> diff -r 3954b253cdb3 -r 1710ec37bb6a 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 18:40:19 2011 +0100 @@ -0,0 +1,24 @@ +

<%=l(:label_authors_show)%>

+ +
+ + + + + + + + + + + <% @author.authorships.each do |authorship| %> + + + + + + + <% end %> + +
<%=l(:field_authorship_publication_title)%><%=l(:field_authorship_name)%><%=l(:field_authorship_email)%><%=l(:field_authorship_institution)%>
<%= link_to_publication(authorship.publication) %><%= h authorship.name_on_paper %><%= h authorship.institution %>
+
\ No newline at end of file diff -r 3954b253cdb3 -r 1710ec37bb6a 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 18:40:19 2011 +0100 @@ -0,0 +1,1 @@ +<%= l(:mail_body_publication_added, :publication => @publication.title, :project => @project.name) %> diff -r 3954b253cdb3 -r 1710ec37bb6a 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 18:40:19 2011 +0100 @@ -0,0 +1,2 @@ +<%= l(:mail_body_publication_added, :publication => @publication.title, :project => @project.name) %> + diff -r 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/views/projects/_bibliography_box.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/projects/_bibliography_box.html.erb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/projects/_bibliography_box.html.erb Fri Sep 16 18:40:19 2011 +0100 @@ -1,8 +1,26 @@ <% if @project.publications.any? %> -
-

<%=l(:label_publications_plural)%>

-

<% @project.publications.each do |publication| %> - <%= link_to publication.title, :controller => 'publications', :action => 'show', :id => publication, :project_id => @project %>
- <% end %>

+<%= 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 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/views/projects/show.rhtml --- a/vendor/plugins/redmine_bibliography/app/views/projects/show.rhtml Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/projects/show.rhtml Fri Sep 16 18:40:19 2011 +0100 @@ -3,10 +3,41 @@ <%= link_to l(:label_subproject_new), {:controller => 'projects', :action => 'new', :parent_id => @project}, :class => 'icon icon-add' %> <% end %> - <%= link_to l(:label_add_publication_to_project), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %> - + <% 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)%>

@@ -79,6 +110,8 @@ <%= 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 %> diff -r 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml --- a/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Fri Sep 16 18:40:19 2011 +0100 @@ -1,28 +1,59 @@ +<%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %> + +
-

- <%= f.text_field :name_on_paper %>
- <%= h l("text_author_name_on_paper") %>
- - <%= link_to_function "Add Me as Author", "update_author_info(this," + User.current.get_author_info.to_json + ")", :class => 'icon icon-add', :id => "add_me_as_author" %> + - <%= observe_field( form_tag_id(f.object_name, :name_on_paper), :frequency => 0.5, :update => form_tag_id(f.object_name, :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 %> -
- - <%= f.text_field :institution, :size => 60 %>
- <%= h l("text_author_institution") %>
+
> +

+ <%= 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.text_field :email, :size => 60 %>
- <%= h l("text_author_email") %>
- - <%= f.hidden_field :user_id %> - - <%= link_to_remove_fields l("remove_author"), f %> - +

+ <%= 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" )} %> +

+ +

+

+
+ +
+ +
+

+
+ +
+

+ <%= f.text_field :name_on_paper, {:class => ("readonly" unless params[:action] == "new") } %>

+

><%= h l("text_author_name_on_paper") %>

+

<%= f.text_field :institution, {:class => ("readonly" unless params[:action] == "new") } %>

+

><%= h l("text_author_institution") %>

+

<%= f.text_field :email, {:class => ("readonly" unless params[:action] == "new") } %>

+

><%= h l("text_author_email") %>

+

+
+ + + + +

+ + <% 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 %>

-
\ No newline at end of file +
+
diff -r 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb Fri Sep 16 18:40:19 2011 +0100 @@ -1,26 +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' %> +

- -

- <%= f.collection_select(:entry_type, BibtexEntryType.find(:all), :id, :name, {:selected => @selected_bibtex_entry_type_id, :prompt => true}) %> -

-

- <%= f.text_field :year, :size => 60 %> -

-

- <%= f.text_field :chapter, :size => 60 %> -

-

- <%= f.text_field :editor, :size => 60 %> -

-

- <%= f.text_field :booktitle,:size => 60 %> -

-

- <%= f.text_field :publisher,:size => 60 %> -

-

- <%= f.text_field :pages, :size => 60 %> -

- -
\ No newline at end of file diff -r 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb Fri Sep 16 18:40:19 2011 +0100 @@ -1,30 +1,31 @@ +<%= f.error_messages %> -
- <%= 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 :title, :required => true, :size => 60 %> + <%= 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_another_author), f, :authorships %>

- +
-
-

Other Details

- <% f.fields_for :bibtex_entry do |builder| -%> - <%= render :partial => 'bibtex_fields', :locals => { :f => builder} %> - <%- end -%> +
+

<%= 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 %> +
-<% content_for :sidebar do %> - placeholder - -<% end %> - - diff -r 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb Fri Sep 16 18:40:19 2011 +0100 @@ -1,1 +1,1 @@ -<%= render_projects_list(@publication) %> \ No newline at end of file +<%= render_projects_list(@publication, true) %> diff -r 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.rhtml --- a/vendor/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.rhtml Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.rhtml Fri Sep 16 18:40:19 2011 +0100 @@ -1,3 +1,4 @@ <% if params[:q] && params[:q].length > 1 %> - <%= choose_author_link 'publication[author_ids][]', @results %> + <%= choose_author_link @object_name, @results %> <% end %> + diff -r 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb Fri Sep 16 18:40:19 2011 +0100 @@ -1,15 +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_id, :action => :update }, :builder => TabularFormBuilder do |f| -%> +<% 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 } %> | + <%= 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 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb Fri Sep 16 18:40:19 2011 +0100 @@ -1,33 +1,40 @@ -
- <%= link_to l(:label_publication_new), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %> +
+ <% 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 %>
-
-

Publications#index

+ <% if @project %> +

<%= l(:label_all_publications_for_project, :project => @project.name) %>

+ <% else %> +

<%= l(:label_all_publications) %>

+ <% end %> +
+ + + + + + + -
<%= l(:title) %><%= l(:authors) %><%= l(:year) %><%= l(:associated_projects) %>
- - - - - - <% @publications.each do |publication| %> - - - - - <% end %> + <%- @publications.each do |publication| -%> + <%- if publication.projects.visible.length > 0 -%> + + + + + + <%- end -%> + <%- end -%>
NumberTitle
<%= publication.id %><%= link_to publication.title, :controller => "publications", :action => "show", :id => publication, :project_id => @project %>
<%= link_to publication.title, :controller => "publications", :action => "show", :id => publication, :project_id => @project %> + <%= render_authorships_list(publication) %> + <%= publication.bibtex_entry.year %> + <%= render_projects_list(publication, false) %> +
- -
- -
- placeholder div -
- +
<% content_for :sidebar do %> - Sidebar <% end %> - \ No newline at end of file + diff -r 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb Fri Sep 16 18:40:19 2011 +0100 @@ -1,10 +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_id, :action => :create }, :builder => TabularFormBuilder do |f| -%> +<% form_for @publication, :url => { :project_id => @project, :action => :create }, :builder => TabularFormBuilder do |f| -%> <%= render :partial => 'form', :locals => { :f => f } %> +
<%= f.submit %> -<% end %> \ No newline at end of file +<% end %> diff -r 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb Fri Sep 16 18:40:19 2011 +0100 @@ -1,41 +1,60 @@ +<%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %> +

<%=l(:label_publication_show)%>

-
-

Title

-<%= h @publication.title %> +
+

+ <%= h @publication.title %> +

<%= l(:authors) %>

    - <% for authorship in @publication.authorships %> + <% for authorship in @publication.authorships.find(:all, :order => :auth_order) %> <% content_tag_for :li, authorship do %> - <%= h authorship.name_on_paper %>
    - <%= h authorship.institution %>
    - <% end %> - <% end %> + <%- 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 -%>
-<%= sortable_element("authorships", :url => { :controller => :publications, :action => :sort_authors }) %> - -
+<%- 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 -%> -

- <%= link_to l(:label_publication_edit), { :controller => "publications", :action => "edit", :id => @publication, :project_id => @project } %> | - <%= link_to "Destroy", @publication, :confirm => 'Are you sure?', :method => :delete %> | - <%= link_to "View All", publications_path %> -

+ +<% 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 %> -
- -

<%=l(:label_publication_project_index)%>

+<% 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' %> -
\ No newline at end of file + <%- end -%> +<% end %> diff -r 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/app/views/users/show.rhtml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/users/show.rhtml Fri Sep 16 18:40:19 2011 +0100 @@ -0,0 +1,104 @@ +<%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %> + +
+<%= link_to(l(:button_edit), edit_user_path(@user), :class => 'icon icon-edit') if User.current.admin? %> +
+ +

<%= avatar @user, :size => "50" %> <%=h @user.name %>

+ +
+
    + <% unless @user.pref.hide_mail %> +
  • <%=l(:field_mail)%>: <%= mail_to(h(@user.mail), nil, :encode => 'javascript') %>
  • + <% end %> + <% @user.visible_custom_field_values.each do |custom_value| %> + <% if !custom_value.value.blank? %> +
  • <%=h custom_value.custom_field.name%>: <%=h show_value(custom_value) %>
  • + <% end %> + <% end %> +
  • <%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %>
  • + <% unless @user.last_login_on.nil? %> +
  • <%=l(:field_last_login_on)%>: <%= format_date(@user.last_login_on) %>
  • + <% end %> +
+ +

<%=l(:label_ssamr_description)%>

+<%= textilizable @description %> + +

<%=l(:label_ssamr_institution)%>

+

<%= h @institution_name %>

+ + +<% unless @memberships.empty? %> +

<%=l(:label_project_plural)%>

+
    +<% for membership in @memberships %> +
  • <%= link_to_project(membership.project) %> + (<%=h membership.roles.sort.collect(&:to_s).join(', ') %>, <%= format_date(membership.created_on) %>)
  • +<% end %> +
+<% end %> +<%= call_hook :view_account_left_bottom, :user => @user %> +
+ +
+ +
+ <% @publications = Publication.all(:include => :authors, :conditions => "authors.id = #{@user.author.id}") %> + +

<%=l(:publications) %> <%= "(" + @publications.count.to_s + ")" %>

+ + <% @publications.each do |publication|%> +
+ <%= link_to publication.title, :controller => 'publications', :action => 'show', :id => publication %> +
+ +
+ + <%= publication.authorships.map { |a| h a.name_on_paper }.join(', ') %> + + <% if publication.bibtex_entry.year.to_s != "" %> + + <%= publication.bibtex_entry.year %> + + <% end %> +
+ <% end %> +
+ + + +<% unless @events_by_day.empty? %> +

<%= link_to l(:label_activity), :controller => 'activities', :action => 'index', :id => nil, :user_id => @user, :from => @events_by_day.keys.first %>

+ +

+<%=l(:label_reported_issues)%>: <%= Issue.count(:conditions => ["author_id=?", @user.id]) %> +

+ +
+<% @events_by_day.keys.sort.reverse.each do |day| %> +

<%= format_activity_day(day) %>

+
+<% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%> +
+ <%= format_time(e.event_datetime, false) %> + <%= content_tag('span', h(e.project), :class => 'project') %> + <%= link_to format_activity_title(e.event_title), e.event_url %>
+
<%= format_activity_description(e.event_description) %>
+<% end -%> +
+<% end -%> +
+ +<% other_formats_links do |f| %> + <%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => nil, :user_id => @user, :key => User.current.rss_key} %> +<% end %> + +<% content_for :header_tags do %> + <%= auto_discovery_link_tag(:atom, :controller => 'activities', :action => 'index', :user_id => @user, :format => :atom, :key => User.current.rss_key) %> +<% end %> +<% end %> +<%= call_hook :view_account_right_bottom, :user => @user %> +
+ +<% html_title @user.name %> diff -r 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/assets/javascripts/authors.js --- a/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Fri Sep 16 18:40:19 2011 +0100 @@ -1,24 +1,72 @@ function remove_fields(link) { - $(link).previous("input[type=hidden]").value = "1"; - $(link).up(".fields").hide(); + $(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).up().insert({ - before: content.replace(regexp, new_id) - }); + var new_id = new Date().getTime(); + var regexp = new RegExp("new_" + association, "g") + $(link).insert({ + before: content.replace(regexp, new_id) + }); } -function update_author_info(link, author_info){ +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(); + })} - $(link).up('div').up('div').select('input[id^=publication_authorships_attributes]').each( - function(e){ - key = e.name.split("[").last().trim().sub(']',''); - - // test for undefined - e.value = author_info[key]; - } - ) -} \ No newline at end of file +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 3954b253cdb3 -r 1710ec37bb6a 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 18:40:19 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 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/config/locales/en.yml --- a/vendor/plugins/redmine_bibliography/config/locales/en.yml Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/config/locales/en.yml Fri Sep 16 18:40:19 2011 +0100 @@ -1,40 +1,79 @@ # English strings go here for Rails i18n en: + project_module_redmine_bibliography: Bibliography + title: "Title" authors: "Authors" author: "Author" name: "Name" + year: "Year" + associated_projects: "Associated Projects" publications_box: "My Publications" 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" + 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_publication_projects: "Associated projects" field_author_name: Author - field_author_username: "Associated User" + 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" - bibtex_entry: - entry_type: "Bibtex Entry Type" - + 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_publications_plural: "Publications" + label_publication_plural: "Publications" + label_related_publication_plural: "Related publications" label_publication_new: "Create New Publication" - label_add_publication_to_project: "Add Publication to this project" + 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 Project to Publication" - label_project_search: "Search by name: " + 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_institution: "Author's institution name as on paper." - text_author_name_on_paper: "Name of the author as it appears on paper. (In case it applies, please use the autocomplete suggestions.)" + + text_author_search: "Search existing authors" # authorships model field_institution: "Institution" @@ -42,10 +81,9 @@ field_email: "Email Address" # bibtex_entries model - field_entry_type: "Entry Type" + field_entry_type: "Publication Type" field_id: "id" field_publication_id: "Publication_id" - field_entry_type: "Entry Type" field_address: "Address" field_annote: "Annote" field_booktitle: "Book Title" @@ -69,8 +107,45 @@ 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 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/config/routes.rb --- a/vendor/plugins/redmine_bibliography/config/routes.rb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/config/routes.rb Fri Sep 16 18:40:19 2011 +0100 @@ -1,3 +1,3 @@ ActionController::Routing::Routes.draw do |map| - map.resources :publications, :collection => { :sort_authors => :post } + map.resources :publications, :collection => { :sort_author_order => :post } end \ No newline at end of file diff -r 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/db/migrate/003_create_authorships.rb --- a/vendor/plugins/redmine_bibliography/db/migrate/003_create_authorships.rb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/db/migrate/003_create_authorships.rb Fri Sep 16 18:40:19 2011 +0100 @@ -4,7 +4,7 @@ t.column :author_id, :integer t.column :publication_id, :integer t.column :name_on_paper, :string - t.column :order, :integer + t.column :auth_order, :integer t.column :institution, :string t.column :email, :string end diff -r 3954b253cdb3 -r 1710ec37bb6a 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 18:40:19 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 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/db/seed_data/bibtex_entry_types_list.txt --- a/vendor/plugins/redmine_bibliography/db/seed_data/bibtex_entry_types_list.txt Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/db/seed_data/bibtex_entry_types_list.txt Fri Sep 16 18:40:19 2011 +0100 @@ -1,14 +1,14 @@ +inproceedings +conference article +masterthesis +phdthesis book booklet -conference inbook incollection -inproceedings manual -masterthesis +techreport +proceedings +unpublished misc -phdthesis -proceedings -techreport -unpublished diff -r 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/init.rb --- a/vendor/plugins/redmine_bibliography/init.rb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/init.rb Fri Sep 16 18:40:19 2011 +0100 @@ -7,6 +7,7 @@ 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) @@ -16,6 +17,11 @@ User.send(:include, Bibliography::UserAuthorPatch) end + unless Mailer.included_modules.include? Bibliography::MailerPatch + Mailer.send(:include, Bibliography::MailerPatch) + end + + end @@ -32,12 +38,14 @@ project_module :redmine_bibliography do permission :publications, { :publications => :index }, :public => true - permission :edit_redmine_bibliography, {:redmine_bibliography => [:edit, :update]}, :public => true - permission :add_publication, {:redmine_bibliography => [:new, :create]}, :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 \ No newline at end of file +end diff -r 3954b253cdb3 -r 1710ec37bb6a 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 18:40:19 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 3954b253cdb3 -r 1710ec37bb6a vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb --- a/vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb Fri Jul 29 19:28:55 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb Fri Sep 16 18:40:19 2011 +0100 @@ -6,10 +6,6 @@ base.send(:include, InstanceMethods) extend ClassMethods - base.class_eval do - has_one :publication - - end end #self.included module ClassMethods @@ -17,37 +13,33 @@ 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 => "", - :email => "", + :name_on_paper => self.name, + :email => self.mail, :institution => "", - :user_id => self.id + :author_user_id => self.id, + :is_user => "1" } - - unless self.author.nil? - logger.error { "We've got author" } - info[:name_on_paper] = self.author.name - if self.author.authorships.length > 0 - info[:email] = self.author.authorships.first.email - info[:institution] = self.author.authorships.first.institution - end + if not self.ssamr_user_detail.nil? + info[:institution] = self.ssamr_user_detail.institution_name + end - else - logger.error { "No author" } - - info[:name_on_paper] = "No Name" - info[:email] = self.mail - if not self.ssamr_user_detail.nil? - info[:institution] = self.ssamr_user_detail.institution_name - end - end - - return info - - end + return info + end + end #InstanceMethods end #UserPublicationsPatch -end #RedmineBibliography \ No newline at end of file +end #RedmineBibliography