# HG changeset patch # User luisf # Date 1342026183 -3600 # Node ID 75351d69e2ba7271b193569831a367c9a5ee5f02 # Parent 03975ec7378dbb0034215fe2d5f1cf66d03592b3 Now using bibtex-ruby and citeproc-ruby gems to format bibtex entries. diff -r 03975ec7378d -r 75351d69e2ba vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb --- 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| diff -r 03975ec7378d -r 75351d69e2ba vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb --- 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 @@

<%=l(:label_publication_show)%>

-

- <%= h @publication.title %> -

+ +<%= @publication.title %> + +<%=h show_cite_proc_entry(@publication)%>

<%= l(:authors) %>

+ <%- 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? %>

<%= l(:field_external_url) %> @@ -46,7 +47,7 @@

<% projects = Project.active.find(:all, :limit => 100, :order => 'name ASC') - @publication.projects %> - + <% content_for :sidebar do %>

<%=l(:label_publication_project_index)%>

diff -r 03975ec7378d -r 75351d69e2ba vendor/plugins/redmine_bibliography/init.rb --- 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.