Revision 1024:503ed68a4e0f vendor/plugins/redmine_bibliography/app/models

View differences:

vendor/plugins/redmine_bibliography/app/models/author.rb
1 1
class Author < ActiveRecord::Base
2
  unloadable
3
  
2 4
  has_many :authorships, :dependent => :destroy
3 5
  has_many :publications, :through => :authorships
4 6

  
vendor/plugins/redmine_bibliography/app/models/bibtex_entry_type.rb
1 1
class BibtexEntryType < ActiveRecord::Base
2
  unloadable
2 3

  
3 4
  @@fields = Hash['article', ['journal', 'year', 'volume', 'number', 'pages', 'month', 'note' ], 
4 5
                  'book' , [ 'editor', 'publisher', 'volume', 'series', 'address', 'edition', 'month', 'year', 'note' ],
vendor/plugins/redmine_bibliography/app/models/publication.rb
57 57
    end    
58 58
  end
59 59
  
60
  def print_bibtex_author_names
61
    # this authors are correctly sorted because the authorships model 
62
    # already outputs the author names ASC by auth_order
63
    self.authorships.map{|a| a.name_on_paper}.join(' and ')
64
  end  
60 65
  
61
  
62
  
66
  def print_entry(style)
67
    bib = BibTeX::Entry.new
68

  
69
    bib.author = self.print_bibtex_author_names
70
    bib.title = self.title
71

  
72

  
73
    self.bibtex_entry.attributes.keys.sort.each do |key|      
74
      value = self.bibtex_entry.attributes[key].to_s
75
      next if key == 'id' or key == 'publication_id' or value == ""
76

  
77
      if key == "entry_type"
78
        bib.type = self.bibtex_entry.entry_type_label
79
      else
80
        bib[key.to_sym] = value
81
      end               
82
    end
83
    
84
    if style == :ieee
85
      CiteProc.process bib.to_citeproc, :style => :ieee, :format => :html      
86
    else 
87
      bibtex = bib.to_s :include => :meta_content
88
      bibtex.strip!
89
      logger.error { bibtex }
90
    end  
91
  end
63 92
end

Also available in: Unified diff