Skip to content
Snippets Groups Projects
Unverified Commit 9553dc5e authored by Sébastien Gaya's avatar Sébastien Gaya Committed by GitHub
Browse files

Merge branch 'main' into website-localization

parents ce4f574b 2fb756f2
No related branches found
No related tags found
No related merge requests found
Showing
with 240 additions and 172 deletions
/*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;
// });
// }
// });
}));
/*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();
});
......@@ -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: []
......
......@@ -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)
......
......@@ -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
......@@ -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' %>
......
......@@ -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 %>
......
......@@ -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
---
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 %>
......
......@@ -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 %>
......
---
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 %>
......
......@@ -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 %>
......
......@@ -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 %>
......
......@@ -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: >-
......
......@@ -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 %>
......
......@@ -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: >
......
---
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:
......
......@@ -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>
......
......@@ -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? %>
......
......@@ -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) %>
......
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