diff --git a/app/controllers/admin/research/journals/papers_controller.rb b/app/controllers/admin/research/journals/papers_controller.rb index 3d88ef07439139a75bc8f27c617d6d2b80078e3c..614f191a858dbb39778c5727dbb35a83ea1c4a78 100644 --- a/app/controllers/admin/research/journals/papers_controller.rb +++ b/app/controllers/admin/research/journals/papers_controller.rb @@ -72,7 +72,7 @@ class Admin::Research::Journals::PapersController < Admin::Research::Journals::A params.require(:research_journal_paper) .permit( :title, :slug, :text, :published, :published_at, :received_at, :accepted_at, - :summary, :abstract, :meta_description, + :summary, :abstract, :meta_description, :doi, :pdf, :references, :keywords, :research_journal_volume_id, :kind_id, person_ids: []) .merge(university_id: current_university.id) end diff --git a/app/models/research/hal/publication.rb b/app/models/research/hal/publication.rb index 577fd844be578a2ef853c59e1a13297f4cd143af..77c8c9c202b984f43198bfa1678f1ea9342d6466 100644 --- a/app/models/research/hal/publication.rb +++ b/app/models/research/hal/publication.rb @@ -24,8 +24,6 @@ class Research::Hal::Publication < ApplicationRecord include WithGit include WithSlug - DOI_PREFIX = 'http://dx.doi.org/'.freeze - has_and_belongs_to_many :researchers, class_name: 'University::Person', foreign_key: 'university_person_id', @@ -77,8 +75,7 @@ class Research::Hal::Publication < ApplicationRecord end def doi_url - return unless doi.present? - "#{DOI_PREFIX}#{doi}" + Doi.url doi end def best_url diff --git a/app/models/research/journal/paper.rb b/app/models/research/journal/paper.rb index a5431743f0686f8241cf2d7c9c62a0fcfe5dfedf..00c33d20e43d2073852c4e6e82a477736957f54b 100644 --- a/app/models/research/journal/paper.rb +++ b/app/models/research/journal/paper.rb @@ -5,6 +5,7 @@ # id :uuid not null, primary key # abstract :text # accepted_at :date +# doi :string # keywords :text # meta_description :text # position :integer @@ -96,6 +97,10 @@ class Research::Journal::Paper < ApplicationRecord dependencies.flatten.compact end + def doi_url + Doi.url doi + end + def to_s "#{ title }" end diff --git a/app/services/doi.rb b/app/services/doi.rb new file mode 100644 index 0000000000000000000000000000000000000000..c71cd3bb7f6804166de88e1a793fd00f50a4e883 --- /dev/null +++ b/app/services/doi.rb @@ -0,0 +1,10 @@ +class Doi + PREFIX = 'https://dx.doi.org/'.freeze + + def self.url(doi) + return nil if doi.blank? + return doi if PREFIX.in?(doi) + "#{PREFIX}#{doi}" + end + +end \ No newline at end of file diff --git a/app/views/admin/research/journals/papers/_form.html.erb b/app/views/admin/research/journals/papers/_form.html.erb index 4769cdfe2c7ae7822065391539f77dd511d525a8..afe1ba6cf57b8430e04078b089e8e414be6a6e8a 100644 --- a/app/views/admin/research/journals/papers/_form.html.erb +++ b/app/views/admin/research/journals/papers/_form.html.erb @@ -8,6 +8,7 @@ <%= f.input :title, as: :text, input_html: { rows: 3 } %> <%= f.input :abstract, as: :text, input_html: { rows: 8 } %> <%= f.input :pdf %> + <%= f.input :doi %> <%= f.input :text, as: :summernote, input_html: { diff --git a/app/views/admin/research/journals/papers/show.html.erb b/app/views/admin/research/journals/papers/show.html.erb index 0a9f938596e2c3e78290ad09e0c8a786f6223f3b..5718ef637b39b4cad79077e6c4ae1c8d0218bafd 100644 --- a/app/views/admin/research/journals/papers/show.html.erb +++ b/app/views/admin/research/journals/papers/show.html.erb @@ -9,6 +9,10 @@ <%= osuny_label Research::Journal::Paper.human_attribute_name('pdf') %> <p><%= link_to @paper.pdf.filename, url_for(@paper.pdf) %></p> <% end %> + <% if @paper.doi.present?%> + <%= osuny_label Research::Journal::Paper.human_attribute_name('doi') %> + <p><%= link_to @paper.doi_url, @paper.doi_url, target: :_blank %></p> + <% end %> <% if has_content?(@paper.text)%> <%= osuny_label Research::Journal::Paper.human_attribute_name('text') %> <%= sanitize @paper.text %> diff --git a/config/locales/research/en.yml b/config/locales/research/en.yml index 0194e6b2b96744b691c2e1c257eb21cc73593c82..c4fb2a96bcc223eaf9c4d25a7fd34b6985c9475a 100644 --- a/config/locales/research/en.yml +++ b/config/locales/research/en.yml @@ -57,6 +57,7 @@ en: title: Title research/journal/paper: abstract: Abstract + doi: DOI keywords: Keywords pdf: PDF published: Published? @@ -113,5 +114,7 @@ en: select_identifier: Select all the HAL authors that correspond to this researcher. Use the publications to be sure it's the same person. simple_form: hints: + research_journal_paper: + doi: "You can type the DOI identifier without https://, for example “10.19182/perspective/31918â€" research_journal_volume: cover: JPG or PNG file diff --git a/config/locales/research/fr.yml b/config/locales/research/fr.yml index 662de36a6a74b4ceb8bd074c940c01737883171a..895456f73ddbd7bcec3fc8c0c87c7413a95e72e7 100644 --- a/config/locales/research/fr.yml +++ b/config/locales/research/fr.yml @@ -58,6 +58,7 @@ fr: title: Titre research/journal/paper: abstract: Extrait + doi: DOI keywords: Mots clés pdf: PDF published: Publié ? @@ -113,5 +114,7 @@ fr: select_identifier: Choisissez tou·te·s les auteur·e·s HAL correspondant à cette personne. Appuyez-vous sur les publications pour vérifier qu'il s'agit de la bonne personne. simple_form: hints: + research_journal_paper: + doi: "Vous pouvez saisir l'identifiant DOI sans https://, par exemple “10.19182/perspective/31918â€" research_journal_volume: cover: Fichier JPG ou PNG diff --git a/db/migrate/20230315170508_add_doi_to_research_journal_paper.rb b/db/migrate/20230315170508_add_doi_to_research_journal_paper.rb new file mode 100644 index 0000000000000000000000000000000000000000..1d4071dd6112031ec604dcf9cdc3c83b6c670cd9 --- /dev/null +++ b/db/migrate/20230315170508_add_doi_to_research_journal_paper.rb @@ -0,0 +1,5 @@ +class AddDoiToResearchJournalPaper < ActiveRecord::Migration[7.0] + def change + add_column :research_journal_papers, :doi, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 27c178af5bf1a8efa547f39b20b7d488443da99e..63dd4cef42ba995dbd79188b61ef6b3eaacf62b5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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_03_15_142604) do +ActiveRecord::Schema[7.0].define(version: 2023_03_15_170508) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -758,6 +758,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_15_142604) do t.uuid "kind_id" t.date "received_at" t.date "accepted_at" + t.string "doi" t.index ["kind_id"], name: "index_research_journal_papers_on_kind_id" t.index ["research_journal_id"], name: "index_research_journal_papers_on_research_journal_id" t.index ["research_journal_volume_id"], name: "index_research_journal_papers_on_research_journal_volume_id"