# HG changeset patch # User luisf # Date 1354726363 0 # Node ID 468967d012aae8f9f8d0e9e47a7e764bbc90a82d # Parent c018d0c89c945e2f7fcab4aa6b58d2aaa7d958d6 Dev commit - fails when saving the temporary publication (no authors). diff -r c018d0c89c94 -r 468967d012aa vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Dec 04 18:15:17 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Wed Dec 05 16:52:43 2012 +0000 @@ -19,13 +19,34 @@ # and at least one author # @publication.authorships.build.build_author + # todo - do we still need this? --lf.20121205 @author_options = [["#{User.current.name} (@#{User.current.mail.partition('@')[2]})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]] end + # the argument is a ruby-bibtex parsed entry + def create_bibtex_entry(bibtex) + + bibtex.fields.keys.map do |field| + case field.to_s + when "title" + @publication.title = bibtex[field] + when "author" + bibtex.authors.each do |auth| + logger.error { "AUTHOR #{auth}" } + end + else + @publication.bibtex_entry[field] = bibtex[field] + end + end + end + def parse_bibtex find_project_by_project_id @bibtex_parse_success = true + @publication = Publication.new + @publication.build_bibtex_entry + begin bibtex_paste = params[:bibtex_paste] bib = BibTeX.parse(bibtex_paste) @@ -42,24 +63,32 @@ @suggested_authors = {} respond_to do |format| - # todo: response for HTML - format.html{} - if @bibtex_parse_success # todo: should this code be here? + + # creates the entry + create_bibtex_entry(bib[0]) + logger.error { "Bibtex Entry #{@bibtex_entry}" } + + @ieee_prev = CiteProc.process bib.to_citeproc, :style => :ieee, :format => :html bibtex_parsed_authors = bib[0].authors - # todo: need to create a bibtex object - ## and add it to the session hash - - # creates stucture with author suggestions bibtex_parsed_authors.each do |auth| @suggested_authors[auth] = suggest_authors(auth.last) + + @publication.authorships.new :name_on_paper => auth + logger.error { "Added Authorship: #{auth}" } end + + # can temporarily save + # note that the publication still needs reviewing + @publication.save! end + + # todo: response for HTML format.js end end @@ -71,7 +100,6 @@ end - def create @project = Project.find(params[:project_id]) @@ -163,7 +191,6 @@ end end - def show find_project_by_project_id unless params[:project_id].nil? @@ -176,24 +203,6 @@ end end - # the argument is a ruby-bibtex parsed entry - def create_bibtex_entry(bibtex) - @bibtex_entry = BibtexEntry.new - - bibtex.fields.keys.map do |field| - case field.to_s - when "title" - @publication.title = d[field] - when "author" - authors.each do |auth| - logger.warning { "AUTHOR #{author}" } - end - else - @bibtex_entry[field] = d[field] - end - end - end - def autocomplete_for_project @publication = Publication.find(params[:id]) diff -r c018d0c89c94 -r 468967d012aa vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb Tue Dec 04 18:15:17 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb Wed Dec 05 16:52:43 2012 +0000 @@ -1,8 +1,8 @@

- <%= f.collection_select :entry_type, - BibtexEntryType.find(:all).reject { |x| x.redundant? }, - :id, + <%= f.collection_select :entry_type, + BibtexEntryType.find(:all).reject { |x| x.redundant? }, + :id, :label, { :prompt => true } %> @@ -14,72 +14,72 @@ :with => 'q' %> -

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

+ <%= f.text_field :year, :size => 4 %>

-

- <%= f.text_field :month, :size => 4%> +

+ <%= f.text_field :month, :size => 4%>

-

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

-

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

-

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

-

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

-

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

+ <%= f.text_field :chapter, :size => 15%>

-

+

+ <%= f.text_field :editor, :size => 33 %> +

+

+ <%= f.text_field :booktitle, :size => 33 %> +

+

+ <%= f.text_field :publisher,:size => 33 %> +

+

+ <%= f.text_field :pages, :size => 12 %> +

+

<%= f.text_field :address %>

-

+

<%= f.text_field :annote %>

-

+

<%= f.text_field :crossref %>

-

+

<%= f.text_field :edition %>

-

+

<%= f.text_field :eprint %>

-

+

<%= f.text_field :howpublished %>

-

+

<%= f.text_field :journal %>

-

+

<%= f.text_field :key %>

-

+

<%= f.text_field :note %>

-

+

<%= f.text_field :number %>

-

+

<%= f.text_field :organization %>

-

+

<%= f.text_field :school %>

-

+

<%= f.text_field :series %>

-

+

<%= f.text_field :type %>

-

+

<%= f.text_field :url %>

-

+

<%= f.text_field :volume %>

\ No newline at end of file diff -r c018d0c89c94 -r 468967d012aa vendor/plugins/redmine_bibliography/app/views/publications/_suggest_author.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/_suggest_author.html.erb Tue Dec 04 18:15:17 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_suggest_author.html.erb Wed Dec 05 16:52:43 2012 +0000 @@ -1,16 +1,19 @@ - +<% logger.error { "suggestions #{suggestions}//" } %> <% logger.error { "index #{index}//" } %> -

- Suggestions for Author: <%= h(suggestions[0]) -%> -
- <%- suggestions[1][:authors].each do |auth| -%> - <%= create_author_suggestion_radio("author_#{index}", auth) -%> - <%- end -%> -
- <%- suggestions[1][:users].each do |usr| -%> - <%= create_user_suggestion_radio("author_#{index}", usr) -%> - <%- end -%> -
-

+<%- if suggestions[1][:authors].count + suggestions[1][:users].count > 0 -%> +

+ Could the author "<%= h(suggestions[0]) -%>" be one of the following? +
+ <%- suggestions[1][:authors].each do |auth| -%> + <%= create_author_suggestion_radio("author_#{index}", auth) -%> + <%- end -%> +
+ <%- suggestions[1][:users].each do |usr| -%> + <%= create_user_suggestion_radio("author_#{index}", usr) -%> + <%- end -%> + <%= radio_button_tag("author_#{index}", nil, false) -%><%= l(:none_of_above) %> +
+

+<%- end -%> diff -r c018d0c89c94 -r 468967d012aa vendor/plugins/redmine_bibliography/app/views/publications/new/_bibtex.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/new/_bibtex.html.erb Tue Dec 04 18:15:17 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/new/_bibtex.html.erb Wed Dec 05 16:52:43 2012 +0000 @@ -18,6 +18,10 @@

Authors

+
+ <%= hidden_field_tag "publication_id" %> +
+ <%= f.submit %> <%- end -%> diff -r c018d0c89c94 -r 468967d012aa vendor/plugins/redmine_bibliography/app/views/publications/parse_bibtex.rjs --- a/vendor/plugins/redmine_bibliography/app/views/publications/parse_bibtex.rjs Tue Dec 04 18:15:17 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/parse_bibtex.rjs Wed Dec 05 16:52:43 2012 +0000 @@ -3,9 +3,11 @@ page.insert_html :top, :content, '
Successfully Parsed BibTeX
' @suggested_authors.each_with_index do |auth, idx| - page.insert_html :bottom, :suggest_bibtex_authors, :partial => "suggest_author" , :locals => {:suggestions => auth, :index => idx} + page.insert_html :bottom, :suggest_bibtex_authors, :partial => "suggest_author", :locals => {:suggestions => auth, :index => idx} end + page.replace_html :publication_id, @publication.id + else page.insert_html :top, :content, '
Error parsing BibTeX.
' end