changeset 384:4be6b16bc6f9 feature_36

DEV commit: beginning of bibtex parser integration.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Mon, 04 Apr 2011 17:20:17 +0100
parents ad71d0604ac2
children a6f8c0584a92
files vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb
diffstat 3 files changed, 56 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Thu Mar 31 18:59:07 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Mon Apr 04 17:20:17 2011 +0100
@@ -1,21 +1,52 @@
 class PublicationsController < ApplicationController
 
+  def parse_bibtex_text
+
+    logger.error "BBBBBBBB"
+
+    bibtex_entry = params[:bibtex_entry]
+
+
+
+
+    #    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  
+      end
+    end
+
+    logger.error "FIM"
+
+  end 
+
   def new
-    
-    @publication = Publication.new(params[:publication])
-    
-    if @publication.save
-      logger.error "GRAVOU XXXdsfgXXX"
-    else
-      logger.error "nao gravou"
+
+    logger.error "AAAAAA"
+
+    logger.error request.request_method
+
+    if request.post?
+      parse_bibtex_text
+      @publication = Publication.new(params[:publication])
+
+      if @publication.save
+        logger.error "GRAVOU XXXdsfgXXX"
+      else
+        logger.error "nao gravou"
+      end
+
     end
-    
+
   end
 
   def create
-    
+
     logger.error "AAAA create"
-    
+
     @publication.save
   end
 
@@ -24,13 +55,13 @@
   end
 
   def edit
-        logger.error "AAAA edit"
+    logger.error "AAAA edit"
 
   end
 
   def update
-    
-        logger.error "AAAA update"
+
+    logger.error "AAAA update"
 
 
   end
--- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb	Thu Mar 31 18:59:07 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb	Mon Apr 04 17:20:17 2011 +0100
@@ -1,2 +1,6 @@
+require 'rubygems'
+require 'bibtex'
+
 module PublicationsHelper
+
 end
--- a/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb	Thu Mar 31 18:59:07 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb	Mon Apr 04 17:20:17 2011 +0100
@@ -8,6 +8,14 @@
     <%= f.text_field :title %>
   </p>
 
+
+  <p>
+  
+    <%=label_tag :bibtex_entry %>
+    <%=text_area_tag :bibtex_entry%>
+  
+  </p>
+
 <%= submit_tag l(:button_submit) %>
 
 <% end %>