changeset 945:75351d69e2ba bibplugin_bibtex

Now using bibtex-ruby and citeproc-ruby gems to format bibtex entries.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Wed, 11 Jul 2012 18:03:03 +0100
parents 03975ec7378d
children a0c9cc95bcf3
files vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb vendor/plugins/redmine_bibliography/init.rb
diffstat 3 files changed, 34 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb	Wed Jul 11 14:43:58 2012 +0100
+++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb	Wed Jul 11 18:03:03 2012 +0100
@@ -89,7 +89,6 @@
     s   
   end
   
-    
   def render_projects_list(publication, show_delete_icon)    
     s= ""
     
@@ -99,6 +98,7 @@
       if show_delete_icon  
         if User.current.allowed_to?(:edit_publication, @project)
           if @project == proj
+            # todo: move this message to yml file
             confirm_msg = 'Are you sure you want to remove the current project from this publication\'s projects list?'
           else
             confirm_msg = false
@@ -114,6 +114,29 @@
     s  
   end
   
+  def show_cite_proc_entry(publication)    
+    s = ""
+
+    # code that should be moved either to the model or to the controller
+
+    book = BibTeX::Entry.new
+    
+    publication.bibtex_entry.attributes.keys.sort.each do |key|      
+      value = publication.bibtex_entry.attributes[key].to_s
+      next if key == 'id' or key == 'publication_id' or value == ""
+      
+      if key == "entry_type"
+         book[key.to_sym] = publication.bibtex_entry.entry_type_label
+      else
+         book[key.to_sym] = value
+      end
+                 
+    end
+  
+    s << CiteProc.process(book.to_citeproc)
+  end
+    
+  
   def show_bibtex_fields(bibtex_entry)
     s = ""
     bibtex_entry.attributes.keys.sort.each do |key|
--- a/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb	Wed Jul 11 14:43:58 2012 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb	Wed Jul 11 18:03:03 2012 +0100
@@ -3,9 +3,10 @@
 <h2><%=l(:label_publication_show)%></h2>
 
 <div class="box">
-<h3>
-  <%= h @publication.title %>
-</h3>
+
+<%= @publication.title %>
+
+<%=h show_cite_proc_entry(@publication)%>
 
 <h4><%= l(:authors) %></h4>
 <ul id="authorships">
@@ -18,6 +19,7 @@
     <%- end -%>
   <%- end -%>
 </ul>
+
 <%- if User.current.allowed_to?(:edit_publication, @project) && @publication.authorships.length > 1 -%>
   <%= sortable_element("authorships", :url => { :controller => :publications, :action => :sort_author_order }, :handle => "handle") %>
 <%- end -%>
@@ -26,7 +28,6 @@
   <%= show_bibtex_fields(@publication.bibtex_entry) %>
 <%- end -%>
 
-
 <% unless @publication.external_url.blank? %>
   <h4>
     <%= l(:field_external_url) %>
@@ -46,7 +47,7 @@
 </div>
 
 <% projects = Project.active.find(:all, :limit => 100, :order => 'name ASC') - @publication.projects %>
-
+  
 <% content_for :sidebar do %>
   <h3><%=l(:label_publication_project_index)%></h3>
 
--- a/vendor/plugins/redmine_bibliography/init.rb	Wed Jul 11 14:43:58 2012 +0100
+++ b/vendor/plugins/redmine_bibliography/init.rb	Wed Jul 11 18:03:03 2012 +0100
@@ -1,6 +1,10 @@
 require 'redmine'
 require 'dispatcher'
 
+require 'bibtex'
+require 'citeproc'
+
+
 RAILS_DEFAULT_LOGGER.info 'Starting Bibliography Plugin for RedMine'
 
 # Patches to the Redmine core.