Mercurial > hg > soundsoftware-site
changeset 695:1710ec37bb6a luisf
Merge from branch "feature_36"
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Fri, 16 Sep 2011 18:40:19 +0100 |
parents | 3954b253cdb3 (current diff) f098cfb33721 (diff) |
children | a0e028d6060a |
files | vendor/plugins/redmine_bibliography/app/views/publications/__author_form.html.erb |
diffstat | 44 files changed, 1141 insertions(+), 339 deletions(-) [+] |
line wrap: on
line diff
--- /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
--- 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) }
--- 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 @@ <dt id="member-<%= member.id %>" class="member <%= member.principal.class.name.downcase %> <%= User.current.logged? && User.current == member.user ? 'me' : nil %>"> <%= avatar(member.user, :size => "24") %> <span class="user"><%= link_to_user member.principal %></span> -<span class="email"><%= member.user.mail %></span> +<span class="email"><%= member.user.mail if !member.user.pref.hide_mail %></span> <dd id="member-<%= member.id %>" class="roles <%= member.principal.class.name.downcase %> <%= User.current.logged? && User.current == member.user ? 'me' : nil %>"> <span class="roles" id="member-<%= member.id %>-roles"><%=h member.roles.sort.collect(&:to_s).join(', ') %></span> </dd>
--- 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 %> -<p class="small"><%= link_to l(:label_issue_view_all), :controller => 'issues', +<p class="small"><%= link_to l(:label_issue_view_all_watched), :controller => 'issues', :action => 'index', :set_filter => 1, :watcher_id => 'me',
--- 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 @@ <div class="contextual"> <%= 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) %> </div>
--- 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 @@ <p><%= setting_text_area :welcome_text, :cols => 60, :rows => 5, :class => 'wiki-edit' %></p> <%= wikitoolbar_for 'settings_welcome_text' %> -<p><%= setting_text_field :attachment_max_size, :size => 6 %> <%= l(:"number.human.storage_units.units.kb") %></p> - <%= wikitoolbar_for 'settings_tipoftheday_text' %> +<p><%= setting_text_area :tipoftheday_text, :cols => 60, :rows => 5, :class => 'wiki-edit' %></p> +<%= wikitoolbar_for 'settings_tipoftheday_text' %> <p><%= setting_text_field :attachment_max_size, :size => 6 %> <%= l(:"number.human.storage_units.units.kb") %></p>
--- 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 %> <h3><%=l(:label_ssamr_institution)%></h3> -<%= h @institution_name %> +<p><%= h @institution_name %></p> <% unless @memberships.empty? %>
--- 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
--- 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;
--- 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
--- 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
--- 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
--- 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 << '<nobr>' << projs.join(', ') << '</nobr>' - 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 << '<nobr>' << auths.join(', ') << '</nobr>' - else - s << auths.join(', ') - end + s << auths.join(', ') + s end
--- 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 = "<em>No Authors found that match your search… sorry!</em>" + 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 = '<p>' - 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 << "<br /><em>#{authorship.institution}</em></p>" + end + + s + end + - if projs.size < 3 - s << '<nobr>' << projs.join(', ') << '</nobr>' - 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 << "<br />" + end + + s end def show_bibtex_fields(bibtex_entry) s = "" - - bibtex_entry.attributes.each do |field| - if field[1] != nil - s << "<h4>" + field[0].titleize + "</h4>" - - 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 << "<h4>" + l("field_#{key}") + "</h4>" + s << "<p>" + if key == "entry_type" + s << bibtex_entry.entry_type_label + else + s << value end + s << "</p>" end s end
--- 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
--- 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
--- 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
--- 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
--- 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 @@ -<h2>Authors#index</h2> +<h2><%=l(:label_authors_index)%></h2> <table class="list authors"> <thead><tr> @@ -11,7 +11,7 @@ <% @authors.each do |author|%> <tr id="author-<%= author.id %>" class="<%= cycle('odd', 'even') %>"> <td class="title"> - <%= h author.name %> + <%= link_to_author author %> </td> <td class="username "> <%= link_to author.user unless author.user.nil? %>
--- /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 @@ +<h2><%=l(:label_authors_show)%></h2> + +<div class="splitcontentleft"> + <table class="list authors"> + <thead> + <tr> + <th><%=l(:field_authorship_publication_title)%></th> + <th><%=l(:field_authorship_name)%></th> + <th><%=l(:field_authorship_email)%></th> + <th><%=l(:field_authorship_institution)%></th> + </tr> + </thead> + + <% @author.authorships.each do |authorship| %> + <tr id="authorship-<%= authorship.id %>" class="<%= cycle('odd', 'even') %>"> + <td class="title"><%= link_to_publication(authorship.publication) %></td> + <td class="name"><%= h authorship.name_on_paper %></td> + <td class="email"><%= h authorship.email %></td> + <td class="institution"><%= h authorship.institution %></td> + </tr> + <% end %> + </tbody> + </table> +</div> \ No newline at end of file
--- /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) %>
--- /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) %> +
--- 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? %> - <div class="bibliography box"> - <h3><%=l(:label_publications_plural)%></h3> - <p><% @project.publications.each do |publication| %> - <%= link_to publication.title, :controller => 'publications', :action => 'show', :id => publication, :project_id => @project %><br /> - <% end %></p> +<%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %> + <div id="bibliography"> + <div class="box"> + <h3><%=l(:label_related_publication_plural)%></h3> + + <dl> + <% @project.publications.each do |publication| %> + <dt> + <%= link_to publication.title, :controller => 'publications', :action => 'show', :id => publication, :project_id => @project %> + </dt> + <dd> + <span class="authors"> + <%= publication.authorships.map { |a| h a.name_on_paper }.join(', ') %> + </span> + <% if publication.bibtex_entry.year.to_s != "" %> + <span class="year"> + <%= publication.bibtex_entry.year %> + </span> + <% end %> + </dd> + <% end -%> + </dl> </div> +</div> <% end %>
--- 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 %> </div> +<% 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) %> +<div class="contextual"> +<%= link_to(l(:button_welcome_page_edit_this), {:controller => 'wiki', :action => 'edit', :project_id => @project, :id => Wiki.titleize("Overview")}, :class => 'icon icon-edit') %> +</div> +<% end %> +<% end %> + +<div class="contextual" style="clear: right"> +<ul> +<% unless @project.homepage.blank? %><li><%=l(:field_homepage)%>: <%= auto_link(h(@project.homepage)) %></li><% end %> +<% if @subprojects.any? %> + <li><%=l(:label_subproject_plural)%>: + <%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join(", ") %></li> +<% end %> +</ul> +</div> + +<%= render(:partial => "wiki/content", :locals => {:content => page.content_for_version()}) %> + +<% else %> + <h2><%=l(:label_overview)%></h2> <div class="splitcontentleft"> @@ -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 %>
--- 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' %> + + <div id="authors" class="fields"> - <p> - <%= f.text_field :name_on_paper %><br /> - <em><%= h l("text_author_name_on_paper") %></em><br /> - - <%= 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" %> +<!-- <h4><%= l("label_author_1") %></h4> --> - <%= 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') - %> - - <div id="<%= form_tag_id(f.object_name, :identify_author) %>"> - <% if params[:q] && params[:q].length > 1 %> - <%= select_author_links 'author[author_ids][]', @authors %> - <% end %> - </div> - - <%= f.text_field :institution, :size => 60 %><br /> - <em><%= h l("text_author_institution") %></em><br /> + <div id="<%= form_tag_id( f.object_name, :search_author ) %>" style=<%= "display:none;" unless params[:action] == "new" %> > + <p> + <%= 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' ) %> + </p> + <%# 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 %><br /> - <em><%= h l("text_author_email") %></em><br /> - - <%= f.hidden_field :user_id %> - - <%= link_to_remove_fields l("remove_author"), f %> - + <p> + <%= 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" )} %> + </p> + + <p style="margin-bottom: -2.5em; padding-bottom; 0"><label><%= l(:identify_author_question) %></label></p> + <p class="author_identify"> + <label class='inline'><%= radio_button_tag(:identify_author, "yes", false, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_yes ), :onclick => "identify_author_status($(this).value, #{form_object_id(f.object_name) });") %> <%= l(:identify_author_yes) %> </label><br /> + + <label class='inline'><%= radio_button_tag(:identify_author, "correct", false, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_corrections ), :onclick => "identify_author_status($(this).value, #{form_object_id(f.object_name) });") %> <%= l(:identify_author_correct) %> </label><br /> + + <label class='inline'><%= radio_button_tag(:identify_author, "no", true, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_no ), :onclick => "identify_author_status($(this).value, #{form_object_id(f.object_name) });") %> <%= l(:identify_author_no) %> </label><br /> + </p> + </div> + + <div class='author_edit' id="<%= form_tag_id( f.object_name, :edit_author_info ) %>"> + <p> + <%= f.text_field :name_on_paper, {:class => ("readonly" unless params[:action] == "new") } %></p> + <p class='description' style=<%= "display:none;" unless params[:action] == "new" %>><%= h l("text_author_name_on_paper") %></p> + <p><%= f.text_field :institution, {:class => ("readonly" unless params[:action] == "new") } %></p> + <p class='description' style=<%= "display:none;" unless params[:action] == "new" %>><%= h l("text_author_institution") %></p> + <p><%= f.text_field :email, {:class => ("readonly" unless params[:action] == "new") } %></p> + <p class='description' style=<%= "display:none;" unless params[:action] == "new" %>><%= h l("text_author_email") %></p> + </p> + </div> + + + <div class="box" id="<%= form_tag_id( f.object_name, :show_author_info ) %>" style="display: none"> + + </div> + + <p> + + <% 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 %> </p> -</div> \ No newline at end of file +</div> +<br/>
--- 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 @@ -<div class="box"> +<p> + <label for="bibtex_entry_type"><%=l("field_entry_type")%> <span class="required">*</span></label> + <%= 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" ) + %> +</p> +<p> + <%= f.text_field :year, :size => 4, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :month, :size => 4, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :chapter, :size => 15, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :editor, :size => 33, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :booktitle, :size => 33, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :publisher,:size => 33, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :pages, :size => 12, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :address, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :annote, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :crossref, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :edition, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :eprint, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :howpublished, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :journal, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :key, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :note, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :number, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :organization, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :school, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :series, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :type, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :url, :class => 'bibtex' %> +</p> +<p> + <%= f.text_field :volume, :class => 'bibtex' %> +</p> - -<p><label for="bibtex_entry_type"><%=l("field_entry_type")%> <span class="required">*</span></label> - <%= f.collection_select(:entry_type, BibtexEntryType.find(:all), :id, :name, {:selected => @selected_bibtex_entry_type_id, :prompt => true}) %> - </p> - <p> - <%= f.text_field :year, :size => 60 %> - </p> - <p> - <%= f.text_field :chapter, :size => 60 %> - </p> - <p> - <%= f.text_field :editor, :size => 60 %> - </p> - <p> - <%= f.text_field :booktitle,:size => 60 %> - </p> - <p> - <%= f.text_field :publisher,:size => 60 %> - </p> - <p> - <%= f.text_field :pages, :size => 60 %> - </p> - -</div> \ No newline at end of file
--- 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 %> -<div class="splitcontentleft"> - <%= f.error_messages %> +<h3><%= f.text_field :title, :required => true, :size => 70 %></h3> + +<div class="splitcontentleft"> + <h3><%= l(:label_publication_other_details) %></h3> + <div class="box tabular"> + <% f.fields_for :bibtex_entry do |builder| -%> + <%= render :partial => 'bibtex_fields', :locals => { :f => builder} %> + <%- end -%> + <p> - <%= f.text_field :title, :required => true, :size => 60 %> + <%= f.text_field :external_url, :size => 70 %> + <br /> + <em><%= l(:text_external_url) %></em> </p> - <h3><%= l(:authors) %></h3> - <% f.fields_for :authorships do |builder| %> - <%= render "authorship_fields", :f => builder %> - <% end %> - - <p><%= link_to_add_fields l(:label_add_another_author), f, :authorships %></p> - + </div> </div> -<div class="splitcontentright"> - <h3>Other Details</h3> - <% f.fields_for :bibtex_entry do |builder| -%> - <%= render :partial => 'bibtex_fields', :locals => { :f => builder} %> - <%- end -%> +<div class="splitcontentright"> + <h3><%= l(:authors) %></h3> + <div class="box tabular"> + <% f.fields_for :authorships do |builder| -%> + <%= render "authorship_fields", :f => builder %> + <%- end -%> + <%= link_to_add_fields l(:label_add_an_author), f, :authorships %> + </div> </div> -<% content_for :sidebar do %> - placeholder - -<% end %> - -
--- 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) %>
--- 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 %> +
--- 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 %> <h2><%=l(:label_publication_show)%></h2> -<% 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 } %> - + + <div style="clear:both"></div> <%= f.submit %> <% end %> <p> - <%= 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 } %> </p>
--- 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 @@ -<div class="contextual"> - <%= link_to l(:label_publication_new), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %> +<div class="contextual"> + <% 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 %> </div> -<div class="splitcontentleft"> - <h3>Publications#index</h3> + <% if @project %> + <h3><%= l(:label_all_publications_for_project, :project => @project.name) %></h3> + <% else %> + <h3><%= l(:label_all_publications) %></h3> + <% end %> + <div class="autoscroll"> + <table class="list publications"> + <thead><tr> + <th><%= l(:title) %></th> + <th><%= l(:authors) %></th> + <th><%= l(:year) %></th> + <th><%= l(:associated_projects) %></th> + </tr></thead> - <table> - <tr> - <th>Number</th> - <th>Title</th> - </tr> - - <% @publications.each do |publication| %> - <tr> - <td><%= publication.id %></td> - <td><%= link_to publication.title, :controller => "publications", :action => "show", :id => publication, :project_id => @project %></td> - </tr> - <% end %> + <%- @publications.each do |publication| -%> + <%- if publication.projects.visible.length > 0 -%> + <tr class="<%= cycle('odd', 'even') %>"> + <td class="firstcol title" align="top"><%= link_to publication.title, :controller => "publications", :action => "show", :id => publication, :project_id => @project %></td> + <td class="authors" align="top"> + <%= render_authorships_list(publication) %> + <td class="year"><%= publication.bibtex_entry.year %></td> + <td class="projects"> + <%= render_projects_list(publication, false) %> + </td> + </tr> + <%- end -%> + <%- end -%> </table> - -</div> - -<div class="splitcontentright"> - placeholder div -</div> - + </div> <% content_for :sidebar do %> - Sidebar <% end %> - \ No newline at end of file +
--- 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 %> <h2><%=l(:label_publication_new)%></h2> -<% 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 } %> + <div style="clear:both"></div> <%= f.submit %> -<% end %> \ No newline at end of file +<% end %>
--- 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' %> + <h2><%=l(:label_publication_show)%></h2> -<div class="splitcontentleft"> -<h4>Title</h4> -<%= h @publication.title %> +<div class="box"> +<h3> + <%= h @publication.title %> +</h3> <h4><%= l(:authors) %></h4> <ul id="authorships"> - <% 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 %> <br /> - <%= h authorship.institution %> <br /> - <% end %> - <% end %> + <%- if User.current.allowed_to?(:edit_publication, @project) && @publication.authorships.length > 1 -%> + <span class="handle">[drag to reorder]</span> + <%- end -%> + <%= h authorship.name_on_paper %> <em><%= h authorship.institution %></em> <br /> + <%- end -%> + <%- end -%> </ul> -<%= sortable_element("authorships", :url => { :controller => :publications, :action => :sort_authors }) %> - -<br /> +<%- 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 -%> -<p> - <%= 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 %> -</p> + +<% unless @publication.external_url.blank? %> + <h4> + <%= l(:field_external_url) %> + </h4> + <p> + <%= link_to h(@publication.external_url), @publication.external_url, {:target => "_blank"} %> + </p> +<% end %> + +<br / > + <% 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 } %> </div> - <% projects = Project.active.find(:all, :limit => 100, :order => 'name ASC') - @publication.projects %> -<div class="splitcontentright"> - - <h4><%=l(:label_publication_project_index)%></h4> +<% content_for :sidebar do %> + <h3><%=l(:label_publication_project_index)%></h3> + <p id="list_projects"> <%= render :partial => 'list_projects' %> </p> + + <%- if User.current.allowed_to?(:edit_publication, @project) -%> <%= render :partial => 'add_project_form' %> -</div> \ No newline at end of file + <%- end -%> +<% end %>
--- /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' %> + +<div class="contextual"> +<%= link_to(l(:button_edit), edit_user_path(@user), :class => 'icon icon-edit') if User.current.admin? %> +</div> + +<h2><%= avatar @user, :size => "50" %> <%=h @user.name %></h2> + +<div class="splitcontentleft"> +<ul> + <% unless @user.pref.hide_mail %> + <li><%=l(:field_mail)%>: <%= mail_to(h(@user.mail), nil, :encode => 'javascript') %></li> + <% end %> + <% @user.visible_custom_field_values.each do |custom_value| %> + <% if !custom_value.value.blank? %> + <li><%=h custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li> + <% end %> + <% end %> + <li><%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %></li> + <% unless @user.last_login_on.nil? %> + <li><%=l(:field_last_login_on)%>: <%= format_date(@user.last_login_on) %></li> + <% end %> +</ul> + +<h3><%=l(:label_ssamr_description)%></h3> +<%= textilizable @description %> + +<h3><%=l(:label_ssamr_institution)%></h3> +<p><%= h @institution_name %></p> + + +<% unless @memberships.empty? %> +<h3><%=l(:label_project_plural)%></h3> +<ul> +<% for membership in @memberships %> + <li><%= link_to_project(membership.project) %> + (<%=h membership.roles.sort.collect(&:to_s).join(', ') %>, <%= format_date(membership.created_on) %>)</li> +<% end %> +</ul> +<% end %> +<%= call_hook :view_account_left_bottom, :user => @user %> +</div> + +<div class="splitcontentright"> + + <div id="bibliography"> + <% @publications = Publication.all(:include => :authors, :conditions => "authors.id = #{@user.author.id}") %> + + <h3><%=l(:publications) %> <%= "(" + @publications.count.to_s + ")" %> </h3> + + <% @publications.each do |publication|%> + <dt> + <%= link_to publication.title, :controller => 'publications', :action => 'show', :id => publication %> + </dt> + + <dd> + <span class="authors"> + <%= publication.authorships.map { |a| h a.name_on_paper }.join(', ') %> + </span> + <% if publication.bibtex_entry.year.to_s != "" %> + <span class="year"> + <%= publication.bibtex_entry.year %> + </span> + <% end %> + </dd> + <% end %> + </div> + + + +<% unless @events_by_day.empty? %> +<h3><%= link_to l(:label_activity), :controller => 'activities', :action => 'index', :id => nil, :user_id => @user, :from => @events_by_day.keys.first %></h3> + +<p> +<%=l(:label_reported_issues)%>: <%= Issue.count(:conditions => ["author_id=?", @user.id]) %> +</p> + +<div id="activity"> +<% @events_by_day.keys.sort.reverse.each do |day| %> +<h4><%= format_activity_day(day) %></h4> +<dl> +<% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%> + <dt class="<%= e.event_type %>"> + <span class="time"><%= format_time(e.event_datetime, false) %></span> + <%= content_tag('span', h(e.project), :class => 'project') %> + <%= link_to format_activity_title(e.event_title), e.event_url %></dt> + <dd><span class="description"><%= format_activity_description(e.event_description) %></span></dd> +<% end -%> +</dl> +<% end -%> +</div> + +<% 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 %> +</div> + +<% html_title @user.name %>
--- 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
--- /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; }
--- 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}.'" -
--- 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
--- 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
--- /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
--- 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
--- 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
--- /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
--- 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