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 @ 393:9595ab4cac6b

History | View | Annotate | Download (1.6 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
    bibtex_entry = params[:bibtex_entry]
17
18 385:a6f8c0584a92 luis
    if bibtex_entry
19
      bib = BibTeX.parse bibtex_entry
20 393:9595ab4cac6b luis
21 385:a6f8c0584a92 luis
      # parses the bibtex entries
22
      bib.data.map do |d|
23
        result = ''
24
        if d.class == BibTeX::Entry
25 393:9595ab4cac6b luis
          @bentry = BibtexEntry.new
26 385:a6f8c0584a92 luis
          #    d.replace!(bib.strings)
27 393:9595ab4cac6b luis
28
          d.fields.keys.map do |k|
29
            @bentry[k] = d[k]
30
          end
31
        end
32 391:fecd4b2f4b77 luis
      end
33 384:4be6b16bc6f9 luis
34 393:9595ab4cac6b luis
      @publication.bibtex_entry = @bentry
35
36
      logger.error @publication.bibtex_entry
37
38
    end
39
  end
40 384:4be6b16bc6f9 luis
41 385:a6f8c0584a92 luis
  def new
42
    @publication = Publication.new
43 386:8ed0a0a268e0 luis
    @publication.current_step = session[:publication_step]
44 393:9595ab4cac6b luis
45 328:aed18b463206 luis
  end
46
47 390:5562a95edbf7 luis
  def create
48
    @publication = Publication.new(params[:publication])
49 391:fecd4b2f4b77 luis
    @publication.current_step = session[:publication_step]
50 384:4be6b16bc6f9 luis
51 391:fecd4b2f4b77 luis
    parse_bibtex_text
52 384:4be6b16bc6f9 luis
53 393:9595ab4cac6b luis
    if @publication.save
54
      logger.error "SAVED"
55
    else
56
      logger.error "NOT SAVED"
57
    end
58
59 390:5562a95edbf7 luis
    if params[:back_button]
60
      @publication.previous_step
61
    else
62
      @publication.next_step
63
    end
64 393:9595ab4cac6b luis
65 390:5562a95edbf7 luis
    session[:publication_step] = @publication.current_step
66 393:9595ab4cac6b luis
67 390:5562a95edbf7 luis
    render "new"
68 329:4575b631f6ce luis
  end
69
70
  def index
71
    @publications = Publication.find(:all)
72 328:aed18b463206 luis
  end
73
74
  def edit
75 384:4be6b16bc6f9 luis
    logger.error "AAAA edit"
76 376:ad71d0604ac2 luis
77 328:aed18b463206 luis
  end
78
79
  def update
80 384:4be6b16bc6f9 luis
81
    logger.error "AAAA update"
82 376:ad71d0604ac2 luis
83
84 328:aed18b463206 luis
  end
85 329:4575b631f6ce luis
86
  def show
87
    @publication = Publication.find(params[id])
88
    @authors = @publication.authors
89
  end
90
91 328:aed18b463206 luis
end