diff --git a/app/assets/javascripts/application/plugins/summernote-paste.js b/app/assets/javascripts/application/plugins/summernote-paste.js deleted file mode 100644 index accc40aa5f7fd205e8cf7c7fd0932542599ccc8b..0000000000000000000000000000000000000000 --- a/app/assets/javascripts/application/plugins/summernote-paste.js +++ /dev/null @@ -1,56 +0,0 @@ -/*global define, module, require */ -(function (factory) { - 'use strict'; - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(['jquery'], factory); - } else if (typeof module === 'object' && module.exports) { - // Node/CommonJS - module.exports = factory(require('jquery')); - } else { - // Browser globals - factory(window.jQuery); - } -}(function ($) { - 'use strict'; - // $.extend($.summernote.options, { - // stripTags: ['section', 'div', 'span', 'o', 'xml', 'font', 'style', 'embed', 'param', 'script', 'html', 'body', 'head', 'meta', 'title', 'link', 'iframe', 'abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'noframes', 'noscript', 'form', 'input', 'select', 'option', 'colgroup', 'col', 'std', 'xml:', 'st1:', 'o:', 'w:', 'v:'], - // onCleanHtml: function (html) { - // var htmlModified = html.replace(/<!\[if !supportLists[\s\S]*?endif\]>/g, '') - // .replace(/<!--[\s\S]*?-->/g, '') - // .replace(/( class=(")?Mso[a-zA-Z]+(")?)/g, ' ') - // .replace(/[\t ]+</g, '<') - // .replace(/>[\t ]+</g, '><') - // .replace(/>[\t ]+$/g, '>') - // .replace(/[\u2018\u2019\u201A]/g, '\'') - // .replace(/[\u201C\u201D\u201E]/g, '"') - // .replace(/\u2026/g, '...') - // .replace(/[\u2013\u2014]/g, '-'); - // return htmlModified; - // } - // }); - - // $.extend($.summernote.plugins, { - // 'striptags': function (context) { - // var $note = context.layoutInfo.note, - // $options = context.options; - // $note.on('summernote.paste', function (e, evt) { - // var text = evt.originalEvent.clipboardData.getData('text/plain'), - // html = evt.originalEvent.clipboardData.getData('text/html'), - // tagStripper = new RegExp('<[ /]*(' + $options.stripTags.join('|') + ')[^>]*>', 'gi'), - // attributeStripper = /<(?!a)(\w+)[^>]*>/gi; - // evt.preventDefault(); - // if (html) { - // html = html.toString(); - // html = $options.onCleanHtml(html); - // html = html.replace(attributeStripper, '<$1>'); - // html = html.replace(tagStripper, ''); - // document.execCommand('insertHTML', false, html); - // } else { - // document.execCommand('insertHTML', false, text); - // } - // return false; - // }); - // } - // }); -})); diff --git a/app/assets/javascripts/application/plugins/summernote.js b/app/assets/javascripts/application/plugins/summernote.js index 4f512e2da3e29deab77ab5fbf517c036a8291217..7e7fee41af9f605860bd4df4f1fcd6e09e171f7d 100644 --- a/app/assets/javascripts/application/plugins/summernote.js +++ b/app/assets/javascripts/application/plugins/summernote.js @@ -1,99 +1,196 @@ /*global $ */ -$(function () { - 'use strict'; +window.summernoteManager = { + configs: {}, + + init: function () { + 'use strict'; + this.setConfigs(); + this.initEditors(); + this.monkeyPatchDropdownButtons(); + }, + + setConfigs: function () { + 'use strict'; + this.setConfig('link', { + toolbar: [ + ['insert', ['link', 'unlink']] + ], + followingToolbar: true, + disableDragAndDrop: true, + callbacks: { + onPaste: this.pasteSanitizedClipboardContent.bind(this, ['a'], ['href', 'target']) + } + }); + + this.setConfig('mini', { + toolbar: [ + ['font', ['bold', 'italic']], + ['position', ['superscript']], + ['insert', ['link', 'unlink']], + ['view', ['codeview']] + ], + followingToolbar: true, + disableDragAndDrop: true, + callbacks: { + onPaste: this.pasteSanitizedClipboardContent.bind(this, ['b', 'strong', 'i', 'em', 'sup', 'a'], ['href', 'target']) + } + }); + + this.setConfig('mini-list', { + toolbar: [ + ['font', ['bold', 'italic']], + ['position', ['superscript']], + ['para', ['ul', 'ol']], + ['insert', ['link', 'unlink']], + ['view', ['codeview']] + ], + followingToolbar: true, + disableDragAndDrop: true, + callbacks: { + onPaste: this.pasteSanitizedClipboardContent.bind(this, ['b', 'strong', 'i', 'em', 'sup', 'a', 'ul', 'ol', 'li'], ['href', 'target']) + } + }); - var configs = []; - - configs['link'] = { - toolbar: [ - ['insert', ['link', 'unlink']] - ], - followingToolbar: true, - disableDragAndDrop: true - }; - - configs['mini'] = { - toolbar: [ - ['font', ['bold', 'italic']], - ['position', ['superscript']], - ['insert', ['link', 'unlink']], - ['view', ['codeview']] - ], - followingToolbar: true, - disableDragAndDrop: true - }; - - configs['mini-list'] = { - toolbar: [ - ['font', ['bold', 'italic']], - ['position', ['superscript']], - ['para', ['ul', 'ol']], - ['insert', ['link', 'unlink']], - ['view', ['codeview']] - ], - followingToolbar: true, - disableDragAndDrop: true - }; - - - configs['full'] = { - toolbar: [ - ['style', ['style']], - ['font', ['bold', 'italic']], - ['position', ['superscript', 'subscript']], - ['para', ['ul', 'ol']], - ['table', ['table']], - ['insert', ['link', 'unlink', 'picture', 'video']], - ['view', ['codeview']] - ], - styleTags: [ - 'p', - 'blockquote', - 'pre', - 'h2', - 'h3', - 'h4' - ], - followingToolbar: true, - disableDragAndDrop: true - }; - - - configs['default'] = { - toolbar: [ - ['style', ['style']], - ['font', ['bold', 'italic']], - ['position', ['superscript', 'subscript']], - ['para', ['ul', 'ol']], - ['view', ['codeview']] - ], - styleTags: [ - 'p', - 'blockquote', - 'pre', - 'h2', - 'h3', - 'h4' - ], - followingToolbar: true, - disableDragAndDrop: true - }; - - $('[data-provider="summernote"]').each(function () { - var config = $(this).attr('data-summernote-config'), + this.setConfig('default', { + toolbar: [ + ['style', ['style']], + ['font', ['bold', 'italic']], + ['position', ['superscript', 'subscript']], + ['para', ['ul', 'ol']], + ['view', ['codeview']] + ], + styleTags: [ + 'p', + 'blockquote', + 'pre', + 'h2', + 'h3', + 'h4' + ], + followingToolbar: true, + disableDragAndDrop: true, + callbacks: { + onPaste: this.pasteSanitizedClipboardContent.bind(this, ['b', 'strong', 'i', 'em', 'sup', 'sub', 'a', 'ul', 'ol', 'li', 'p', 'blockquote', 'pre', 'h2', 'h3', 'h4'], ['href', 'target']) + } + }); + + window.SUMMERNOTE_CONFIGS = this.configs; + }, + + setConfig: function (key, data) { + 'use strict'; + this.configs[key] = data; + }, + + initEditors: function () { + 'use strict'; + $('[data-provider="summernote"]').each(this.initEditor.bind(this)); + }, + + initEditor: function (_, element) { + 'use strict'; + var config = $(element).attr('data-summernote-config'), locale = $('#summernote-locale').data('locale'), options = {}; config = config || 'default'; - options = configs[config]; + options = this.configs[config]; // if locale is undefined, summernote use default (en-US) options['lang'] = locale; - $(this).summernote(options); - }); + $(element).summernote(options); + }, + + monkeyPatchDropdownButtons: function () { + 'use strict'; + // https://github.com/summernote/summernote/issues/4170 + $('button[data-toggle="dropdown"]').each(function () { + $(this).removeAttr('data-toggle') + .attr('data-bs-toggle', 'dropdown'); + }); + }, - // https://github.com/summernote/summernote/issues/4170 - $("button[data-toggle='dropdown']").each(function (index) { - $(this).removeAttr("data-toggle").attr("data-bs-toggle", "dropdown"); - }); + pasteSanitizedClipboardContent: function (allowedTags, allowedAttributes, event) { + 'use strict'; + var text = event.originalEvent.clipboardData.getData('text/plain'), + html = event.originalEvent.clipboardData.getData('text/html'); - window.SUMMERNOTE_CONFIGS = configs; + event.preventDefault(); + if (html) { + html = html.toString(); + html = this.cleanHtml(html); + html = this.sanitizeTags(html, allowedTags); + html = this.sanitizeAttributes(html, allowedAttributes); + document.execCommand('insertHTML', false, html); + } else { + document.execCommand('insertText', false, text); + } + }, + + cleanHtml: function (html) { + 'use strict'; + // remove allMicrosoft Office tag + html = html.replace(/<!\[if !supportLists[\s\S]*?endif\]>/g, ''); + // remove all html comments + html = html.replace(/<!--[\s\S]*?-->/g, ''); + // remove all microsoft attributes, + html = html.replace(/( class=(")?Mso[a-zA-Z]+(")?)/g, ' '); + // ensure regular quote + html = html.replace(/[\u2018\u2019\u201A]/g, '\''); + // ensure regular double quote + html = html.replace(/[\u201C\u201D\u201E]/g, '"'); + // ensure regular ellipsis + html = html.replace(/\u2026/g, '...'); + // ensure regular hyphen + html = html.replace(/[\u2013\u2014]/g, '-'); + return html; + }, + + sanitizeTags: function (html, allowedTags) { + 'use strict'; + var allowedTagsRegex = allowedTags.map(function (e) { + return '(?!' + e + ')'; + }).join(''), + tagStripper = new RegExp('</?' + allowedTagsRegex + '\\w*\\b[^>]*>', 'ig'); + + return html.replace(tagStripper, ''); + }, + + sanitizeAttributes: function (html, allowedAttributes) { + 'use strict'; + var div = document.createElement('div'); + div.innerHTML = html; + this.sanitizeElementAttributes(div, allowedAttributes); + return div.innerHTML; + }, + + sanitizeElementAttributes: function (elmt, allowedAttributes) { + 'use strict'; + var children = elmt.children, + child, + i, + j; + for (i = 0; i < children.length; i += 1) { + child = children[i]; + for (j = child.attributes.length - 1; j >= 0; j -= 1) { + if ($.inArray(child.attributes[j].name, allowedAttributes) < 0) { + child.removeAttributeNode(child.attributes[j]); + } + } + + if (child.children.length) { + this.sanitizeElementAttributes(child, allowedAttributes); + } + } + }, + + invoke: function () { + 'use strict'; + return { + init: this.init.bind(this) + }; + } +}; + +window.addEventListener('DOMContentLoaded', function () { + 'use strict'; + window.summernoteManager.init(); }); diff --git a/app/controllers/admin/university/people_controller.rb b/app/controllers/admin/university/people_controller.rb index d67706aa5df03b24ebcfca286d45778b29609162..da83493acbb45a2c3f44a318548f7a9cd5ed4f20 100644 --- a/app/controllers/admin/university/people_controller.rb +++ b/app/controllers/admin/university/people_controller.rb @@ -109,7 +109,7 @@ class Admin::University::PeopleController < Admin::University::ApplicationContro :phone_mobile, :phone_professional, :phone_personal, :address, :zipcode, :city, :country, :meta_description, :summary, - :biography, :picture, :picture_delete, :picture_infos, + :biography, :picture, :picture_delete, :picture_infos, :picture_credit, :habilitation, :tenure, :url, :linkedin, :twitter, :mastodon, :is_researcher, :is_teacher, :is_administration, :is_alumnus, :user_id, research_laboratory_ids: [], category_ids: [] diff --git a/app/models/university/person.rb b/app/models/university/person.rb index 8f7e1823e9eb277c60dde5972d576a8231dbc321..97b12794f2ad25ca0514c8cfe21e4d55d696cef1 100644 --- a/app/models/university/person.rb +++ b/app/models/university/person.rb @@ -25,6 +25,7 @@ # phone_mobile :string # phone_personal :string # phone_professional :string +# picture_credit :text # slug :string indexed # summary :text # tenure :boolean default(FALSE) diff --git a/app/views/admin/application/static/_breadcrumbs.html.erb b/app/views/admin/application/static/_breadcrumbs.html.erb index 45da218f52d0fe569bac82c8fbbb704bb56dc0ee..d5bc3a90c92d55ee3e9c43526cbe4586d0e2cccb 100644 --- a/app/views/admin/application/static/_breadcrumbs.html.erb +++ b/app/views/admin/application/static/_breadcrumbs.html.erb @@ -4,4 +4,4 @@ breadcrumbs: path: "<%= page.path %>" <% end %> - title: >- - <%= current.to_s %> \ No newline at end of file + <%= current_title %> \ No newline at end of file diff --git a/app/views/admin/communication/websites/agenda/categories/static.html.erb b/app/views/admin/communication/websites/agenda/categories/static.html.erb index cdb7d8ecb2d6a39c8df7560de1425bc79b64dd20..2b283b37cd3643a0044d69618566c7a0b486b684 100644 --- a/app/views/admin/communication/websites/agenda/categories/static.html.erb +++ b/app/views/admin/communication/websites/agenda/categories/static.html.erb @@ -2,9 +2,9 @@ title: "<%= @about.name %>" <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design', full_width: true, toc_offcanvas: true %> -<%= render 'admin/application/static/breadcrumbs', +<%= render 'admin/application/static/breadcrumbs', pages: @website.special_page(Communication::Website::Page::CommunicationAgenda).ancestors_and_self, - current: @about %> + current_title: @about.to_s %> position: <%= @about.position %> <%= render 'admin/application/i18n/static' %> <%= render 'admin/application/featured_image/static' %> diff --git a/app/views/admin/communication/websites/agenda/events/static.html.erb b/app/views/admin/communication/websites/agenda/events/static.html.erb index df1dedfe029b53807558deffdf5b189f95881dc4..1e44c20d8a0322464d118ccfa7e63d3c1bd1debf 100644 --- a/app/views/admin/communication/websites/agenda/events/static.html.erb +++ b/app/views/admin/communication/websites/agenda/events/static.html.erb @@ -2,9 +2,9 @@ title: "<%= @about.title %>" subtitle: "<%= @about.subtitle %>" <%= render 'admin/communication/websites/agenda/events/dates_static', event: @about %> -<%= render 'admin/application/static/breadcrumbs', +<%= render 'admin/application/static/breadcrumbs', pages: @website.special_page(Communication::Website::Page::CommunicationAgenda).ancestors_and_self, - current: @about %> + current_title: @about.to_s %> weight: <%= @about.distance_in_days %> <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design', full_width: false, toc_offcanvas: false %> diff --git a/app/views/admin/communication/websites/configs/deuxfleurs_workflow/static.html.erb b/app/views/admin/communication/websites/configs/deuxfleurs_workflow/static.html.erb index af6834807c68c0710a23a4abc1d39f5efba99963..b386a1f9903876eb478f9255cdc4c0a0605c49e1 100644 --- a/app/views/admin/communication/websites/configs/deuxfleurs_workflow/static.html.erb +++ b/app/views/admin/communication/websites/configs/deuxfleurs_workflow/static.html.erb @@ -38,3 +38,13 @@ jobs: env: AWS_ACCESS_KEY_ID: ${{ secrets.DEUXFLEURS_ACCESS_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.DEUXFLEURS_SECRET }} + + - name: Notification Slack en cas d'échecs + uses: ravsamhq/notify-slack-action@2.3.0 + if: always() + with: + status: ${{ job.status }} + notify_when: "failure" + notification_title: "" + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} \ No newline at end of file diff --git a/app/views/admin/communication/websites/pages/static.html.erb b/app/views/admin/communication/websites/pages/static.html.erb index 21804c972a9f5d8e079c3f3aa3af899b5f8ffc3f..a8a3717a04033f00ea9694fce4c501a7634abcce 100644 --- a/app/views/admin/communication/websites/pages/static.html.erb +++ b/app/views/admin/communication/websites/pages/static.html.erb @@ -1,9 +1,9 @@ --- title: "<%= @about.title %>" breadcrumb_title: "<%= @about.best_title %>" -<%= render 'admin/application/static/breadcrumbs', +<%= render 'admin/application/static/breadcrumbs', pages: @about.ancestors, - current: @about %> + current_title: @about.best_title %> <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design' %> <% if @about.static_layout %> diff --git a/app/views/admin/communication/websites/posts/categories/static.html.erb b/app/views/admin/communication/websites/posts/categories/static.html.erb index 13234a9616553ac09750366c6fc0f90dca6efae9..c5bd4a51e724110da9dece2308e46d7d5928da27 100644 --- a/app/views/admin/communication/websites/posts/categories/static.html.erb +++ b/app/views/admin/communication/websites/posts/categories/static.html.erb @@ -2,9 +2,9 @@ title: "<%= @about.name %>" <%= render 'admin/application/static/permalink', forced_slug: @about.slug_with_ancestors_slugs %> <%= render 'admin/application/static/design', full_width: true, toc_offcanvas: true %> -<%= render 'admin/application/static/breadcrumbs', +<%= render 'admin/application/static/breadcrumbs', pages: @website.special_page(Communication::Website::Page::CommunicationPost).ancestors_and_self, - current: @about %> + current_title: @about.to_s %> <% if @about.parent %> parent: "<%= @about.parent.path %>" <% end %> diff --git a/app/views/admin/communication/websites/posts/static.html.erb b/app/views/admin/communication/websites/posts/static.html.erb index 84fa2a6472f2ac6bc3497e7283cbbb5960adbea8..8f0674964cebbe14c8a5642f4d01a53e06404860 100644 --- a/app/views/admin/communication/websites/posts/static.html.erb +++ b/app/views/admin/communication/websites/posts/static.html.erb @@ -1,9 +1,9 @@ --- title: "<%= @about.title %>" date: "<%= @about.published_at&.iso8601 %>" -<%= render 'admin/application/static/breadcrumbs', +<%= render 'admin/application/static/breadcrumbs', pages: @website.special_page(Communication::Website::Page::CommunicationPost).ancestors_and_self, - current: @about %> + current_title: @about.to_s %> <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design', full_width: false, toc_offcanvas: false %> <% if @about.pinned %> diff --git a/app/views/admin/education/diplomas/static.html.erb b/app/views/admin/education/diplomas/static.html.erb index 707c694956e8c6dc32691d2ada3b1d04af126599..f904c860702e08d03051850f0396077450141a1c 100644 --- a/app/views/admin/education/diplomas/static.html.erb +++ b/app/views/admin/education/diplomas/static.html.erb @@ -3,10 +3,10 @@ title: > <%= prepare_text_for_static @about.name %> <%= render 'admin/application/static/permalink' if @website %> <%= render 'admin/application/static/design', full_width: true, toc_offcanvas: true %> -<%= render 'admin/application/static/breadcrumbs', +<%= render 'admin/application/static/breadcrumbs', pages: @website.special_page(Communication::Website::Page::EducationDiploma).ancestors_and_self, - current: @about %> -<% if @website + current_title: @about.to_s %> +<% if @website @programs = @website.education_programs.where(diploma: @about).root.ordered %> programs: <%= render 'admin/education/diplomas/programs', diploma: @about, programs: @programs %> diff --git a/app/views/admin/education/programs/static.html.erb b/app/views/admin/education/programs/static.html.erb index 79ebfd3e1275168189d5558b78527374581c6565..8ad8110960304e1c974095e0243f83bcfd109bfa 100644 --- a/app/views/admin/education/programs/static.html.erb +++ b/app/views/admin/education/programs/static.html.erb @@ -11,9 +11,9 @@ title: > <%= @about.name %> <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design', full_width: false, toc_offcanvas: true, toc_present: true %> -<%= render 'admin/application/static/breadcrumbs', +<%= render 'admin/application/static/breadcrumbs', pages: @website.special_page(Communication::Website::Page::EducationProgram).ancestors_and_self, - current: @about %> + current_title: @about.to_s %> <% if @about.downloadable_summary.attached? %> downloadable_summary: <%= @about.downloadable_summary.blob_id %> <% end %> diff --git a/app/views/admin/research/hal/publications/static.html.erb b/app/views/admin/research/hal/publications/static.html.erb index 6f74b878d05a82fb190e1bc671e7de90515cfbed..75fbeacb368554157da234689a31ef581e11d3ad 100644 --- a/app/views/admin/research/hal/publications/static.html.erb +++ b/app/views/admin/research/hal/publications/static.html.erb @@ -2,9 +2,9 @@ title: >- <%= @about.title %> date: "<%= @about.publication_date&.iso8601 %>" -<%= render 'admin/application/static/breadcrumbs', +<%= render 'admin/application/static/breadcrumbs', pages: @website.special_page(Communication::Website::Page::ResearchHalPublication).ancestors_and_self, - current: @about %> + current_title: @about.to_s %> <%= render 'admin/application/static/permalink' %> docid: "<%= @about.docid %>" abstract: >- diff --git a/app/views/admin/research/journals/papers/static.html.erb b/app/views/admin/research/journals/papers/static.html.erb index ce7217b7bb0e2c8252daf15daf875a2ea0597bf1..bd77d6822756be10d4899978a347bb52dcba5f9d 100644 --- a/app/views/admin/research/journals/papers/static.html.erb +++ b/app/views/admin/research/journals/papers/static.html.erb @@ -3,9 +3,9 @@ title: >- <%= prepare_text_for_static @about.title %> <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design', full_width: false, toc_offcanvas: false %> -<%= render 'admin/application/static/breadcrumbs', +<%= render 'admin/application/static/breadcrumbs', pages: @website.special_page(Communication::Website::Page::ResearchPaper).ancestors_and_self, - current: @about %> + current_title: @about.to_s %> <% if @about.kind %> paper_kind: >- <%= prepare_text_for_static @about.kind %> diff --git a/app/views/admin/research/journals/volumes/static.html.erb b/app/views/admin/research/journals/volumes/static.html.erb index fa8af83a110f12883455cc11bbc51e5d9a00c7c9..c47e26e1d5f6956a31a93d89ecbd98a12ef89e41 100644 --- a/app/views/admin/research/journals/volumes/static.html.erb +++ b/app/views/admin/research/journals/volumes/static.html.erb @@ -3,9 +3,9 @@ title: >- <%= prepare_text_for_static @about.title %> <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design', full_width: true, toc_offcanvas: false, toc_present: false %> -<%= render 'admin/application/static/breadcrumbs', +<%= render 'admin/application/static/breadcrumbs', pages: @website.special_page(Communication::Website::Page::ResearchVolume).ancestors_and_self, - current: @about %> + current_title: @about.to_s %> number: <%= @about.number %> issn: "<%= @about.journal.issn %>" keywords: > diff --git a/app/views/admin/university/organizations/static.html.erb b/app/views/admin/university/organizations/static.html.erb index 110b6586c3a046b6af895e079c6a1d82f8bd7825..58717ff974dcb5549d7297ea2c16460ca42e07eb 100644 --- a/app/views/admin/university/organizations/static.html.erb +++ b/app/views/admin/university/organizations/static.html.erb @@ -1,9 +1,9 @@ --- title: > <%= @about.to_s %> -<%= render 'admin/application/static/breadcrumbs', +<%= render 'admin/application/static/breadcrumbs', pages: @website.special_page(Communication::Website::Page::Organization).ancestors_and_self, - current: @about %> + current_title: @about.to_s %> <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design', full_width: true, toc_offcanvas: true %> kind: diff --git a/app/views/admin/university/people/_form.html.erb b/app/views/admin/university/people/_form.html.erb index 157cb8266a211c722151f6ed187ab1db6b4560b6..2ca25b424da18b91072ba08561930ca9cb524bbe 100644 --- a/app/views/admin/university/people/_form.html.erb +++ b/app/views/admin/university/people/_form.html.erb @@ -118,6 +118,15 @@ preview: 200, resize: 1, direct_upload: true %> + <%= f.input :picture_credit, + as: :summernote, + hint: t('featured_image.credit.hint'), + input_html: { + data: { + translatable: true, + 'summernote-config' => 'link' + } + } %> <% end %> <%= render 'admin/application/meta_description/form', f: f, about: person %> </div> diff --git a/app/views/admin/university/people/_main_infos.html.erb b/app/views/admin/university/people/_main_infos.html.erb index 475f57b97554f534d1c9cb99521b2e7d6a7a6ff2..71de767a454452eb8dd32e14ad0ddd46c3f4e874 100644 --- a/app/views/admin/university/people/_main_infos.html.erb +++ b/app/views/admin/university/people/_main_infos.html.erb @@ -10,6 +10,11 @@ </span> </p> <% end %> + <% if person.picture_credit.present? %> + <div class="small mb-0"> + <%= sanitize person.picture_credit %> + </div> + <% end %> <% end if person.best_picture.attached? %> <% if person.categories.any? %> diff --git a/app/views/admin/university/people/static.html.erb b/app/views/admin/university/people/static.html.erb index 64218ac7a176a62bf68abc77620809c9340b069f..74085ceb6cf5a9eab311c45c862f1cd3e34da15b 100644 --- a/app/views/admin/university/people/static.html.erb +++ b/app/views/admin/university/people/static.html.erb @@ -3,9 +3,9 @@ title: >- <%= @about.to_s %> linkTitle: >- <%= @about.to_s_alphabetical %> -<%= render 'admin/application/static/breadcrumbs', +<%= render 'admin/application/static/breadcrumbs', pages: @website.special_page(Communication::Website::Page::Person).ancestors_and_self, - current: @about %> + current_title: @about.to_s %> <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/meta_description/static' %> <%= render 'admin/application/summary/static' %> @@ -40,6 +40,8 @@ contact_details: <%= render 'admin/application/static/contact_detail', variable: :email, data: @about.email, kind: ContactDetails::Email %> <% if @about.best_picture.attached? %> image: "<%= @about.best_picture.blob.id %>" +credit: >- + <%= prepare_html_for_static @about.picture_credit, @about.university %> <% end %> roles: <% if @about.author.for_website?(@website) %> diff --git a/config/locales/university/en.yml b/config/locales/university/en.yml index 032c07762af0f890387037d009e578937d84030c..eb9bb65e3164d34a019aa3f5513ffdbc6dbbb370 100644 --- a/config/locales/university/en.yml +++ b/config/locales/university/en.yml @@ -92,6 +92,7 @@ en: phone_personal: Personal phone phone_professional: Professional phone picture: Profile picture + picture_credit: Credit research_journal_papers: Papiers research_laboratories: Research laboratories researcher: Researcher diff --git a/config/locales/university/fr.yml b/config/locales/university/fr.yml index 407e8a7b09e502717a3d35fbb023a220ee4beb56..b070cac54414cbd8e085e85330315a0f500090be 100644 --- a/config/locales/university/fr.yml +++ b/config/locales/university/fr.yml @@ -92,6 +92,7 @@ fr: phone_personal: Téléphone personnel phone_professional: Téléphone professionnel picture: Photo de profil + picture_credit: Crédit research_journal_papers: Papiers research_laboratories: Laboratoires de recherche researcher: Chercheur·e diff --git a/db/migrate/20240129100647_add_photo_credits_to_people.rb b/db/migrate/20240129100647_add_photo_credits_to_people.rb new file mode 100644 index 0000000000000000000000000000000000000000..72fd5f44f36fe18ab102dcc480bac7d698df35d5 --- /dev/null +++ b/db/migrate/20240129100647_add_photo_credits_to_people.rb @@ -0,0 +1,5 @@ +class AddPhotoCreditsToPeople < ActiveRecord::Migration[7.1] + def change + add_column :university_people, :picture_credit, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 72fe05620b73cb80eba5d49dcf5193b4cad1ca9e..13fed44a6deed1228bf58449d77229dcb6a05f54 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.1].define(version: 2024_01_22_144217) do +ActiveRecord::Schema[7.1].define(version: 2024_01_29_100647) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -1037,6 +1037,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_22_144217) do t.string "mastodon" t.uuid "language_id", null: false t.uuid "original_id" + t.text "picture_credit" t.index ["language_id"], name: "index_university_people_on_language_id" t.index ["original_id"], name: "index_university_people_on_original_id" t.index ["slug"], name: "index_university_people_on_slug"