Revision 385:a6f8c0584a92 vendor

View differences:

vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb
1
# vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb
2

  
1 3
class PublicationsController < ApplicationController
2 4

  
5
  # parse string with bibtex authors
6
  # return an ordered array
7
  def parse_authors
8
    
9
  end
10

  
11
  def parse_bibtex_file
12
  
13
  end
14

  
3 15
  def parse_bibtex_text
4

  
5
    logger.error "BBBBBBBB"
6

  
7 16
    bibtex_entry = params[:bibtex_entry]
8 17

  
18
    if bibtex_entry
19
      bib = BibTeX.parse bibtex_entry
20
      
21
      # parses the bibtex entries
22
      bib.data.map do |d|
23
        result = ''
24
        if d.class == BibTeX::Entry
25
          #    d.replace!(bib.strings)
26
          result = [d.author, '. ', d.title].join
27
        end
9 28

  
10

  
11

  
12
    #    logger.error bibtex_entry
13

  
14
    if bibtex_entry
15
      Bibtex::Parser.parse_string(bibtex_entry).map do |entry|
16
        logger.error entry[:title]
17
        logger.error entry[:year]
18
        logger.error entry.type  
29
        logger.error result
19 30
      end
20 31
    end
21

  
22
    logger.error "FIM"
23

  
24 32
  end 
25 33

  
26
  def new
27

  
28
    logger.error "AAAAAA"
29

  
30
    logger.error request.request_method
34
  def new 
35
    session[:publication_params] ||= {}
36
    @publication = Publication.new
31 37

  
32 38
    if request.post?
33 39
      parse_bibtex_text
vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb
1
require 'rubygems'
1
# require 'rubygems'
2 2
require 'bibtex'
3 3

  
4

  
4 5
module PublicationsHelper
5 6

  
6 7
end
vendor/plugins/redmine_bibliography/app/models/publication.rb
1
# vendor/plugins/redmine_bibliography/app/models/publication.rb
2

  
1 3
class Publication < ActiveRecord::Base
2 4
  has_many :authorships
3 5
  has_many :authors, :through => :authorships
4 6

  
5 7
  validates_presence_of :title
8
  
9
  attr_writer :current_step
10

  
11
  def current_step
12
    @current_step || steps.first
13
  end
14
  
15
  def steps
16
    %w[new review]
17
  end
18

  
6 19

  
7 20
end
vendor/plugins/redmine_bibliography/app/views/publications/_new_bibtex_step.html.erb
1

  
2
  <h1>New Bibtex</h1>
3
  <p>
4
    <%= f.label :title %>
5
    <%= f.text_field :title %>
6
  </p>
7

  
8

  
9
  <p>
10
  
11
    <%=label_tag :bibtex_entry %>
12
    <%=text_area_tag :bibtex_entry%>
13
  
14
  </p>
15

  
16

  
vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb
1 1
<h1>New Publication</h1>
2 2

  
3
<% form_for(:publication) do |f| %>
3

  
4
<% form_for @publication do |f| %>
4 5
  <% f.error_messages %>
5
  
6
  <p>
7
    <%= f.label :title %>
8
    <%= f.text_field :title %>
9
  </p>
10 6

  
7
  <% render :partial  => "#{@publication.current_step}_bibtex_step", :f => f %>
11 8

  
12
  <p>
13
  
14
    <%=label_tag :bibtex_entry %>
15
    <%=text_area_tag :bibtex_entry%>
16
  
17
  </p>
18

  
19
<%= submit_tag l(:button_submit) %>
9
  <%= submit_tag l(:button_submit) %>
20 10

  
21 11
<% end %>
22 12

  

Also available in: Unified diff