diff --git a/app/controllers/admin/research/hal/publications_controller.rb b/app/controllers/admin/research/hal/publications_controller.rb index 2f865345d72d8a6f31fca429c46e11fbce5dccc6..1660210880016502a4628ee44a7e2dd3760de1e2 100644 --- a/app/controllers/admin/research/hal/publications_controller.rb +++ b/app/controllers/admin/research/hal/publications_controller.rb @@ -12,6 +12,7 @@ class Admin::Research::Hal::PublicationsController < Admin::Research::Hal::Appli def static @about = @publication + @website = @publication.websites&.first render layout: false end diff --git a/app/models/communication/website/page/research_hal_publication.rb b/app/models/communication/website/page/research_hal_publication.rb new file mode 100644 index 0000000000000000000000000000000000000000..9fc695c7888fcf8b8a736d45307c77f16a8ca941 --- /dev/null +++ b/app/models/communication/website/page/research_hal_publication.rb @@ -0,0 +1,27 @@ +class Communication::Website::Page::ResearchHalPublication < Communication::Website::Page + + def is_necessary_for_website? + website.connected_hal_publications.any? + end + + def editable_width? + false + end + + def full_width_by_default? + true + end + + def dependencies + super + + [website.config_default_languages] + + website.connected_hal_publications + end + + protected + + def current_git_path + @current_git_path ||= "#{git_path_prefix}publications/_index.html" + end + +end diff --git a/app/models/communication/website/page/with_type.rb b/app/models/communication/website/page/with_type.rb index c60722771519df44324689112b0b490e2e23d521..dd1333e11bd8de027a238c2237c6ba93708f984b 100644 --- a/app/models/communication/website/page/with_type.rb +++ b/app/models/communication/website/page/with_type.rb @@ -17,6 +17,7 @@ module Communication::Website::Page::WithType # Research Communication::Website::Page::ResearchVolume, Communication::Website::Page::ResearchPaper, + Communication::Website::Page::ResearchHalPublication, # People facets Communication::Website::Page::Administrator, Communication::Website::Page::Author, diff --git a/app/models/communication/website/permalink/publication.rb b/app/models/communication/website/permalink/publication.rb new file mode 100644 index 0000000000000000000000000000000000000000..b5904c51eac1f2d519be2a6046c3e4a4de0b03cd --- /dev/null +++ b/app/models/communication/website/permalink/publication.rb @@ -0,0 +1,26 @@ +class Communication::Website::Permalink::Publication < Communication::Website::Permalink + def self.required_in_config?(website) + website.connected_hal_publications.any? + end + + def self.static_config_key + :publications + end + + def self.pattern_in_website(website, language) + "/#{website.special_page(Communication::Website::Page::ResearchHalPublication, language: language).slug_with_ancestors}/:year/:slug/" + end + + protected + + def published? + website.id == about.communication_website_id && about.published && about.published_at + end + + def substitutions + { + year: about.publication_date.strftime("%Y"), + slug: about.slug + } + end +end diff --git a/app/models/communication/website/with_connected_objects.rb b/app/models/communication/website/with_connected_objects.rb index edcd2e610ac3b61d476e40664b7cd643c32fc2ff..92da5f081dbc6397056a07dc2c632ee297d94d0c 100644 --- a/app/models/communication/website/with_connected_objects.rb +++ b/app/models/communication/website/with_connected_objects.rb @@ -69,6 +69,11 @@ module Communication::Website::WithConnectedObjects University::Organization.where(id: ids) end + def connected_hal_publications + ids = connections.where(indirect_object_type: 'Research::Hal::Publication').pluck(:indirect_object_id) + Research::Hal::Publication.where(id: ids) + end + # ensure the object "website" respond to both is_direct_object? and is_indirect_object? as website doesn't include neither as_direct_object nor as_indirect_object def is_direct_object? true diff --git a/app/models/concerns/with_translations.rb b/app/models/concerns/with_translations.rb index 50d90c41243c6b321629814a5021c3c45a935fdb..761aa5a40526e3de3dce3fd9b50b3bc61cd3b340 100644 --- a/app/models/concerns/with_translations.rb +++ b/app/models/concerns/with_translations.rb @@ -94,6 +94,8 @@ module WithTranslations filename: public_send(attachment_name).filename.to_s, content_type: public_send(attachment_name).content_type ) + rescue + # Missing attachment end def translate_additional_data!(translation) diff --git a/app/models/education/school.rb b/app/models/education/school.rb index 81467db462a229a5df7832c346bad8de34ca1cee..9941eb6814f472623dcfd99f20bc50ab1e37eaf9 100644 --- a/app/models/education/school.rb +++ b/app/models/education/school.rb @@ -75,7 +75,8 @@ class Education::School < ApplicationRecord active_storage_blobs + programs + diplomas + - administrators.map(&:administrator) + administrators.map(&:administrator) + + researchers.map(&:researcher) end ##################### diff --git a/app/models/research/hal/publication.rb b/app/models/research/hal/publication.rb index b51772181c60cef522881dccd70504136471c6b9..913b1dc2b9fe5bf9b7b2a98861dfdfd432c2cab6 100644 --- a/app/models/research/hal/publication.rb +++ b/app/models/research/hal/publication.rb @@ -48,10 +48,15 @@ class Research::Hal::Publication < ApplicationRecord 'docid', 'title_s', 'citationRef_s', + 'citationFull_s', 'uri_s', 'doiId_s', 'publicationDate_tdate', 'linkExtUrl_s', + 'abstract_s', + 'openAccess_bool', + 'journalTitle_s', + 'files_s' # '*', ] publications = [] @@ -68,16 +73,25 @@ class Research::Hal::Publication < ApplicationRecord puts "HAL sync publication #{doc.docid}" publication.title = Osuny::Sanitizer.sanitize doc.title_s.first, 'string' publication.ref = doc.attributes['citationRef_s'] + publication.citation_full = doc.attributes['citationFull_s'] + publication.abstract = doc.attributes['abstract_s']&.first publication.hal_url = doc.attributes['uri_s'] publication.doi = doc.attributes['doiId_s'] publication.publication_date = doc.attributes['publicationDate_tdate'] publication.url = doc.attributes['linkExtUrl_s'] + publication.open_access = doc.attributes['openAccess_bool'] + publication.journal_title = doc.attributes['journalTitle_s'] + publication.file = doc.attributes['files_s']&.first publication.save publication end def template_static - "admin/research/publications/static" + "admin/research/hal/publications/static" + end + + def git_path(website) + "#{git_path_content_prefix(website)}publications/#{created_at.year}/#{slug}.html" if for_website?(website) end def doi_url diff --git a/app/models/university/person/researcher.rb b/app/models/university/person/researcher.rb index 6fbd666ad02fadd718e0c2390fe702851f926757..43c4da82367f84cb65a36fe571f32b96bd3ece62 100644 --- a/app/models/university/person/researcher.rb +++ b/app/models/university/person/researcher.rb @@ -66,7 +66,8 @@ class University::Person::Researcher < University::Person end def dependencies - [person] + [person] + + research_hal_publications end def references diff --git a/app/views/admin/research/hal/publications/show.html.erb b/app/views/admin/research/hal/publications/show.html.erb index 5c84a479d4022d96e45562ce5a8e1e5905371664..da9578ae684431b314a4035dec57694c8afee425 100644 --- a/app/views/admin/research/hal/publications/show.html.erb +++ b/app/views/admin/research/hal/publications/show.html.erb @@ -2,8 +2,20 @@ <div class="row"> <div class="col-lg-8"> - <p class="lead mb-4"><%= sanitize @publication.ref %></p> + <% if @publication.abstract.present? %> + <p class="lead mb-5"> + <%= sanitize @publication.abstract %> + </p> + <% end %> <div class="row"> + <div class="col-lg-6"> + <%= osuny_label Research::Hal::Publication.human_attribute_name('citation_full') %> + <p><%= sanitize @publication.citation_full %></p> + </div> + <div class="col-lg-6"> + <%= osuny_label Research::Hal::Publication.human_attribute_name('ref') %> + <p><%= sanitize @publication.ref %></p> + </div> <div class="col-lg-6"> <%= osuny_label Research::Hal::Publication.human_attribute_name('docid') %> <p><%= @publication.docid %></p> @@ -12,6 +24,10 @@ <%= osuny_label Research::Hal::Publication.human_attribute_name('publication_date') %> <p><%= l @publication.publication_date %></p> </div> + <div class="col-lg-6"> + <%= osuny_label Research::Hal::Publication.human_attribute_name('open_access') %> + <p><%= t @publication.open_access %></p> + </div> </div> </div> <div class="col-lg-4"> @@ -35,7 +51,7 @@ </div> </div> -<% [:url, :hal_url, :doi_url].each do |key| %> +<% [:url, :hal_url, :doi_url, :file].each do |key| %> <% value = @publication.send key %> <% next if value.blank? %> <%= osuny_label Research::Hal::Publication.human_attribute_name(key) %> diff --git a/app/views/admin/research/hal/publications/static.html.erb b/app/views/admin/research/hal/publications/static.html.erb index 5910efe141522de01b82ee8447c1558390ce224e..9d2bc84efd8b4d4eba87a904ed0cbca7c9442a42 100644 --- a/app/views/admin/research/hal/publications/static.html.erb +++ b/app/views/admin/research/hal/publications/static.html.erb @@ -3,12 +3,19 @@ title: "<%= @about.title %>" date: "<%= @about.publication_date&.iso8601 %>" slug: "<%= @about.slug %>" docid: "<%= @about.docid %>" -ref: > +abstract: >- + <%= prepare_html_for_static @about.abstract, @website.university %> +citation_full: >- + <%= prepare_html_for_static @about.citation_full, @website.university %> +authors: >- + <%= @about.authors.ordered.join(', ') %> +ref: >- <%= sanitize @about.ref %> url: hal: "<%= @about.hal_url %>" doi: "<%= @about.doi_url %>" raw: "<%= @about.url %>" + file: "<%= @about.file %>" researchers: <% @about.researchers.each do |researcher| %> - <%= researcher.slug %> diff --git a/app/views/admin/university/people/researchers/_researcher.html.erb b/app/views/admin/university/people/researchers/_researcher.html.erb index d79fa151e8ef1e81602c753dd175c591f542e032..cfea76c9135439d0efa35d439752b0836093a947 100644 --- a/app/views/admin/university/people/researchers/_researcher.html.erb +++ b/app/views/admin/university/people/researchers/_researcher.html.erb @@ -1,8 +1,10 @@ <article class="mb-4 d-flex align-items-center position-relative"> - <div style="width: 80px"> - <%= kamifusen_tag researcher.best_picture, width: 80, class: 'img-circle' if researcher.best_picture.attached? %> - </div> - <div class="ms-3"> + <% if researcher.best_picture.attached? %> + <div class="me-3" style="width: 80px"> + <%= kamifusen_tag researcher.best_picture, width: 80, class: 'img-circle' %> + </div> + <% end %> + <div> <%= link_to researcher, admin_research_researcher_path(researcher), class: 'stretched-link' %> </div> </article> diff --git a/config/application.sample.yml b/config/application.sample.yml index 998c1a2b9f7e6a66e11b3daf282e9b2c661261ef..5e3269d246b7d2fdc8139cd4d3f24f1bced034be 100644 --- a/config/application.sample.yml +++ b/config/application.sample.yml @@ -35,6 +35,8 @@ UNSPLASH_ACCESS_KEY: UNSPLASH_SECRET: PEXELS_API_KEY: +MAINTENANCE: "false" + # Pour les tests automatisés TEST_GITHUB_BRANCH: TEST_GITHUB_ENDPOINT: '' # no use for github @@ -45,3 +47,4 @@ TEST_GITLAB_BRANCH: TEST_GITLAB_ENDPOINT: TEST_GITLAB_TOKEN: TEST_GITLAB_REPOSITORY: + diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 5c36b5931f021233ab586783c9c7ae38c691a6e5..153ee23b13485d2bfd0dc26843165cb98517551e 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -738,6 +738,9 @@ en: privacy_policy: slug: privacy-policy title: Privacy policy + research_hal_publication: + slug: publications + title: HAL publications research_paper: slug: papers title: Papers diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 003753ea8759fc625f03640a4eef456b93b89d69..5a0e78892f931af49d293d8d82c6ff8d00aa6643 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -738,6 +738,9 @@ fr: privacy_policy: slug: politique-de-confidentialite title: Politique de confidentialité + research_hal_publication: + slug: publications + title: Publications HAL research_paper: slug: papiers title: Papiers diff --git a/db/migrate/20230705073214_add_fields_to_research_hal_publication.rb b/db/migrate/20230705073214_add_fields_to_research_hal_publication.rb new file mode 100644 index 0000000000000000000000000000000000000000..680756b70fb3f876f9dfd098dc156e9b4a3a2dc4 --- /dev/null +++ b/db/migrate/20230705073214_add_fields_to_research_hal_publication.rb @@ -0,0 +1,9 @@ +class AddFieldsToResearchHalPublication < ActiveRecord::Migration[7.0] + def change + add_column :research_hal_publications, :citation_full, :text + add_column :research_hal_publications, :open_access, :boolean + add_column :research_hal_publications, :abstract, :text + add_column :research_hal_publications, :journal_title, :string + add_column :research_hal_publications, :file, :text + end +end