Revision 393:9595ab4cac6b vendor/plugins/redmine_bibliography/app
| vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb | ||
|---|---|---|
| 5 | 5 |
# parse string with bibtex authors |
| 6 | 6 |
# return an ordered array |
| 7 | 7 |
def parse_authors |
| 8 |
|
|
| 8 |
|
|
| 9 | 9 |
end |
| 10 | 10 |
|
| 11 | 11 |
def parse_bibtex_file |
| 12 |
|
|
| 12 |
|
|
| 13 | 13 |
end |
| 14 | 14 |
|
| 15 | 15 |
def parse_bibtex_text |
| ... | ... | |
| 17 | 17 |
|
| 18 | 18 |
if bibtex_entry |
| 19 | 19 |
bib = BibTeX.parse bibtex_entry |
| 20 |
|
|
| 20 |
|
|
| 21 | 21 |
# parses the bibtex entries |
| 22 | 22 |
bib.data.map do |d| |
| 23 | 23 |
result = '' |
| 24 | 24 |
if d.class == BibTeX::Entry |
| 25 |
@bentry = BibtexEntry.new |
|
| 25 | 26 |
# d.replace!(bib.strings) |
| 26 |
|
|
| 27 |
result = [author, '. ', d.title].join |
|
| 28 |
end |
|
| 27 |
|
|
| 28 |
d.fields.keys.map do |k| |
|
| 29 |
@bentry[k] = d[k] |
|
| 30 |
end |
|
| 31 |
end |
|
| 29 | 32 |
end |
| 30 | 33 |
|
| 31 |
end |
|
| 32 |
end |
|
| 34 |
@publication.bibtex_entry = @bentry |
|
| 35 |
|
|
| 36 |
logger.error @publication.bibtex_entry |
|
| 37 |
|
|
| 38 |
end |
|
| 39 |
end |
|
| 33 | 40 |
|
| 34 | 41 |
def new |
| 35 | 42 |
@publication = Publication.new |
| 36 | 43 |
@publication.current_step = session[:publication_step] |
| 37 |
|
|
| 44 |
|
|
| 38 | 45 |
end |
| 39 | 46 |
|
| 40 | 47 |
def create |
| ... | ... | |
| 43 | 50 |
|
| 44 | 51 |
parse_bibtex_text |
| 45 | 52 |
|
| 53 |
if @publication.save |
|
| 54 |
logger.error "SAVED" |
|
| 55 |
else |
|
| 56 |
logger.error "NOT SAVED" |
|
| 57 |
end |
|
| 58 |
|
|
| 46 | 59 |
if params[:back_button] |
| 47 | 60 |
@publication.previous_step |
| 48 | 61 |
else |
| 49 | 62 |
@publication.next_step |
| 50 | 63 |
end |
| 51 |
|
|
| 64 |
|
|
| 52 | 65 |
session[:publication_step] = @publication.current_step |
| 53 |
|
|
| 66 |
|
|
| 54 | 67 |
render "new" |
| 55 | 68 |
end |
| 56 | 69 |
|
| ... | ... | |
| 75 | 88 |
@authors = @publication.authors |
| 76 | 89 |
end |
| 77 | 90 |
|
| 78 |
|
|
| 79 | 91 |
end |
| vendor/plugins/redmine_bibliography/app/models/authorship.rb | ||
|---|---|---|
| 1 | 1 |
class Authorship < ActiveRecord::Base |
| 2 | 2 |
belongs_to :author |
| 3 | 3 |
belongs_to :publication |
| 4 |
|
|
| 4 | 5 |
end |
| vendor/plugins/redmine_bibliography/app/models/bibtex_entry.rb | ||
|---|---|---|
| 1 |
class BibtexEntry < ActiveRecord::Base |
|
| 2 |
belongs_to :publication |
|
| 3 |
|
|
| 4 |
end |
|
| vendor/plugins/redmine_bibliography/app/models/publication.rb | ||
|---|---|---|
| 3 | 3 |
class Publication < ActiveRecord::Base |
| 4 | 4 |
has_many :authorships |
| 5 | 5 |
has_many :authors, :through => :authorships |
| 6 |
has_one :bibtex_entry |
|
| 6 | 7 |
|
| 7 | 8 |
validates_presence_of :title |
| 8 | 9 |
|
Also available in: Unified diff