diff vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb @ 385:a6f8c0584a92 feature_36

using new bibtex parsing plugin; implementing multipage create bibtex form
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Tue, 05 Apr 2011 18:31:02 +0100
parents 4be6b16bc6f9
children 8ed0a0a268e0
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Mon Apr 04 17:20:17 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Tue Apr 05 18:31:02 2011 +0100
@@ -1,33 +1,39 @@
+# vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb
+
 class PublicationsController < ApplicationController
 
+  # parse string with bibtex authors
+  # return an ordered array
+  def parse_authors
+    
+  end
+
+  def parse_bibtex_file
+  
+  end
+
   def parse_bibtex_text
-
-    logger.error "BBBBBBBB"
-
     bibtex_entry = params[:bibtex_entry]
 
+    if bibtex_entry
+      bib = BibTeX.parse bibtex_entry
+      
+      # parses the bibtex entries
+      bib.data.map do |d|
+        result = ''
+        if d.class == BibTeX::Entry
+          #    d.replace!(bib.strings)
+          result = [d.author, '. ', d.title].join
+        end
 
-
-
-    #    logger.error bibtex_entry
-
-    if bibtex_entry
-      Bibtex::Parser.parse_string(bibtex_entry).map do |entry|
-        logger.error entry[:title]
-        logger.error entry[:year]
-        logger.error entry.type  
+        logger.error result
       end
     end
-
-    logger.error "FIM"
-
   end 
 
-  def new
-
-    logger.error "AAAAAA"
-
-    logger.error request.request_method
+  def new 
+    session[:publication_params] ||= {}
+    @publication = Publication.new
 
     if request.post?
       parse_bibtex_text