changeset 473:ec7c78040115 cannam_integration

Merge from branch "feature_36" into a specially created integration branch
author Chris Cannam
date Mon, 27 Jun 2011 12:28:32 +0100
parents 350acce374a2 (current diff) 0ce4139187fa (diff)
children 9867ed78c4c1
files app/models/user.rb
diffstat 60 files changed, 1072 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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}"
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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 << "<label>#{ check_box_tag name, project.id, false } #{link_to_project project}</label>\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
--- /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
--- /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
--- /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
--- /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
--- /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 @@
+<h2>Authors#index</h2>
+
+<% @authors.each do |author| %>
+	<p><%= author.name %> - <%= author.publications.first.title%></p>
+<% end %>
\ No newline at end of file
--- /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 @@
+<h2>Authorships#update</h2>
--- /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? %>
+  <div class="bibliography box">
+	  <h3><%=l(:label_publications_plural)%></h3>	
+	  <p><% @project.publications.each do |publication| %>
+	    <%= link_to publication.title, :controller => 'publications', :action => 'show', :id => publication, :project_id => @project %><br />
+	  <% end %></p>
+  </div>
+<% end %>
--- /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 @@
+<div class="contextual">
+	<% 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 %>
+</div>
+
+<h2><%=l(:label_overview)%></h2> 
+	
+<div class="splitcontentleft">
+	<div class="wiki">
+		<%= textilizable @project.description %>
+	</div>	
+	<ul>
+	<% unless @project.homepage.blank? %><li><%=l(:field_homepage)%>: <%= auto_link(h(@project.homepage)) %></li><% end %>
+  <% if @subprojects.any? %>
+ 	<li><%=l(:label_subproject_plural)%>:
+	    <%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join(", ") %></li>
+  <% end %>
+	<% @project.visible_custom_field_values.each do |custom_value| %>
+	<% if !custom_value.value.blank? %>
+	   <li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
+	<% end %>
+	<% end %>
+	</ul>	
+
+  <% if User.current.allowed_to?(:view_issues, @project) %>
+  <div class="issues box">    
+    <h3><%=l(:label_issue_tracking)%></h3>
+    <ul>
+    <% for tracker in @trackers %>    
+      <li><%= 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) %>
+			</li>
+    <% end %>
+    </ul>
+    <p>
+    	<%= 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 %>
+		</p>
+  </div>
+  <% end %>
+  <%= call_hook(:view_projects_show_left, :project => @project) %>
+</div>
+
+<div class="splitcontentright">
+  
+  <%= render :partial => 'bibliography_box' %>
+  
+  <%= render :partial => 'members_box' %>
+    
+  <% if @news.any? && authorize_for('news', 'index') %>
+  <div class="news box">
+    <h3><%=l(:label_news_latest)%></h3>  
+    <%= render :partial => 'news/news', :collection => @news %>
+    <p><%= link_to l(:label_news_view_all), :controller => 'news', :action => 'index', :project_id => @project %></p>
+  </div>  
+  <% end %>
+  <%= call_hook(:view_projects_show_right, :project => @project) %>
+</div>
+
+<% content_for :sidebar do %>
+    <% if @total_hours && User.current.allowed_to?(:view_time_entries, @project) %>
+    <h3><%= l(:label_spent_time) %></h3>
+    <p><span class="icon icon-time"><%= l_hours(@total_hours) %></span></p>
+    <p><%= 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}) %></p>
+    <% 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)) -%>
--- /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| %>
+								<fieldset><legend><%=l(:label_add_project_to_publication)%></legend>
+	      <p>
+	        <%= label_tag "project_search", l(:label_project_search) %><%= text_field_tag 'project_search', nil %>
+	      </p>
+	     
+	      <%= observe_field(:project_search,
+               :frequency => 0.5,
+               :update => :projects,
+               :url => { :controller => 'publications', :action => 'autocomplete_for_project', :id => @publication },
+               :with => 'q')
+                %>
+
+					<div id="projects">
+					<% if params[:q] && params[:q].length > 1 %>
+			  		  <%= projects_check_box_tags 'project[project_ids][]', @projects %>
+					<% end %>
+					</div>
+
+        <p><%= submit_tag l(:button_add), :id => 'project-add-submit' %></p>
+    
+    
+      </fieldset>
+  <% end %>
--- /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 @@
+<div class="fields">
+  <p>
+    <%= f.label :name_on_paper, l("name") %>
+    <%= f.text_field :name_on_paper %><br />
+    <em><%= h l("text_name_on_paper") %></em><br />
+    <%= f.label :institution, l("institution") %>
+    <%= f.text_field :institution %><br />
+    <em><%= h l("text_institution") %></em><br />
+    <%= f.hidden_field :_destroy %>
+    <%= link_to_remove_fields l("remove_author"), f %>
+  </p>
+</div>
\ No newline at end of file
--- /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 @@
+    <p> 
+      <%= f.label :year, l(:year) %>  <%= f.text_field :year %>  
+    </p>  
+    <p>   
+      <%= f.label :chapter, l(:chapter) %>  <%= f.text_field :chapter %>  
+    </p>  
+    <p>   
+      <%= f.label :editor, l(:editor) %>  <%= f.text_field :editor %>  
+    </p>  
+    <p>   
+      <%= f.label :booktitle, l(:booktitle) %>  <%= f.text_field :booktitle %>  
+    </p>  
+    <p>   
+      <%= f.label :publisher, l(:publisher) %>  <%= f.text_field :publisher %>  
+    </p>  
+    <p>   
+      <%= f.label :pages, l(:pages) %>  <%= f.text_field :pages %>  
+    </p>
--- /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 %>  
+  <p>
+    <%= f.label :title, l(:title) %><br />
+    <%= f.text_field :title %>
+  </p>
+
+  <h3><%= l(:authors) %></h3>    
+  <% f.fields_for :authorships do |builder| %>
+    <%= render "authorship_fields", :f => builder %>
+  <% end %>
+  <p><%= link_to_add_fields l(:label_add_another_author), f, :authorships %></p>
+      
+  <%= 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" } %>
+
+  <div id="me"></div>
+    
+  <h3>Other Details</h3>
+  <% f.fields_for :bibtex_entry do |builder| -%>
+    <%= render :partial => 'bibtex_fields', :locals => { :f => builder}  %>
+  <%- end -%>
+
+
+  <%= f.submit %>
+
+<% end -%>
--- /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
--- /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 @@
+<h3>New Bibtex</h3>
+
+<h4>Paste your Bibtex entries here</h4>
+<p>
+  <%=label_tag :bibtex_entry %>
+  <%=text_area_tag :bibtex_entry%>  
+</p>
+
+
--- /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 @@
+<h2>Review new entries</h2>
+
--- /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
--- /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
+
--- /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 %>
--- /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 @@
+<h2>Publications#create</h2>
--- /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 @@
+<h2>Publications#edit</h2>
+
+<%= render :partial => 'edit' %>
+
+<p>
+  <%= link_to "Show", @publication %> |
+  <%= link_to "View All", publications_path %>
+</p>
--- /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 @@
+<h1>New Publication</h1>
+
+<% form_for @publication, :url => { :action => "create" } do |f| %>
+  <% f.error_messages %>
+
+  <%= render :partial  => "#{@publication.current_step}_bibtex_step", :locals => { :f => f }  %>
+
+  <p><%= f.submit "Submit" %></p>
+  <p><%= f.submit "Back", :name => "back_button" unless @publication.first_step? %></p>
+  
+<% end %>
+
--- /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 @@
+<div class="contextual">		
+		<%= link_to l(:label_publication_new), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %>
+</div>
+
+<div class="splitcontentleft">
+  <h3>Publications#index</h3>
+
+
+  <table>
+    <tr>
+      <th>Number</th>
+      <th>Title</th> 
+    </tr>
+
+    <% @publications.each do |publication| %>
+	    <tr>
+	      <td><%= publication.id %></td>
+	      <td><%= link_to publication.title, :controller => "publications", :action => "show", :id => publication, :project_id => @project %></td>
+	 	  </tr>
+    <% end %>    
+  </table>
+
+</div>
+
+<div class="splitcontentright">
+  placeholder div
+</div>
+
+
+<% content_for :sidebar do %>
+  Sidebar
+<% end %>
+  
\ No newline at end of file
--- /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 @@
+<h1>New Publication</h1>
+
+<div class="splitcontentleft">
+  <%= render :partial => 'edit' %>
+</div>
+
+<div class="splitcontentright">
+
+</div>
\ No newline at end of file
--- /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 @@
+<h2>Publication Details</h2>
+
+<div class="splitcontentleft">
+<h4>Title</h4>
+<%= h @publication.title %>
+
+<h4><%= l(:authors) %></h4>
+<ul id="authorships">
+  <% for authorship in @publication.authorships %>
+    <% content_tag_for :li, authorship do %>
+      <%= h authorship.name_on_paper %> <br />
+      <%= h authorship.institution %> <br />
+    <% end %>
+  <% end %>
+</ul>
+<%= sortable_element("authorships", :url => { :controller => :publications, :action => :sort_authors }) %>
+
+<br />
+
+<%- if @publication.bibtex_entry != nil -%>
+<% @publication.bibtex_entry.attributes.each do |field| %>
+  <% if field[1] != nil %>
+    <h4><%= field[0] %></h4>
+    <%= @publication.bibtex_entry.attributes[field[0]] unless field[1] == nil %>
+    <br />
+  <%- end -%>
+<%- end -%>
+<%- end -%>
+
+<p>
+  <%= link_to "Edit", edit_publication_path(@publication) %> |
+  <%= link_to "Destroy", @publication, :confirm => 'Are you sure?', :method => :delete %> |
+  <%= link_to "View All", publications_path %>
+</p>
+</div>
+
+
+<% projects = Project.active.find(:all, :limit => 100, :order => 'name ASC') - @publication.projects %>
+
+<div class="splitcontentright">
+
+
+  <h4>List of Projects</h4>
+  <p id="list_projects">
+    <%= render :partial => 'list_projects' %>
+  </p>
+
+  <%= render :partial => 'add_project_form' %>
+    
+</div>
\ No newline at end of file
--- /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 @@
+<h2>Publications#update</h2>
--- /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 @@
+<p><label>Menu caption</label>
+<%= text_field_tag 'settings[menu]', @settings['menu'], :size => 30 %>
+<br /><em>Clear this field if you don't want to add a tab to the project menu</em></p>
--- /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
--- /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"
+  
+  
+  
+  
+  
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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"
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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
--- /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