# HG changeset patch # User luisf # Date 1302701352 -3600 # Node ID 216a61338322a8b2da0d15a58bef46bb708e84c4 # Parent b15397a5341c98108815e2a8809594a01990b8e2 comments and refactoring diff -r b15397a5341c -r 216a61338322 vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Apr 12 16:35:30 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Wed Apr 13 14:29:12 2011 +0100 @@ -13,57 +13,60 @@ end def parse_bibtex_text - bibtex_entry = params[:bibtex_entry] + bib = BibTeX.parse bibtex_entry - logger.error bibtex_entry + # parses the bibtex entries + bib.data.map do |d| + result = '' + if d.class == BibTeX::Entry + @bentry = BibtexEntry.new + # d.replace!(bib.strings) - if bibtex_entry - bib = BibTeX.parse bibtex_entry + d.fields.keys.map do |k| + if k == "title" + @publication.title = d[k] + else + @bentry[k] = d[k] + end + end + end + end + + @publication.bibtex_entry = @bentry + + if @publication.save + logger.error "SAVED" + else + logger.error "NOT SAVED" + end - # parses the bibtex entries - bib.data.map do |d| - result = '' - if d.class == BibTeX::Entry - @bentry = BibtexEntry.new - # d.replace!(bib.strings) + logger.error @publication.bibtex_entry + end - d.fields.keys.map do |k| - if k == "title" - @publication.title = d[k] - else - @bentry[k] = d[k] - end - end - end - end - - @publication.bibtex_entry = @bentry - - if @publication.save - logger.error "SAVED" - else - logger.error "NOT SAVED" - end - - logger.error @publication.bibtex_entry - - end + def new + # we always try to create at least one publication + @publication = Publication.new + + # the step we're at in the form + @publication.current_step = session[:publication_step] end - def new - @publication = Publication.new - @publication.current_step = session[:publication_step] - - end - - def create + def create @publication = Publication.new(params[:publication]) @publication.current_step = session[:publication_step] - parse_bibtex_text + # contents of the paste text area + bibtex_entry = params[:bibtex_entry] + # debug message + logger.error bibtex_entry + # method for creating "pasted" bibtex entries + if bibtex_entry + parse_bibtex_text + end + # form's flow control if params[:back_button] @publication.previous_step else