Skip to content
Snippets Groups Projects
Commit e384fc27 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

citeproc

parent ae658111
No related branches found
No related tags found
No related merge requests found
......@@ -60,7 +60,9 @@ class Research::Hal::Publication < ApplicationRecord
'abstract_s',
'openAccess_bool',
'journalTitle_s',
'authLastNameFirstName_s',
'authFullName_s',
'authLastName_s',
'authFirstName_s',
'files_s'
# '*',
]
......@@ -87,7 +89,14 @@ class Research::Hal::Publication < ApplicationRecord
publication.open_access = doc.attributes['openAccess_bool']
publication.journal_title = doc.attributes['journalTitle_s']
publication.file = doc.attributes['files_s']&.first
publication.authors_list = doc.attributes['authLastNameFirstName_s'].join(', ')
publication.authors_list = doc.attributes['authFullName_s'].join(', ')
publication.authors_citeproc = []
doc.attributes['authLastName_s'].each_with_index do |last_name, index|
publication.authors_citeproc << {
"family" => last_name,
"given" => doc.attributes['authFirstName_s'][index]
}
end
publication.save
publication
end
......@@ -117,9 +126,7 @@ class Research::Hal::Publication < ApplicationRecord
def to_citeproc(website: nil)
{
"title" => title,
"author" => authors.map { |author|
{ "family" => author.last_name, "given" => author.first_name }
},
"author" => authors_citeproc,
"URL" => hal_url,
"container-title" => journal_title,
"pdf" => file,
......
class AddAuthorsCiteprocToResearchHalPublications < ActiveRecord::Migration[7.0]
def change
add_column :research_hal_publications, :authors_citeproc, :json
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2023_07_11_071413) do
ActiveRecord::Schema[7.0].define(version: 2023_07_11_073707) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
......@@ -744,6 +744,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_07_11_071413) do
t.string "journal_title"
t.text "file"
t.text "authors_list"
t.json "authors_citeproc"
t.index ["docid"], name: "index_research_hal_publications_on_docid"
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment