# HG changeset patch # User Chris Cannam # Date 1309174112 -3600 # Node ID ec7c78040115659c0fc40ee1664eb54e0c476ea7 # Parent 350acce374a205d36064457c25ff617f89406bd3# Parent 0ce4139187faea18b181332e87e43e1ea1878838 Merge from branch "feature_36" into a specially created integration branch diff -r 350acce374a2 -r ec7c78040115 app/models/user.rb --- a/app/models/user.rb Mon Jun 06 14:55:38 2011 +0100 +++ b/app/models/user.rb Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 vendor/plugins/redmine_bibliography/README.rdoc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/README.rdoc Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,3 @@ += bibliography + +Description goes here diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,7 @@ +class AuthorsController < ApplicationController + + def index + @authors = Author.find(:all) + end + +end diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,10 @@ +class AuthorshipsController < ApplicationController + + def index + + end + + + def update + end +end diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,3 @@ +class BibtexEntriesController < ApplicationController + +end \ No newline at end of file diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,237 @@ +# vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb + +class PublicationsController < ApplicationController + unloadable + + before_filter :find_project_by_project_id, :except => [:autocomplete_for_project, :add_author, :sort_authors] + + + def new + @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 + @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 + @project = Project.find(params[:project_id]) + @publications = Publication.find :all, :joins => :projects, :conditions => ["project_id = ?", @project.id] + 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 add_me_as_author + if (request.xhr?) + if User.current.author.nil? + logger.error { "current user has an author" } + @author = Author.new(:user_id => User.current) + else + logger.error { "current user does not have an author" } + @author = User.current.author + end + @authorship = Authorship.create(:author => @author, :publication => @publication) + else + # No? Then render an action. + #render :action => 'view_attribute', :attr => @name + logger.error { "ERROR ADD ME AS AUTHOR" } + end + end + + + def edit + @publication = Publication.find(params[:id]) + end + + def update + @publication = Publication.find(params[:id]) + if @publication.update_attributes(params[:publication]) + flash[:notice] = "Successfully updated Publication." + redirect_to @publication + else + render :action => 'edit' + end + end + + def show + logger.error "-------> No Show" + + @publication = Publication.find(params[:id]) + + if @publication.nil? + @publications = Publication.all + render "index", :alert => 'Your Publications was not found!' + else + @authors = @publication.authors + @bibtext_entry = @publication.bibtex_entry + + respond_to do |format| + format.html + format.xml {render :xml => @publication} + end + 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]) + + logger.error "aaaaaaaa" + logger.error { @publication.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 sort_authors + params[:authors].each_with_index do |id, index| + Author.update_all(['order=?', index+1], ['id=?', id]) + end + render :nothing => true + end + + + private + + # TODO: luisf. - only here for debugging purposes + # Find project of id params[:project_id] + def find_project_by_project_id + + logger.error { "FIND PROJECT BY PROJECT ID" } + + @project = Project.find(params[:project_id]) + rescue ActiveRecord::RecordNotFound + render_404 + end +end diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,2 @@ +module AuthorsHelper +end diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,2 @@ +module AuthorshipsHelper +end diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,3 @@ +module BibtexEntriesHelper + +end \ No newline at end of file diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,23 @@ +require 'bibtex' + +module PublicationsHelper + def projects_check_box_tags(name, projects) + s = '' + projects.sort.each do |project| + s << "\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 +end diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,7 @@ +class Author < ActiveRecord::Base + has_many :authorships, :dependent => :destroy + has_many :publications, :through => :authorships + + belongs_to :user + +end diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,5 @@ +class Authorship < ActiveRecord::Base + belongs_to :author + belongs_to :publication + +end diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,4 @@ +class BibtexEntry < ActiveRecord::Base + belongs_to :publication + +end diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,41 @@ +# 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 + + attr_writer :current_step + + def current_step + @current_step || steps.first + end + + def steps + %w[new review] + end + + def next_step + self.current_step = steps[steps.index(current_step)+1] + end + + def previous_step + self.current_step = steps[steps.index(current_step)-1] + end + + def first_step? + current_step == steps.first + end + +end diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,5 @@ +

Authors#index

+ +<% @authors.each do |author| %> +

<%= author.name %> - <%= author.publications.first.title%>

+<% end %> \ No newline at end of file diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,1 @@ +

Authorships#update

diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,83 @@ +
+ <% 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 %> +
+ +

<%=l(:label_overview)%>

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

<%=l(:label_issue_tracking)%>

+ +

+ <%= 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,12 @@ +
+

+ <%= f.label :name_on_paper, l("name") %> + <%= f.text_field :name_on_paper %>
+ <%= h l("text_name_on_paper") %>
+ <%= f.label :institution, l("institution") %> + <%= f.text_field :institution %>
+ <%= h l("text_institution") %>
+ <%= f.hidden_field :_destroy %> + <%= link_to_remove_fields l("remove_author"), f %> +

+
\ No newline at end of file diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,18 @@ +

+ <%= f.label :year, l(:year) %> <%= f.text_field :year %> +

+

+ <%= f.label :chapter, l(:chapter) %> <%= f.text_field :chapter %> +

+

+ <%= f.label :editor, l(:editor) %> <%= f.text_field :editor %> +

+

+ <%= f.label :booktitle, l(:booktitle) %> <%= f.text_field :booktitle %> +

+

+ <%= f.label :publisher, l(:publisher) %> <%= f.text_field :publisher %> +

+

+ <%= f.label :pages, l(:pages) %> <%= f.text_field :pages %> +

diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,36 @@ +<% content_for :header_tags do %> + <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %> +<% end %> + + +<% form_for @publication, :url => { :project_id => @project_id, :action => :create } do |f| -%> + <%= f.error_messages %> +

+ <%= f.label :title, l(:title) %>
+ <%= f.text_field :title %> +

+ +

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

+ + <%= link_to_remote l(:label_add_me_as_author), + { :url => { :controller => 'publications', :action => 'add_me_as_author', :project_id => @project }, + :method => 'post', + :update => 'me', + :complete => "" + }, { :class => 'icon icon-add', :id => "add_me_as_author" } %> + +
+ +

Other Details

+ <% f.fields_for :bibtex_entry do |builder| -%> + <%= render :partial => 'bibtex_fields', :locals => { :f => builder} %> + <%- end -%> + + + <%= f.submit %> + +<% end -%> diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,3 @@ +<% @publication.projects.each do |proj| %> + <%= link_to_project proj %> +<% end %> \ No newline at end of file diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,9 @@ +

New Bibtex

+ +

Paste your Bibtex entries here

+

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

+ + diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,2 @@ +

Review new entries

+ diff -r 350acce374a2 -r ec7c78040115 vendor/plugins/redmine_bibliography/app/views/publications/add_me_as_author.rjs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/add_me_as_author.rjs Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,1 @@ +page.insert_html :bottom, :authors, :partial => 'authorships_fields', :locals => { :authorships => @authorship } \ No newline at end of file diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,3 @@ +page.replace_html :list_projects, :partial => 'list_projects' +page[:add_project_form].reset + diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,3 @@ +<% if params[:q] && params[:q].length > 1 %> + <%= projects_check_box_tags 'publication[project_ids][]', @projects %> +<% end %> diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,1 @@ +

Publications#create

diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,8 @@ +

Publications#edit

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

+ <%= link_to "Show", @publication %> | + <%= link_to "View All", publications_path %> +

diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,9 @@ +

New Publication

+ +
+ <%= render :partial => 'edit' %> +
+ +
+ +
\ No newline at end of file diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,50 @@ +

Publication Details

+ +
+

Title

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

<%= l(:authors) %>

+ +<%= sortable_element("authorships", :url => { :controller => :publications, :action => :sort_authors }) %> + +
+ +<%- if @publication.bibtex_entry != nil -%> +<% @publication.bibtex_entry.attributes.each do |field| %> + <% if field[1] != nil %> +

<%= field[0] %>

+ <%= @publication.bibtex_entry.attributes[field[0]] unless field[1] == nil %> +
+ <%- end -%> +<%- end -%> +<%- end -%> + +

+ <%= link_to "Edit", edit_publication_path(@publication) %> | + <%= 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 %> + +
+ + +

List of Projects

+

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

+ + <%= render :partial => 'add_project_form' %> + +
\ No newline at end of file diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,1 @@ +

Publications#update

diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,12 @@ +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) + }); +} \ No newline at end of file diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,57 @@ +# English strings go here for Rails i18n +en: + title: "Title" + authors: "Authors" + author: "Author" + name: "Name" + + 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: "Add Publication" + label_add_project_to_publication: "Add Project to Publication" + label_project_search: "Search by name: " + + text_institution: "Please insert the institution as it appears on the paper." + text_name_on_paper: "Please insert the name of the author as it appears on the paper." + + # authorships model + institution: "Institution" + naem_on_paper: "Name" + + + # bibtex_entries model + id: "id" + publication_id: "Publication_id" + entry_type: "Entry Type" + address: "Address" + annote: "Annote" + booktitle: "Book Title" + chapter: "Chapter" + crossref: "Cross Reference" + edition: "Edition" + editor: "Editor" + eprint: "eprint" + howpublished: "How was it Published" + journal: "Journal" + key: "Key" + month: "Month" + note: "Note" + number: "Number" + organization: "Organization" + pages: "Pages" + publisher: "Publisher" + school: "School" + series: "Series" + type: "Type" + url: "URL" + volume: "Volume" + year: "Year" + + + + + diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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, :string + 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 vendor/plugins/redmine_bibliography/init.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/init.rb Mon Jun 27 12:28:32 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 Project.included_modules.include? Bibliography::UserAuthorPatch + Project.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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,2 @@ +# English strings go here +my_label: "My label" diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 2011 +0100 @@ -0,0 +1,11 @@ +require_dependency 'user' + +module Bibliography + module UserAuthorPatch + def self.included(base) + base.class_eval do + has_one :publication + end + end #self.included + end #UserPublicationsPatch +end #RedmineBibliography \ No newline at end of file diff -r 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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 350acce374a2 -r ec7c78040115 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 Mon Jun 27 12:28:32 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