To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / vendor / plugins / redmine_bibliography / app / controllers / publications_controller.rb @ 404:216a61338322

History | View | Annotate | Download (1.92 KB)

1 385:a6f8c0584a92 luis
# vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb
2
3 328:aed18b463206 luis
class PublicationsController < ApplicationController
4
5 385:a6f8c0584a92 luis
  # parse string with bibtex authors
6
  # return an ordered array
7
  def parse_authors
8 393:9595ab4cac6b luis
9 385:a6f8c0584a92 luis
  end
10
11
  def parse_bibtex_file
12 393:9595ab4cac6b luis
13 385:a6f8c0584a92 luis
  end
14
15 384:4be6b16bc6f9 luis
  def parse_bibtex_text
16 404:216a61338322 luis
    bib = BibTeX.parse bibtex_entry
17 384:4be6b16bc6f9 luis
18 404:216a61338322 luis
    # parses the bibtex entries
19
    bib.data.map do |d|
20
      result = ''
21
      if d.class == BibTeX::Entry
22
        @bentry = BibtexEntry.new
23
        #    d.replace!(bib.strings)
24 403:b15397a5341c luis
25 404:216a61338322 luis
        d.fields.keys.map do |k|
26
          if k == "title"
27
            @publication.title = d[k]
28
          else
29
            @bentry[k] = d[k]
30
          end
31
        end
32
      end
33
    end
34
35
    @publication.bibtex_entry = @bentry
36
37
    if @publication.save
38
      logger.error "SAVED"
39
    else
40
      logger.error "NOT SAVED"
41
    end
42 393:9595ab4cac6b luis
43 404:216a61338322 luis
    logger.error @publication.bibtex_entry
44
  end
45 393:9595ab4cac6b luis
46 404:216a61338322 luis
  def new
47
    # we always try to create at least one publication
48
    @publication = Publication.new
49
50
    # the step we're at in the form
51
    @publication.current_step = session[:publication_step]
52 393:9595ab4cac6b luis
  end
53 384:4be6b16bc6f9 luis
54 404:216a61338322 luis
  def create
55 390:5562a95edbf7 luis
    @publication = Publication.new(params[:publication])
56 391:fecd4b2f4b77 luis
    @publication.current_step = session[:publication_step]
57 384:4be6b16bc6f9 luis
58 404:216a61338322 luis
    # contents of the paste text area
59
    bibtex_entry = params[:bibtex_entry]
60 384:4be6b16bc6f9 luis
61 404:216a61338322 luis
    # debug message
62
    logger.error bibtex_entry
63 403:b15397a5341c luis
64 404:216a61338322 luis
    # method for creating "pasted" bibtex entries
65
    if bibtex_entry
66
      parse_bibtex_text
67
    end
68 393:9595ab4cac6b luis
69 404:216a61338322 luis
    # form's flow control
70 390:5562a95edbf7 luis
    if params[:back_button]
71
      @publication.previous_step
72
    else
73
      @publication.next_step
74
    end
75 393:9595ab4cac6b luis
76 390:5562a95edbf7 luis
    session[:publication_step] = @publication.current_step
77 393:9595ab4cac6b luis
78 390:5562a95edbf7 luis
    render "new"
79 329:4575b631f6ce luis
  end
80
81
  def index
82
    @publications = Publication.find(:all)
83 328:aed18b463206 luis
  end
84
85
  def edit
86 384:4be6b16bc6f9 luis
    logger.error "AAAA edit"
87 376:ad71d0604ac2 luis
88 328:aed18b463206 luis
  end
89
90
  def update
91 384:4be6b16bc6f9 luis
92
    logger.error "AAAA update"
93 376:ad71d0604ac2 luis
94
95 328:aed18b463206 luis
  end
96 329:4575b631f6ce luis
97
  def show
98
    @publication = Publication.find(params[id])
99
    @authors = @publication.authors
100
  end
101
102 328:aed18b463206 luis
end