Revision 404:216a61338322 vendor/plugins/redmine_bibliography
| vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb | ||
|---|---|---|
| 13 | 13 |
end |
| 14 | 14 |
|
| 15 | 15 |
def parse_bibtex_text |
| 16 |
bibtex_entry = params[:bibtex_entry]
|
|
| 16 |
bib = BibTeX.parse bibtex_entry
|
|
| 17 | 17 |
|
| 18 |
logger.error bibtex_entry |
|
| 18 |
# 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) |
|
| 19 | 24 |
|
| 20 |
if bibtex_entry |
|
| 21 |
bib = BibTeX.parse bibtex_entry |
|
| 25 |
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 |
|
| 22 | 42 |
|
| 23 |
# parses the bibtex entries |
|
| 24 |
bib.data.map do |d| |
|
| 25 |
result = '' |
|
| 26 |
if d.class == BibTeX::Entry |
|
| 27 |
@bentry = BibtexEntry.new |
|
| 28 |
# d.replace!(bib.strings) |
|
| 43 |
logger.error @publication.bibtex_entry |
|
| 44 |
end |
|
| 29 | 45 |
|
| 30 |
d.fields.keys.map do |k| |
|
| 31 |
if k == "title" |
|
| 32 |
@publication.title = d[k] |
|
| 33 |
else |
|
| 34 |
@bentry[k] = d[k] |
|
| 35 |
end |
|
| 36 |
end |
|
| 37 |
end |
|
| 38 |
end |
|
| 39 |
|
|
| 40 |
@publication.bibtex_entry = @bentry |
|
| 41 |
|
|
| 42 |
if @publication.save |
|
| 43 |
logger.error "SAVED" |
|
| 44 |
else |
|
| 45 |
logger.error "NOT SAVED" |
|
| 46 |
end |
|
| 47 |
|
|
| 48 |
logger.error @publication.bibtex_entry |
|
| 49 |
|
|
| 50 |
end |
|
| 46 |
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] |
|
| 51 | 52 |
end |
| 52 | 53 |
|
| 53 |
def new |
|
| 54 |
@publication = Publication.new |
|
| 55 |
@publication.current_step = session[:publication_step] |
|
| 56 |
|
|
| 57 |
end |
|
| 58 |
|
|
| 59 |
def create |
|
| 54 |
def create |
|
| 60 | 55 |
@publication = Publication.new(params[:publication]) |
| 61 | 56 |
@publication.current_step = session[:publication_step] |
| 62 | 57 |
|
| 63 |
parse_bibtex_text |
|
| 58 |
# contents of the paste text area |
|
| 59 |
bibtex_entry = params[:bibtex_entry] |
|
| 64 | 60 |
|
| 61 |
# debug message |
|
| 62 |
logger.error bibtex_entry |
|
| 65 | 63 |
|
| 64 |
# method for creating "pasted" bibtex entries |
|
| 65 |
if bibtex_entry |
|
| 66 |
parse_bibtex_text |
|
| 67 |
end |
|
| 66 | 68 |
|
| 69 |
# form's flow control |
|
| 67 | 70 |
if params[:back_button] |
| 68 | 71 |
@publication.previous_step |
| 69 | 72 |
else |
Also available in: Unified diff