# HG changeset patch # User luisf # Date 1311964135 -3600 # Node ID 3954b253cdb3cecb34ca1aba4d33767703adc1f4 # Parent 8a26a0e291cff86560266c84ceab8d938474bba6# Parent 56ad0c490f5e65dc5514b53031d92531bff4daa0 Merge from branch "feature_36" diff -r 8a26a0e291cf -r 3954b253cdb3 app/models/user.rb --- a/app/models/user.rb Mon Jul 25 14:53:18 2011 +0100 +++ b/app/models/user.rb Fri Jul 29 19:28:55 2011 +0100 @@ -54,6 +54,8 @@ has_one :ssamr_user_detail, :dependent => :destroy, :class_name => 'SsamrUserDetail' accepts_nested_attributes_for :ssamr_user_detail + + has_one :author # Active non-anonymous users scope named_scope :active, :conditions => "#{User.table_name}.status = #{STATUS_ACTIVE}" diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/README.rdoc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/README.rdoc Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,3 @@ += bibliography + +Description goes here diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/controllers/authors_controller.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/controllers/authors_controller.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,7 @@ +class AuthorsController < ApplicationController + + def index + @authors = Author.find(:all) + end + +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/controllers/authorships_controller.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/controllers/authorships_controller.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,10 @@ +class AuthorshipsController < ApplicationController + + def index + + end + + + def update + end +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/controllers/bibtex_entries_controller.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/controllers/bibtex_entries_controller.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,3 @@ +class BibtexEntriesController < ApplicationController + +end \ No newline at end of file diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,242 @@ +# 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] + + def new + find_project_by_project_id + @publication = Publication.new + + # we'll always want a new publication to have its bibtex entry + @publication.build_bibtex_entry + + # and at least one author + # @publication.authorships.build.build_author + + @project_id = params[:project_id] + @current_user = User.current + end + + + def create + find_project_by_project_id + + @publication = Publication.new(params[:publication]) + + # @project = Project.find(params[:project_id]) + @publication.projects << @project + + if @publication.save + flash[:notice] = "Successfully created publication." + redirect_to :action => :show, :id => @publication, :project_id => @project.id + else + render :action => 'new' + end + end + + def index + if !params[:project_id].nil? + find_project_by_project_id + @project = Project.find(params[:project_id]) + @publications = Publication.find :all, :joins => :projects, :conditions => ["project_id = ?", @project.id] + else + @publications = Publication.find :all + end + end + + def new_from_bibfile + @publication.current_step = session[:publication_step] + + # contents of the paste text area + bibtex_entry = params[:bibtex_entry] + + # method for creating "pasted" bibtex entries + if bibtex_entry + parse_bibtex_list bibtex_entry + end + end + + def 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" } + end + end + + def edit + find_project_by_project_id unless params[:project_id].nil? + + @publication = Publication.find(params[:id]) + @selected_bibtex_entry_type_id = @publication.bibtex_entry.entry_type + end + + def update + @publication = Publication.find(params[:id]) + + logger.error { "INSIDE THE UPDATE ACTION IN THE PUBLICATION CONTROLLER" } + + if @publication.update_attributes(params[:publication]) + flash[:notice] = "Successfully updated Publication." + + if !params[:project_id].nil? + redirect_to :action => :show, :id => @publication, :project_id => params[:project_id] + else + redirect_to :action => :show, :id => @publication + end + else + render :action => 'edit' + end + end + + def show + find_project_by_project_id unless params[:project_id].nil? + + @publication = Publication.find(params[:id]) + + if @publication.nil? + @publications = Publication.all + render "index", :alert => 'The publication was not found!' + else + @authors = @publication.authors + @bibtext_entry = @publication.bibtex_entry + end + end + + # parse string with bibtex authors + def parse_authors(authors_entry) + # in bibtex the authors are always seperated by "and" + return authors_entry.split(" and ") + end + + # parses a list of bibtex + def parse_bibtex_list(bibtex_list) + bibliography = BibTeX.parse bibtex_list + + no_entries = bibliography.data.length + + # parses the bibtex entries + bibliography.data.map do |d| + + if d.class == BibTeX::Entry + create_bibtex_entry d + end + end + end + + def create_bibtex_entry(d) + @publication = Publication.new + @bentry = BibtexEntry.new + authors = [] + institution = "" + email = "" + + d.fields.keys.map do |field| + case field.to_s + when "author" + authors = parse_authors d[field] + when "title" + @publication.title = d[field] + when "institution" + institution = d[field] + when "email" + email = d[field] + else + @bentry[field] = d[field] + end + end + + @publication.bibtex_entry = @bentry + @publication.save + + # what is this for??? + # @created_publications << @publication.id + + # need to save all authors + # and establish the author-publication association + # via the authorships table + authors.each_with_index.map do |authorname, idx| + author = Author.new(:name => authorname) + if author.save! + puts "SAVED" + else + puts "NOT SAVED" + end + + author.authorships.create!( + :publication => @publication, + :institution => institution, + :email => email, + :order => idx) + end + end + + # parses the bibtex file + def parse_bibtex_file + + end + + def import + @publication = Publication.new + + + end + + def 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]) + + @projects = Project.active.like(params[:q]).find(:all, :limit => 100) - @publication.projects + logger.debug "Query for \"#{params[:q]}\" returned \"#{@projects.size}\" results" + render :layout => false + end + + def autocomplete_for_author + @results = [] + + authors_list = Author.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" + + # need to subtract both lists + # give priority to the users + users_list.each do |user| + @results << user + end + + authors_list.each do |author| + @results << author unless users_list.include?(author.user_id) + end + + render :layout => false + end + + def sort_authors + params[:authors].each_with_index do |id, index| + Author.update_all(['order=?', index+1], ['id=?', id]) + end + render :nothing => true + end + + def identify_author + + end + + private + +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/helpers/authors_helper.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/helpers/authors_helper.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,20 @@ +module AuthorsHelper + unloadable + + def render_author_publications(author) + s = "" + pubs = [] + + author.publications.each do |pub| + pubs << link_to(pub.title, pub) + end + + if pubs.size < 3 + s << '' << pubs.join(', ') << '' + else + s << pubs.join(', ') + end + s + end + +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/helpers/authorships_helper.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/helpers/authorships_helper.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,2 @@ +module AuthorshipsHelper +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/helpers/bibtex_entries_helper.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/helpers/bibtex_entries_helper.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,3 @@ +module BibtexEntriesHelper + +end \ No newline at end of file diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/helpers/my_helper.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/helpers/my_helper.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,45 @@ +module MyHelper + + def get_my_publications() + if not User.current.author.nil? + @my_publications = Publication.all(:include => :authors, :conditions => "authors.id = #{User.current.author.id}") + else + @my_publications = [] + end + end + + def render_publications_projects(publication) + s = "" + projs = [] + + publication.projects.each do |proj| + projs << link_to(proj.name, proj) + end + + if projs.size < 3 + s << '' << projs.join(', ') << '' + else + s << projs.join(', ') + end + + s + end + + def render_publications_authors(publication) + s = "" + auths = [] + + publication.authorships.each do |auth| + auths << h(auth.name_on_paper) + end + + if auths.size < 3 + s << '' << auths.join(', ') << '' + else + s << auths.join(', ') + end + s + end + + +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,98 @@ +require 'bibtex' + +module PublicationsHelper + def projects_check_box_tags(name, projects) + s = '' + projects.sort.each do |project| + s << "\n" + end + s + end + + def identify_author(author) + if author.class == User + author_info = { + :name_on_paper => author.name, + :user_id => author.id + } + + 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 + end + + def link_to_remove_fields(name, f) + f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)") + end + + def link_to_add_fields(name, f, association) + new_object = f.object.class.reflect_on_association(association).klass.new + fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| + render(association.to_s.singularize + "_fields", :f => builder) + end + link_to_function(name, h("add_fields(this, '#{association}', '#{escape_javascript(fields)}')"), { :class => 'icon icon-add', :id => "add_another_author" }) + end + + def sanitized_object_name(object_name) + object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/,"_").sub(/_$/,"") + end + + def sanitized_method_name(method_name) + method_name.sub(/\?$/, "") + end + + def form_tag_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 = [] + + publication.projects.each do |proj| + projs << link_to_project(proj) + end + + if projs.size < 3 + s << '' << projs.join(', ') << '' + else + s << projs.join(', ') + 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 + end + end + s + end +end + diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/models/author.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/models/author.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,18 @@ +class Author < ActiveRecord::Base + has_many :authorships, :dependent => :destroy + has_many :publications, :through => :authorships + + belongs_to :user + + def <=>(author) + name.downcase <=> author.name.downcase + end + + named_scope :like, lambda {|q| + s = "%#{q.to_s.strip.downcase}%" + {:conditions => ["LOWER(name) LIKE :s", {:s => s}], + :order => 'name' + } + } + +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/models/authorship.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/models/authorship.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,27 @@ +class Authorship < ActiveRecord::Base + belongs_to :author + belongs_to :publication + + accepts_nested_attributes_for :author + accepts_nested_attributes_for :publication + + + # setter and getter for virtual attribute :user_id + def user_id + 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 + end +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/models/bibtex_entry.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/models/bibtex_entry.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,14 @@ +class BibtexEntry < ActiveRecord::Base + unloadable + + belongs_to :publication + validates_presence_of :entry_type + + def entry_type_name + entry_type = self.entry_type + BibtexEntryType.find(entry_type).name + end + + + +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/models/bibtex_entry_type.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/models/bibtex_entry_type.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,2 @@ +class BibtexEntryType < ActiveRecord::Base +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/models/publication.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,19 @@ +# vendor/plugins/redmine_bibliography/app/models/publication.rb + +class Publication < ActiveRecord::Base + unloadable + + has_many :authorships, :dependent => :destroy + has_many :authors, :through => :authorships, :uniq => true + + has_one :bibtex_entry, :dependent => :destroy + + validates_presence_of :title + + accepts_nested_attributes_for :authorships + accepts_nested_attributes_for :authors, :allow_destroy => true + accepts_nested_attributes_for :bibtex_entry, :allow_destroy => true + + has_and_belongs_to_many :projects, :uniq => true + +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/authors/index.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/authors/index.html.erb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,26 @@ +

Authors#index

+ + + + + + + + + + <% @authors.each do |author|%> + + + + + + <% end %> + +
<%=l(:field_author_name)%><%=l(:field_author_username)%><%=l(:field_author_publications)%>
+ <%= h author.name %> + + <%= link_to author.user unless author.user.nil? %> + + <%= render_author_publications(author) %> +
+ diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/authorships/update.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/authorships/update.html.erb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,1 @@ +

Authorships#update

diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/my/blocks/_publications_box.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/my/blocks/_publications_box.html.erb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,30 @@ +<% get_my_publications %> + +

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

+ + + + + + + + + + <% @my_publications.each do |publication|%> + + + + + + <% end %> + +
<%=l(:field_publication_title)%><%=l(:field_publication_authors)%><%=l(:field_publication_projects)%>
+ <%= link_to publication.title, publication %> + + <%= render_publications_authors(publication) %> + + <%= render_publications_projects(publication) %> +
+ + + diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/projects/_bibliography_box.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/projects/_bibliography_box.html.erb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,8 @@ +<% 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 %>

+
+<% end %> diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/projects/show.rhtml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/projects/show.rhtml Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,86 @@ +
+ <% if User.current.allowed_to?(:add_subprojects, @project) %> + <%= link_to l(:label_subproject_new), {:controller => 'projects', :action => 'new', :parent_id => @project}, :class => 'icon icon-add' %> + <% end %> + + <%= link_to l(:label_add_publication_to_project), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %> + +
+ +

<%=l(:label_overview)%>

+ +
+
+ <%= textilizable @project.description %> +
+ + + <% if User.current.allowed_to?(:view_issues, @project) %> +
+

<%=l(:label_issue_tracking)%>

+
    + <% for tracker in @trackers %> +
  • <%= link_to tracker.name, :controller => 'issues', :action => 'index', :project_id => @project, + :set_filter => 1, + "tracker_id" => tracker.id %>: + <%= l(:label_x_open_issues_abbr_on_total, :count => @open_issues_by_tracker[tracker].to_i, + :total => @total_issues_by_tracker[tracker].to_i) %> +
  • + <% end %> +
+

+ <%= link_to l(:label_issue_view_all), :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1 %> + <% if User.current.allowed_to?(:view_calendar, @project, :global => true) %> + | <%= link_to(l(:label_calendar), :controller => 'calendars', :action => 'show', :project_id => @project) %> + <% end %> + <% if User.current.allowed_to?(:view_gantt, @project, :global => true) %> + | <%= link_to(l(:label_gantt), :controller => 'gantts', :action => 'show', :project_id => @project) %> + <% end %> +

+
+ <% end %> + <%= call_hook(:view_projects_show_left, :project => @project) %> +
+ +
+ + <%= render :partial => 'bibliography_box' %> + + <%= render :partial => 'members_box' %> + + <% if @news.any? && authorize_for('news', 'index') %> +
+

<%=l(:label_news_latest)%>

+ <%= render :partial => 'news/news', :collection => @news %> +

<%= link_to l(:label_news_view_all), :controller => 'news', :action => 'index', :project_id => @project %>

+
+ <% end %> + <%= call_hook(:view_projects_show_right, :project => @project) %> +
+ +<% content_for :sidebar do %> + <% if @total_hours && User.current.allowed_to?(:view_time_entries, @project) %> +

<%= l(:label_spent_time) %>

+

<%= l_hours(@total_hours) %>

+

<%= link_to(l(:label_details), {:controller => 'timelog', :action => 'index', :project_id => @project}) %> | + <%= link_to(l(:label_report), {:controller => 'time_entry_reports', :action => 'report', :project_id => @project}) %>

+ <% end %> + <%= call_hook(:view_projects_show_sidebar_bottom, :project => @project) %> +<% end %> + +<% content_for :header_tags do %> +<%= auto_discovery_link_tag(:atom, {:controller => 'activities', :action => 'index', :id => @project, :format => 'atom', :key => User.current.rss_key}) %> +<% end %> + +<% html_title(l(:label_overview)) -%> diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/publications/_add_project_form.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_add_project_form.html.erb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,29 @@ +<% form_remote_for(:publication, + :url => {:controller => 'publications', :action => 'add_project', :id => @publication, :project_id => @project}, + :method => :post, + :html => { :id => 'add_project_form' }, + :loading => "$('project-add-submit').disable()", + :complete => "$('project-add-submit').enable()") do |f| %> +
<%=l(:label_add_project_to_publication)%> +

+ <%= label_tag "project_search", l(:label_project_search) %><%= text_field_tag 'project_search', nil %> +

+ + <%= observe_field(:project_search, + :frequency => 0.5, + :update => :projects, + :url => { :controller => 'publications', :action => 'autocomplete_for_project', :id => @publication }, + :with => 'q') + %> + +
+ <% if params[:q] && params[:q].length > 1 %> + <%= projects_check_box_tags 'project[project_ids][]', @projects %> + <% end %> +
+ +

<%= submit_tag l(:button_add), :id => 'project-add-submit' %>

+ + +
+ <% end %> diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,28 @@ +
+

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

+
\ No newline at end of file diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,26 @@ +
+ + +

+ <%= 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 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,30 @@ + +
+ <%= f.error_messages %> +

+ <%= f.text_field :title, :required => true, :size => 60 %> +

+ +

<%= 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 -%> +
+ +<% content_for :sidebar do %> + + placeholder + +<% end %> + + diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/publications/_identify_author_form.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_identify_author_form.html.erb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,25 @@ +<%= "Identify Authors in the system…" %> + +<%= link_to_remote "It's me!", + { :url => { :controller => 'publications', + :action => 'add_me_as_author', + :project_id => @project }, :method => 'post'}, + { :class => 'icon icon-add', :id => "add_me_as_author" } %> + +

+ <%= label_tag "author_search", l(:label_project_search) %><%= text_field_tag 'author_search', nil %> +

+ +<%= observe_field( form_tag_id(f.object_name, :name), + :frequency => 0.5, + :update => :identify_author, + :url => { :controller => 'publications', :action => 'autocomplete_for_author' }, + :with => 'q') +%> + +
+ <% if params[:q] && params[:q].length > 1 %> + <%= select_author_links 'author[author_ids][]', @authors %> + <% end %> +
+ diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,1 @@ +<%= render_projects_list(@publication) %> \ No newline at end of file diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/publications/_new_bibtex_step.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_new_bibtex_step.html.erb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,9 @@ +

New Bibtex

+ +

Paste your Bibtex entries here

+

+ <%=label_tag :bibtex_entry %> + <%=text_area_tag :bibtex_entry%> +

+ + diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/publications/_review_bibtex_step.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_review_bibtex_step.html.erb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,2 @@ +

Review new entries

+ diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/publications/add_project.rjs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/add_project.rjs Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,3 @@ +page.replace_html :list_projects, :partial => 'list_projects' +page[:add_project_form].reset + diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.rhtml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.rhtml Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,3 @@ +<% if params[:q] && params[:q].length > 1 %> + <%= choose_author_link 'publication[author_ids][]', @results %> +<% end %> diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/publications/autocomplete_for_project.rhtml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/autocomplete_for_project.rhtml Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,3 @@ +<% if params[:q] && params[:q].length > 1 %> + <%= projects_check_box_tags 'publication[project_ids][]', @projects %> +<% end %> diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/publications/create.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/create.html.erb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,1 @@ +

Publications#create

diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,15 @@ +<% content_for :header_tags do %> + <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %> +<% end %> + +

<%=l(:label_publication_show)%>

+ +<% form_for @publication, :url => { :project_id => @project_id, :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_index), { :controller => "publications", :action => "index", :project_id => @project } %> +

diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/publications/import.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/import.html.erb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,12 @@ +

New Publication

+ +<% form_for @publication, :url => { :action => "create" } do |f| %> + <% f.error_messages %> + + <%= render :partial => "#{@publication.current_step}_bibtex_step", :locals => { :f => f } %> + +

<%= f.submit "Submit" %>

+

<%= f.submit "Back", :name => "back_button" unless @publication.first_step? %>

+ +<% end %> + diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,33 @@ +
+ <%= link_to l(:label_publication_new), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %> +
+ +
+

Publications#index

+ + + + + + + + + <% @publications.each do |publication| %> + + + + + <% end %> +
NumberTitle
<%= publication.id %><%= link_to publication.title, :controller => "publications", :action => "show", :id => publication, :project_id => @project %>
+ +
+ +
+ placeholder div +
+ + +<% content_for :sidebar do %> + Sidebar +<% end %> + \ No newline at end of file diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,10 @@ +<% content_for :header_tags do %> + <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %> +<% end %> + +

<%=l(:label_publication_new)%>

+ +<% form_for @publication, :url => { :project_id => @project_id, :action => :create }, :builder => TabularFormBuilder do |f| -%> + <%= render :partial => 'form', :locals => { :f => f } %> + <%= f.submit %> +<% end %> \ No newline at end of file diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,41 @@ +

<%=l(:label_publication_show)%>

+ +
+

Title

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

<%= l(:authors) %>

+ +<%= sortable_element("authorships", :url => { :controller => :publications, :action => :sort_authors }) %> + +
+ +<%- 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 %> +

+
+ + +<% projects = Project.active.find(:all, :limit => 100, :order => 'name ASC') - @publication.projects %> + +
+ +

<%=l(:label_publication_project_index)%>

+

+ <%= render :partial => 'list_projects' %> +

+ <%= render :partial => 'add_project_form' %> +
\ No newline at end of file diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/publications/update.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/update.html.erb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,1 @@ +

Publications#update

diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/app/views/settings/_bibliography.rhtml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/settings/_bibliography.rhtml Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,3 @@ +

+<%= text_field_tag 'settings[menu]', @settings['menu'], :size => 30 %> +
Clear this field if you don't want to add a tab to the project menu

diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/assets/javascripts/authors.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,24 @@ +function remove_fields(link) { + $(link).previous("input[type=hidden]").value = "1"; + $(link).up(".fields").hide(); +} + +function add_fields(link, association, content) { + var new_id = new Date().getTime(); + var regexp = new RegExp("new_" + association, "g") + $(link).up().insert({ + before: content.replace(regexp, new_id) + }); +} + +function update_author_info(link, author_info){ + + $(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 diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/config/locales/en.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/config/locales/en.yml Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,76 @@ +# English strings go here for Rails i18n +en: + title: "Title" + authors: "Authors" + author: "Author" + name: "Name" + publications_box: "My Publications" + label_my_publications_box: "My Publications" + + field_publication_title: Title + field_publication_authors: Authors + field_publication_projects: "Associated Projects" + field_author_name: Author + field_author_username: "Associated User" + field_author_publications: "Publications by this Author" + + bibtex_entry: + entry_type: "Bibtex Entry Type" + + label_add_me_as_author: "Add me as an author" + label_add_another_author: "Add another author" + + remove_author: "Remove this author" + + label_publications_plural: "Publications" + label_publication_new: "Create New 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_publication_project_index: "Projects associated with this publication" + label_publication_index: "View all publications" + + 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.)" + + # authorships model + field_institution: "Institution" + field_name_on_paper: "Name" + field_email: "Email Address" + + # bibtex_entries model + field_entry_type: "Entry Type" + field_id: "id" + field_publication_id: "Publication_id" + field_entry_type: "Entry Type" + field_address: "Address" + field_annote: "Annote" + field_booktitle: "Book Title" + field_chapter: "Chapter" + field_crossref: "Cross Reference" + field_edition: "Edition" + field_editor: "Editor" + field_eprint: "eprint" + field_howpublished: "How was it Published" + field_journal: "Journal" + field_key: "Key" + field_month: "Month" + field_note: "Note" + field_number: "Number" + field_organization: "Organization" + field_pages: "Pages" + field_publisher: "Publisher" + field_school: "School" + field_series: "Series" + field_type: "Type" + field_url: "URL" + field_volume: "Volume" + field_year: "Year" + + + + + diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/config/routes.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/config/routes.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,3 @@ +ActionController::Routing::Routes.draw do |map| + map.resources :publications, :collection => { :sort_authors => :post } +end \ No newline at end of file diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/db/migrate/001_create_authors.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/db/migrate/001_create_authors.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,12 @@ +class CreateAuthors < ActiveRecord::Migration + def self.up + create_table :authors do |t| + t.column :user_id, :integer + t.column :name, :string + end + end + + def self.down + drop_table :authors + end +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/db/migrate/002_create_publications.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/db/migrate/002_create_publications.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,12 @@ +class CreatePublications < ActiveRecord::Migration + def self.up + create_table :publications do |t| + t.column :title, :string + t.column :reviewed, :boolean, :default => false + end + end + + def self.down + drop_table :publications + end +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/db/migrate/003_create_authorships.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/db/migrate/003_create_authorships.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,16 @@ +class CreateAuthorships < ActiveRecord::Migration + def self.up + create_table :authorships do |t| + t.column :author_id, :integer + t.column :publication_id, :integer + t.column :name_on_paper, :string + t.column :order, :integer + t.column :institution, :string + t.column :email, :string + end + end + + def self.down + drop_table :authorships + end +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/db/migrate/004_create_bibtex_entries.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/db/migrate/004_create_bibtex_entries.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,35 @@ +class CreateBibtexEntries < ActiveRecord::Migration + def self.up + create_table :bibtex_entries do |t| + t.column :publication_id, :integer + t.column :entry_type, :integer + t.column :address, :string + t.column :annote, :string + t.column :booktitle, :string + t.column :chapter, :string + t.column :crossref, :string + t.column :edition, :string + t.column :editor, :string + t.column :eprint, :string + t.column :howpublished, :string + t.column :journal, :string + t.column :key, :string + t.column :month, :string + t.column :note, :text + t.column :number, :string + t.column :organization, :string + t.column :pages, :string + t.column :publisher, :string + t.column :school, :string + t.column :series, :string + t.column :type, :string + t.column :url, :string + t.column :volume, :integer + t.column :year, :integer + end + end + + def self.down + drop_table :bibtex_entries + end +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/db/migrate/005_create_projects_publications_join_table.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/db/migrate/005_create_projects_publications_join_table.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,12 @@ +class CreateProjectsPublicationsJoinTable < ActiveRecord::Migration + def self.up + create_table :projects_publications, :id => false do |t| + t.integer :project_id + t.integer :publication_id + end + end + + def self.down + drop_table :projects_publications + end +end \ No newline at end of file diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/db/migrate/006_create_bibtex_entry_types.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/db/migrate/006_create_bibtex_entry_types.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,13 @@ +class CreateBibtexEntryTypes < ActiveRecord::Migration + def self.up + create_table :bibtex_entry_types do |t| + t.string :name + + t.timestamps + end + end + + def self.down + drop_table :bibtex_entry_types + end +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/db/seed_data/bibtex_entry_types_list.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/db/seed_data/bibtex_entry_types_list.txt Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,14 @@ +article +book +booklet +conference +inbook +incollection +inproceedings +manual +masterthesis +misc +phdthesis +proceedings +techreport +unpublished diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/init.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/init.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,43 @@ +require 'redmine' +require 'dispatcher' + +RAILS_DEFAULT_LOGGER.info 'Starting Bibliography Plugin for RedMine' + +# Patches to the Redmine core. +Dispatcher.to_prepare :redmine_model_dependencies do + require_dependency 'project' + require_dependency 'user' + + unless Project.included_modules.include? Bibliography::ProjectPublicationsPatch + Project.send(:include, Bibliography::ProjectPublicationsPatch) + end + + unless User.included_modules.include? Bibliography::UserAuthorPatch + User.send(:include, Bibliography::UserAuthorPatch) + end + +end + + +# Plugin Info +Redmine::Plugin.register :redmine_bibliography do + name 'Redmine Bibliography plugin' + author 'Chris Cannam, Luis Figueira' + description 'This is a bibliography management plugin for Redmine' + version '0.0.1' + url 'http://example.com/path/to/plugin' + author_url 'http://example.com/about' + + settings :default => { 'menu' => 'Bibliography' }, :partial => 'settings/bibliography' + + project_module :redmine_bibliography do + permission :publications, { :publications => :index }, :public => true + permission :edit_redmine_bibliography, {:redmine_bibliography => [:edit, :update]}, :public => true + permission :add_publication, {:redmine_bibliography => [:new, :create]}, :public => true + 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 diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/lang/en.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/lang/en.yml Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,2 @@ +# English strings go here +my_label: "My label" diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/lib/bibliography/project_publications_patch.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/lib/bibliography/project_publications_patch.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,25 @@ +require_dependency 'project' + +module Bibliography + module ProjectPublicationsPatch + def self.included(base) + base.class_eval do + has_and_belongs_to_many :publications, :uniq => true + + named_scope :like, lambda {|q| + s = "%#{q.to_s.strip.downcase}%" + {:conditions => ["LOWER(name) LIKE :s OR LOWER(homepage) LIKE :s", {:s => s}], + :order => 'name' + } + } + end + end #self.included + + module ProjectMethods + + + + + end #ProjectMethods + end #ProjectPublicationsPatch +end #RedmineBibliography \ No newline at end of file diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,53 @@ +require_dependency 'user' + +module Bibliography + module UserAuthorPatch + def self.included(base) + base.send(:include, InstanceMethods) + extend ClassMethods + + base.class_eval do + has_one :publication + + end + end #self.included + + module ClassMethods + end + + module InstanceMethods + + def get_author_info + info = { + :name_on_paper => "", + :email => "", + :institution => "", + :user_id => self.id + } + + 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 + + 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 + end #InstanceMethods + + end #UserPublicationsPatch +end #RedmineBibliography \ No newline at end of file diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/lib/tasks/seed_bibtex_entry_types.rake --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/lib/tasks/seed_bibtex_entry_types.rake Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,20 @@ +namespace :redmine do + namespace :plugins do + namespace :redmine_bibliography do + + task :seed_bibtex_entry_types => :environment do + desc "Seeds the Bibtex Entry Types Table" + + quoted = ActiveRecord::Base.connection.quote_table_name('bibtex_entry_types') + ActiveRecord::Base.connection.execute("TRUNCATE #{quoted}") + + open(File.dirname(__FILE__) + "/../../db/seed_data/bibtex_entry_types_list.txt") do |bibtex_entry_types| + bibtex_entry_types.read.each_line do |bibtex_entry_type| + BibtexEntryType.create(:name => bibtex_entry_type.chomp) + end + end + end + + end + end +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/test/fixtures/authors.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/test/fixtures/authors.yml Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,17 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +one: + id: 1 + user_id: + name: MyString +two: + id: 2 + user_id: + name: MyString +one: + id: 3 + user_id: + name: MyString +two: + id: 4 + user_id: + name: MyString diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/test/fixtures/authorships.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/test/fixtures/authorships.yml Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,33 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +one: + id: 1 + author_id: 1 + publication_id: 1 + name_on_paper: Yih-Farn R. Chen + order: 1 + institution: + email: MyString +two: + id: 2 + author_id: 2 + publication_id: 1 + name_on_paper: Glenn S. Fowler + order: 2 + institution: + email: MyString +three: + id: 3 + author_id: 1 + publication_id: 1 + name_on_paper: Yih-Farn R. Chen + order: 1 + institution: + email: MyString +four: + id: 4 + author_id: 2 + publication_id: 1 + name_on_paper: Glenn S. Fowler + order: 2 + institution: + email: MyString diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/test/fixtures/bibtex_entries.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/test/fixtures/bibtex_entries.yml Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,6 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +one: + id: 1 + entry_type: InProceedings + booktitle: International Conference on Software Maintenance + year: 1995 diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/test/fixtures/publications.yml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/test/fixtures/publications.yml Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,9 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +one: + id: 1 + title: Test Fixture Title No1 + bibtex_entry_id: 1 +two: + id: 2 + title: MyString + bibtex_entry_id: MyString diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/test/functional/authors_controller_test.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/test/functional/authors_controller_test.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,8 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class AuthorsControllerTest < ActionController::TestCase + # Replace this with your real tests. + def test_truth + assert true + end +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/test/functional/authorships_controller_test.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/test/functional/authorships_controller_test.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,8 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class AuthorshipsControllerTest < ActionController::TestCase + # Replace this with your real tests. + def test_truth + assert true + end +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/test/functional/publications_controller_test.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/test/functional/publications_controller_test.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,8 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class PublicationsControllerTest < ActionController::TestCase + # Replace this with your real tests. + def test_truth + assert true + end +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/test/test_helper.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/test/test_helper.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,24 @@ +# Load the normal Rails helper +require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper') +require 'publications_controller' + +# Ensure that we are using the temporary fixture path +Engines::Testing.set_fixture_path + +class BibliographyControllerTest < ActionController::TestCase + fixtures :all + + def setup + end + + def test_publication + + end + + + def test_routing + assert_routing( + {:method => :get, :path => '/requirements'}, + :controller => 'requirements', :action => 'index' + ) + end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/test/unit/author_test.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/test/unit/author_test.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class AuthorTest < ActiveSupport::TestCase + fixtures :authors + + # Replace this with your real tests. + def test_truth + assert true + end +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/test/unit/authorship_test.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/test/unit/authorship_test.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class AuthorshipTest < ActiveSupport::TestCase + fixtures :authorships + + # Replace this with your real tests. + def test_truth + assert true + end +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/test/unit/bibtex_entry_test.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/test/unit/bibtex_entry_test.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class BibtexEntryTest < ActiveSupport::TestCase + fixtures :bibtex_entries + + # Replace this with your real tests. + def test_truth + assert true + end +end diff -r 8a26a0e291cf -r 3954b253cdb3 vendor/plugins/redmine_bibliography/test/unit/publication_test.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/test/unit/publication_test.rb Fri Jul 29 19:28:55 2011 +0100 @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class PublicationTest < ActiveSupport::TestCase + fixtures :publications + + # Replace this with your real tests. + def test_truth + assert true + end +end