# HG changeset patch # User luisf # Date 1302024662 -3600 # Node ID a6f8c0584a92e26a1ba2ac4822abc94574e18ca5 # Parent 4be6b16bc6f95ba91d759081fc0c900cf78dc6ab using new bibtex parsing plugin; implementing multipage create bibtex form diff -r 4be6b16bc6f9 -r a6f8c0584a92 vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- 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 diff -r 4be6b16bc6f9 -r a6f8c0584a92 vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb --- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Mon Apr 04 17:20:17 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Tue Apr 05 18:31:02 2011 +0100 @@ -1,6 +1,7 @@ -require 'rubygems' +# require 'rubygems' require 'bibtex' + module PublicationsHelper end diff -r 4be6b16bc6f9 -r a6f8c0584a92 vendor/plugins/redmine_bibliography/app/models/publication.rb --- a/vendor/plugins/redmine_bibliography/app/models/publication.rb Mon Apr 04 17:20:17 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb Tue Apr 05 18:31:02 2011 +0100 @@ -1,7 +1,20 @@ +# vendor/plugins/redmine_bibliography/app/models/publication.rb + class Publication < ActiveRecord::Base has_many :authorships has_many :authors, :through => :authorships validates_presence_of :title + + attr_writer :current_step + + def current_step + @current_step || steps.first + end + + def steps + %w[new review] + end + end diff -r 4be6b16bc6f9 -r a6f8c0584a92 vendor/plugins/redmine_bibliography/app/views/publications/_new_bibtex_step.html.erb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_new_bibtex_step.html.erb Tue Apr 05 18:31:02 2011 +0100 @@ -0,0 +1,16 @@ + +

New Bibtex

+

+ <%= f.label :title %> + <%= f.text_field :title %> +

+ + +

+ + <%=label_tag :bibtex_entry %> + <%=text_area_tag :bibtex_entry%> + +

+ + diff -r 4be6b16bc6f9 -r a6f8c0584a92 vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb Mon Apr 04 17:20:17 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb Tue Apr 05 18:31:02 2011 +0100 @@ -1,22 +1,12 @@

New Publication

-<% form_for(:publication) do |f| %> + +<% form_for @publication do |f| %> <% f.error_messages %> - -

- <%= f.label :title %> - <%= f.text_field :title %> -

+ <% render :partial => "#{@publication.current_step}_bibtex_step", :f => f %> -

- - <%=label_tag :bibtex_entry %> - <%=text_area_tag :bibtex_entry%> - -

- -<%= submit_tag l(:button_submit) %> + <%= submit_tag l(:button_submit) %> <% end %>