diff --git a/app/controllers/admin/communication/websites/localizations_controller.rb b/app/controllers/admin/communication/websites/localizations_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..afc6d455ce3200687cede9cb08627bd0b26466ac --- /dev/null +++ b/app/controllers/admin/communication/websites/localizations_controller.rb @@ -0,0 +1,38 @@ +class Admin::Communication::Websites::LocalizationsController < Admin::Communication::Websites::ApplicationController + before_action :load_localization + + def show + breadcrumb + end + + def update + if @localization.update_and_sync(localization_params) + redirect_to admin_communication_website_localization_path, notice: t('admin.successfully_updated_html', model: Communication::Website::Localization.model_name.human) + else + breadcrumb + render :show, status: :unprocessable_entity + end + end + + protected + + def load_localization + @localization = @website.find_or_create_localization_for(current_website_language) + authorize! :update, @localization + end + + def breadcrumb + super + add_breadcrumb helpers.language_name(current_website_language.iso_code) + add_breadcrumb t('admin.communication.website.localizations.title') + end + + def localization_params + params.require(:communication_website_localization) + .permit( + :name, + :social_email, :social_facebook, :social_github, :social_instagram, :social_linkedin, + :social_mastodon, :social_peertube, :social_tiktok, :social_vimeo, :social_x, :social_youtube + ) + end +end 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/helpers/admin/communication/website/localizations_helper.rb b/app/helpers/admin/communication/website/localizations_helper.rb new file mode 100644 index 0000000000000000000000000000000000000000..e30177825a91f379fb2dd4352d90b28667cbfa5a --- /dev/null +++ b/app/helpers/admin/communication/website/localizations_helper.rb @@ -0,0 +1,17 @@ +module Admin::Communication::Website::LocalizationsHelper + def localization_input(f, attribute_name, website) + label = Communication::Website.human_attribute_name(attribute_name) + + is_editing_master = f.object.is_a?(Communication::Website) + master_value = website.public_send(attribute_name) + if !is_editing_master && master_value.present? + hint = t('admin.communication.website.localizations.fallback_hint_html', master_value: master_value) + else + hint = nil + end + + f.input attribute_name, + label: label, + hint: hint + end +end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6ce281b92930c686cad614753079eb4866c492a2..93c751ca2a45927be149b4bf4c93c157f958c5ee 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -64,9 +64,25 @@ module ApplicationHelper def default_images_formats_accepted Rails.application.config.default_images_formats.join(', ') end + + def default_audio_formats_accepted + Rails.application.config.default_audio_formats.join(', ') + end + + def file_hint(filesize: number_to_human_size(Rails.application.config.default_file_max_size), formats: []) + if formats.empty? + t('file_hint_without_formats', filesize: filesize) + else + t('file_hint_with_formats', filesize: filesize, formats: formats) + end + end - def default_images_formats_accepted_hint - t('default_images_hint', formats: default_images_formats_accepted) + def images_formats_accepted_hint(formats: default_images_formats_accepted) + file_hint(filesize: number_to_human_size(Rails.application.config.default_image_max_size), formats: formats) + end + + def audio_formats_accepted_hint(formats: default_audio_formats_accepted) + file_hint(formats: formats) end end diff --git a/app/models/ability/admin.rb b/app/models/ability/admin.rb index 3d711e79ad8f38fc92ab5c2080b1e91d5288eba5..dd196ad2129812b2a913060de667ae0c16c7b055 100644 --- a/app/models/ability/admin.rb +++ b/app/models/ability/admin.rb @@ -55,6 +55,7 @@ class Ability::Admin < Ability # Est-ce bien raisonnable de laisser supprimer un site ? # Le risque de faussse manip est grand. cannot :destroy, Communication::Website, university_id: @user.university_id + can :manage, Communication::Website::Localization, university_id: @user.university_id can :manage, Communication::Website::Agenda::Event, university_id: @user.university_id can :manage, Communication::Website::Agenda::Category, university_id: @user.university_id can :manage, Communication::Website::Post::Category, university_id: @user.university_id @@ -63,7 +64,7 @@ class Ability::Admin < Ability can :manage, Communication::Website::Page, university_id: @user.university_id can :manage, Communication::Website::Post, university_id: @user.university_id end - + def admin_communication_extranet can [:read, :update], Communication::Extranet, university_id: @user.university_id can :manage, Communication::Extranet::Connection, university_id: @user.university_id diff --git a/app/models/ability/website_manager.rb b/app/models/ability/website_manager.rb index e519439038c3334cae1443cd0da48be5adbf3377..d4700e289898af27e5e547f4f914b2f0773861c1 100644 --- a/app/models/ability/website_manager.rb +++ b/app/models/ability/website_manager.rb @@ -4,6 +4,7 @@ class Ability::WebsiteManager < Ability super manage_blocks can [:read, :analytics], Communication::Website, university_id: @user.university_id, id: managed_websites_ids + can :manage, Communication::Website::Localization, university_id: @user.university_id, communication_website_id: managed_websites_ids can :manage, Communication::Website::Agenda::Event, university_id: @user.university_id, communication_website_id: managed_websites_ids can :manage, Communication::Website::Agenda::Category, university_id: @user.university_id, communication_website_id: managed_websites_ids can :manage, Communication::Website::Post::Category, university_id: @user.university_id, communication_website_id: managed_websites_ids diff --git a/app/models/communication/block.rb b/app/models/communication/block.rb index aad6c670dff1b8f346a333bfb700680aead05fdd..8ce38b1417c5b81340ecc63d3dafd05bf925d3e0 100644 --- a/app/models/communication/block.rb +++ b/app/models/communication/block.rb @@ -39,8 +39,6 @@ class Communication::Block < ApplicationRecord include WithUniversity include Sanitizable - IMAGE_MAX_SIZE = 5.megabytes - FILE_MAX_SIZE = 100.megabytes BLOCK_COPY_COOKIE = 'osuny-content-editor-block-copy' belongs_to :about, polymorphic: true diff --git a/app/models/communication/website/localization.rb b/app/models/communication/website/localization.rb new file mode 100644 index 0000000000000000000000000000000000000000..a1d171c3bca1cc713ea10467fc5638dc4ab733ec --- /dev/null +++ b/app/models/communication/website/localization.rb @@ -0,0 +1,66 @@ +# == Schema Information +# +# Table name: communication_website_localizations +# +# id :uuid not null, primary key +# name :string +# social_email :string +# social_facebook :string +# social_github :string +# social_instagram :string +# social_linkedin :string +# social_mastodon :string +# social_peertube :string +# social_tiktok :string +# social_vimeo :string +# social_x :string +# social_youtube :string +# created_at :datetime not null +# updated_at :datetime not null +# communication_website_id :uuid not null, indexed +# language_id :uuid not null, indexed +# university_id :uuid not null, indexed +# +# Indexes +# +# idx_on_communication_website_id_ed4630e334 (communication_website_id) +# index_communication_website_localizations_on_language_id (language_id) +# index_communication_website_localizations_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_2b920b0a3a (language_id => languages.id) +# fk_rails_431797c26c (communication_website_id => communication_websites.id) +# fk_rails_fc42676b8b (university_id => universities.id) +# +class Communication::Website::Localization < ApplicationRecord + include AsDirectObject + include Sanitizable + include WithUniversity + + belongs_to :language + + validates :language_id, uniqueness: { scope: :communication_website_id } + + before_validation :set_university_id, on: :create + + # Localization is not directly exportable to git + # Whereas the languages config in the dependencies is exportable to git + def exportable_to_git? + false + end + + def dependencies + [website.config_default_languages] + end + + def computed_name + name.present? ? "#{name}" : website.to_s + end + + private + + def set_university_id + self.university_id = website.university_id + end +end diff --git a/app/models/communication/website/with_languages.rb b/app/models/communication/website/with_languages.rb index 258d4b6f9759a6aa5e9960163e6756901578e746..95591dcdf8c7cb8e6d880729ae74427e35f40e63 100644 --- a/app/models/communication/website/with_languages.rb +++ b/app/models/communication/website/with_languages.rb @@ -11,6 +11,9 @@ module Communication::Website::WithLanguages foreign_key: :communication_website_id, association_foreign_key: :language_id, after_remove: :flag_languages_change + has_many :localizations, + foreign_key: :communication_website_id, + dependent: :destroy validates :languages, length: { minimum: 1 } validate :languages_must_include_default_language @@ -27,6 +30,18 @@ module Communication::Website::WithLanguages languages.find_by(iso_code: iso_code) || default_language end + def localization_for(language) + return self if language.id == default_language_id + localization = localizations.find_by(language_id: language.id) + localization ||= self + localization + end + + def find_or_create_localization_for(language) + return self if language.id == default_language_id + localizations.find_or_create_by(language_id: language.id) + end + protected def languages_must_include_default_language diff --git a/app/models/university/person.rb b/app/models/university/person.rb index 0cf51c88138cb8240946eba5c78787ebc70e6d5c..6e26f2a2d58a7949d1adee796032733064b731da 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/services/icon.rb b/app/services/icon.rb index bca2f75f8140b3b5bfa1bf3b14516a5cb31b82ab..78d817d6252c783b839ce1bc56d58fc15a1ffa6f 100644 --- a/app/services/icon.rb +++ b/app/services/icon.rb @@ -5,6 +5,7 @@ class Icon COMMUNICATION_EXTRANET = 'fas fa-project-diagram' COMMUNICATION_WEBSITE = 'fas fa-sitemap' COMMUNICATION_WEBSITE_HOME = 'fas fa-home' + COMMUNICATION_WEBSITE_LOCALIZATIONS = 'fas fa-globe' COMMUNICATION_WEBSITE_POST = 'fas fa-newspaper' COMMUNICATION_WEBSITE_PAGE = 'fas fa-file' COMMUNICATION_WEBSITE_PAGES = 'fas fa-sitemap' @@ -61,7 +62,7 @@ class Icon OSUNY_USER = 'fas fa-user' USER = OSUNY_USER - + ADD = 'fas fa-plus' ARROW_RIGHT = 'fas fa-arrow-right' A11Y = 'fas fa-universal-access' diff --git a/app/views/admin/application/featured_image/_edit.html.erb b/app/views/admin/application/featured_image/_edit.html.erb index 2de1e713aa505c6130fc9080ddea5e94a5f5e593..6b741fcddfcf932eaea2f41c4ec4a666601e15c9 100644 --- a/app/views/admin/application/featured_image/_edit.html.erb +++ b/app/views/admin/application/featured_image/_edit.html.erb @@ -3,7 +3,7 @@ as: :single_deletable_file, direct_upload: true, label: false, - hint: default_images_formats_accepted_hint, + hint: images_formats_accepted_hint, input_html: { accept: default_images_formats_accepted }, preview: true, resize: true %> diff --git a/app/views/admin/communication/blocks/components/file/_edit.html.erb b/app/views/admin/communication/blocks/components/file/_edit.html.erb index 592c1f391cb482a5afc58c7cb6ea4276f3a2885e..49c925a46dff1418e5571c5f2f06d09df4b6e2f5 100644 --- a/app/views/admin/communication/blocks/components/file/_edit.html.erb +++ b/app/views/admin/communication/blocks/components/file/_edit.html.erb @@ -1,6 +1,8 @@ <% -label = t 'admin.communication.blocks.components.file.input.label' -remove = t 'admin.communication.blocks.components.file.input.remove' +label = t('admin.communication.blocks.components.file.input.label') +remove = t('admin.communication.blocks.components.file.input.remove') +hint = file_hint if hint.blank? +accept ||= '*' %> <div class="mb-3"> <div v-if="!<%= model %>.<%= property %>.id"> @@ -10,9 +12,9 @@ remove = t 'admin.communication.blocks.components.file.input.remove' </label> <input class="form-control" type="file" - accept="*" + accept="<%= accept %>" @change="onFileImageChange( $event, <%= model %>, '<%= property %>' )" - data-size-limit="<%= Communication::Block::FILE_MAX_SIZE %>" + data-size-limit="<%= Rails.application.config.default_file_max_size %>" :id="<%= dom_id.html_safe %>"> </div> <div v-if="<%= model %>.<%= property %>.id"> @@ -23,4 +25,7 @@ remove = t 'admin.communication.blocks.components.file.input.remove' <%= remove %> </a> </div> + <div v-if="<%= hint.present? %> && !<%= model %>.<%= property %>.id" class="form-text"> + <%= hint %> + </div> </div> diff --git a/app/views/admin/communication/blocks/components/image/_edit.html.erb b/app/views/admin/communication/blocks/components/image/_edit.html.erb index 3c8b741b7b8b50cd60c7ec8e36d4bcfac977e44c..18747b32ba041c8c165d9d572c517f3e6498bef6 100644 --- a/app/views/admin/communication/blocks/components/image/_edit.html.erb +++ b/app/views/admin/communication/blocks/components/image/_edit.html.erb @@ -1,7 +1,7 @@ <% label = t('admin.communication.blocks.components.image.input.label') remove = t('admin.communication.blocks.components.image.input.remove') -hint = default_images_formats_accepted_hint +hint = images_formats_accepted_hint %> <div class="mb-3"> <div v-if="!<%= model %>.<%= property %>.id"> @@ -13,7 +13,7 @@ hint = default_images_formats_accepted_hint type="file" accept="<%= default_images_formats_accepted %>" @change="onFileImageChange( $event, <%= model %>, '<%= property %>' )" - data-size-limit="<%= Communication::Block::IMAGE_MAX_SIZE %>" + data-size-limit="<%= Rails.application.config.default_image_max_size %>" :id="<%= dom_id.html_safe %>" > </div> diff --git a/app/views/admin/communication/blocks/edit.html.erb b/app/views/admin/communication/blocks/edit.html.erb index a5ad1b8dae8cc5e10ece1cba5834706566f83c05..b5c773ffd01b063a5c035d66653ace51e692c9b5 100644 --- a/app/views/admin/communication/blocks/edit.html.erb +++ b/app/views/admin/communication/blocks/edit.html.erb @@ -84,7 +84,7 @@ }, uploadFile(input, file, object, key) { var size = Math.round(file.size / 1024 / 1024), - sizeLimit = <%= Communication::Block::IMAGE_MAX_SIZE %>, + sizeLimit = <%= Rails.application.config.default_image_max_size %>, sizeLimitMo = 0, controller; if (input.hasAttribute('data-size-limit')) { diff --git a/app/views/admin/communication/blocks/templates/gallery/_edit.html.erb b/app/views/admin/communication/blocks/templates/gallery/_edit.html.erb index 50965764ce66360dbeabee572b4bfabea4f3bfaa..168a81616ab8b26971fb9321cefe075c1ed42ebb 100644 --- a/app/views/admin/communication/blocks/templates/gallery/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/gallery/_edit.html.erb @@ -8,13 +8,17 @@ <p><%= t('.send_multiple_images') %></p> -<input class="form-control mb-2" +<input class="form-control" type="file" - accept="image/*" + accept="<%= default_images_formats_accepted %>" @change="onMultipleFileImageChange( $event, 'image' )" - data-size-limit="<%= Communication::Block::IMAGE_MAX_SIZE %>" + data-size-limit="<%= Rails.application.config.default_image_max_size %>" multiple> +<div class="form-text mb-2"> + <%= images_formats_accepted_hint %> +</div> + <hr class="my-5"> <p><%= t('.move_images') %></p> diff --git a/app/views/admin/communication/blocks/templates/sound/_edit.html.erb b/app/views/admin/communication/blocks/templates/sound/_edit.html.erb index 68c966a68a16e7bdf6df5f04ee14de5a4cf0b37a..69a9938b9031d5c1f819f735d98f53c6a1128324 100644 --- a/app/views/admin/communication/blocks/templates/sound/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/sound/_edit.html.erb @@ -1,6 +1,8 @@ <div class="row pure__row--small"> <div class="col-md-6"> - <%= block_component_edit block, :file %> + <%= block_component_edit block, :file, + hint: audio_formats_accepted_hint, + accept: default_audio_formats_accepted %> <%= block_component_edit block, :title %> </div> <div class="col-md-6"> diff --git a/app/views/admin/communication/extranets/_form.html.erb b/app/views/admin/communication/extranets/_form.html.erb index 1a7ef3849956c8f00a3b34e763b7b114a54896e4..378f3b2904318c673839ae307bd4110e9de66e81 100644 --- a/app/views/admin/communication/extranets/_form.html.erb +++ b/app/views/admin/communication/extranets/_form.html.erb @@ -15,12 +15,13 @@ <%= osuny_panel t('look_feel') do %> <%= f.input :logo, as: :single_deletable_file, - hint: default_images_formats_accepted_hint, + hint: images_formats_accepted_hint, input_html: { accept: default_images_formats_accepted }, preview: 200, direct_upload: true %> <%= f.input :favicon, as: :single_deletable_file, + hint: images_formats_accepted_hint('.png') input_html: { accept: '.png' }, preview: 100, direct_upload: true %> diff --git a/app/views/admin/communication/websites/_form.html.erb b/app/views/admin/communication/websites/_form.html.erb index 269247bb7289813962632a2651ece908d8eb7951..9fcf63a8ef4b27181ddb126efd7887602fa337ff 100644 --- a/app/views/admin/communication/websites/_form.html.erb +++ b/app/views/admin/communication/websites/_form.html.erb @@ -48,7 +48,7 @@ <%= f.input :default_image, as: :single_deletable_file, direct_upload: true, - hint: default_images_formats_accepted_hint, + hint: images_formats_accepted_hint, input_html: { accept: default_images_formats_accepted }, preview: 300 %> </div> diff --git a/app/views/admin/communication/websites/_sidebar.html.erb b/app/views/admin/communication/websites/_sidebar.html.erb index ebd838a964c77d1885ece044b7f398625327ad18..43b53ce044975c590caadad0baa9c646bce69377 100644 --- a/app/views/admin/communication/websites/_sidebar.html.erb +++ b/app/views/admin/communication/websites/_sidebar.html.erb @@ -38,6 +38,13 @@ ability: can?(:read, Communication::Website::Post::Category) } + navigation << { + title: t('admin.communication.website.localizations.title'), + path: admin_communication_website_localization_path(website_id: @website), + icon: Icon::COMMUNICATION_WEBSITE_LOCALIZATIONS, + ability: can?(:read, Communication::Website::Localization) + } if @website.languages.many? + navigation << { title: t('communication.website.analytics'), path: analytics_admin_communication_website_path(@website.id, website_id: nil), diff --git a/app/views/admin/communication/websites/configs/default_languages/static.html.erb b/app/views/admin/communication/websites/configs/default_languages/static.html.erb index acddc20ec56dc6637870f81175ce95c335464808..ba583bb05cf51d6d6ac065e7719c4bed771ab65e 100644 --- a/app/views/admin/communication/websites/configs/default_languages/static.html.erb +++ b/app/views/admin/communication/websites/configs/default_languages/static.html.erb @@ -1,11 +1,39 @@ # DO NOT EDIT THIS FILE BY HAND - IT WILL BE OVERWRITTEN BY OSUNY -<% @website.languages.each do |language| %> +<% +@website.languages.each do |language| + localization = @website.localization_for(language) + title = localization.respond_to?(:computed_name) ? localization.computed_name + : localization.to_s +%> <%= language.iso_code %>: - title: <%= @website %><%# TODO I18n: Traduire le nom du site %> + title: <%= title %> contentDir: content/<%= language.iso_code %> languageCode: <%= language.iso_code %> languageName: <%= language.name %> + params: + social: + <%- + [ + :email, + :mastodon, + :peertube, + :x, + :github, + :linkedin, + :youtube, + :vimeo, + :instagram, + :facebook, + :tiktok + ].each do |social_element| + value = localization.public_send "social_#{social_element}" + value = @website.public_send "social_#{social_element}" if value.blank? + next if value.blank? + -%> + <%= social_element %>: >- + <%= value %> + <%- end -%> permalinks: <% Communication::Website::Permalink.config_in_website(@website, language).each do |key, value| %> <%= key %>: <%= value %> diff --git a/app/views/admin/communication/websites/localizations/show.html.erb b/app/views/admin/communication/websites/localizations/show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..7c438b159c0db4f6bc5a52fc29259ec3d4b91b44 --- /dev/null +++ b/app/views/admin/communication/websites/localizations/show.html.erb @@ -0,0 +1,43 @@ +<% content_for :title, "#{t('admin.communication.website.localizations.title')}" %> + +<% content_for :title_right do %> + <%= language_name(current_website_language.iso_code) %> +<% end %> + +<%= render 'admin/communication/websites/sidebar' do %> + <%= simple_form_for [:admin, @localization], as: :communication_website_localization, url: admin_communication_website_localization_path do |f| %> + <%= f.error_notification %> + <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %> + + <%= osuny_panel t('content') do %> + <%= localization_input f, :name, @website %> + <% end %> + + <%= osuny_panel Communication::Website.human_attribute_name('social') do %> + <div class="row"> + <div class="col-lg-6"> + <p><%= t('admin.communication.website.social.free') %></p> + <%= localization_input f, :social_email, @website %> + <%= localization_input f, :social_mastodon, @website %> + <%= localization_input f, :social_peertube, @website %> + </div> + <div class="col-lg-6"> + <p><%= t('admin.communication.website.social.private') %></p> + <%= localization_input f, :social_x, @website %> + <%= localization_input f, :social_github, @website %> + <%= localization_input f, :social_linkedin, @website %> + <%= localization_input f, :social_youtube, @website %> + <%= localization_input f, :social_vimeo, @website %> + <%= localization_input f, :social_instagram, @website %> + <%= localization_input f, :social_facebook, @website %> + <%= localization_input f, :social_tiktok, @website %> + </div> + </div> + <% end %> + + <% content_for :action_bar_right do %> + <%= submit f %> + <% end %> + <% end %> + +<% end %> diff --git a/app/views/admin/communication/websites/static.html.erb b/app/views/admin/communication/websites/static.html.erb index f1c6884b2ec02687da51b5998e3bedbca05070a6..8bc86ef5bd4417733ecf792d3239c40b34d7fdb1 100644 --- a/app/views/admin/communication/websites/static.html.erb +++ b/app/views/admin/communication/websites/static.html.erb @@ -18,10 +18,10 @@ social: :instagram, :facebook, :tiktok -].each do |network| - value = @website.send "social_#{network}" +].each do |social_element| + value = @website.send "social_#{social_element}" next if value.blank? %> - <%= network %>: >- + <%= social_element %>: >- <%= value %> <% end %> \ No newline at end of file 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 f7f169bed8a5e228140beb007c2107f57a088236..74085ceb6cf5a9eab311c45c862f1cd3e34da15b 100644 --- a/app/views/admin/university/people/static.html.erb +++ b/app/views/admin/university/people/static.html.erb @@ -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/application.rb b/config/application.rb index 8ff90a501a0f9a35ed7b0e20f3a04781fc848497..f017ec3b1526a722dd5298be6681a225b7e8afd2 100644 --- a/config/application.rb +++ b/config/application.rb @@ -70,7 +70,12 @@ module Osuny ] config.allowed_special_chars = '#?!,_@$%^&*+:;£µ-' + + # FILES + config.default_file_max_size = 100.megabytes + config.default_image_max_size = 5.megabytes config.default_images_formats = ['.jpg', '.jpeg', '.png', '.svg'] + config.default_audio_formats = ['.mp3'] config.generators do |g| g.orm :active_record, primary_key_type: :uuid diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index b3f7fcffadf131e23ac25c4e701d9796807c678e..66df046916b8b236089482edefafb8c59d86a2b0 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -280,6 +280,9 @@ en: editorial: label: Editorial description: Everything related to content + localizations: + fallback_hint_html: "Leave blank to use the default value: <i>%{master_value}</i>" + title: Internationalization technical: label: Technical description: Everything related to technical settings diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 92fb38d9a2d9056f3aff21b4b6318f3ede2c4d2b..ed541ea417e31cc3c4b1615f9d9b5772314798e9 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -280,6 +280,9 @@ fr: editorial: label: Éditorial description: Tout ce qui est lié au contenu + localizations: + fallback_hint_html: "Laisser vide pour utiliser la valeur par défaut : <i>%{master_value}</i>" + title: Internationalisation technical: label: Technique description: Tout ce qui est lié aux réglages techniques diff --git a/config/locales/en.yml b/config/locales/en.yml index db4b1d1259bdec95cc19c7259a66fdcf395fa9ba..27d5ac2c388891c253198ee2ea12edb245f898f4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -168,7 +168,6 @@ en: birthday: "%B %d" full: "%A %-d %B %Y" delete: Delete - default_images_hint: "5 MB max, %{formats}" devise: failure: invalid: "Invalid email or password." @@ -225,6 +224,8 @@ en: label: Credit hint: The credit must be present according to copyright or copyleft licenses. remove: Remove image + file_hint_with_formats: "%{formats} files only. %{filesize} max." + file_hint_without_formats: "%{filesize} max" filters: attributes: category: Filter by category diff --git a/config/locales/fr.yml b/config/locales/fr.yml index e0eb275899c49a5a6f12eba281d25393407e3387..47404bef1649e36a2385180d9e2d53c83dea8ec3 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -167,7 +167,6 @@ fr: formats: birthday: "%d %B" full: "%A %-d %B %Y" - default_images_hint: "5 Mo max, %{formats}" delete: Supprimer devise: failure: @@ -225,6 +224,8 @@ fr: label: Crédit hint: Le crédit photo doit être indiqué, dans le respect du droit d'auteur. remove: Supprimer l'image + file_hint_with_formats: "Fichiers %{formats} uniquement. %{filesize} max." + file_hint_without_formats: "%{filesize} max." filters: attributes: category: Filtrer par catégorie 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/config/routes/admin/communication.rb b/config/routes/admin/communication.rb index bb24319d55a16786f58e26fbecde068dc28ae24e..303289d08b65fb3442e4cca0d5d3345bdf993fae 100644 --- a/config/routes/admin/communication.rb +++ b/config/routes/admin/communication.rb @@ -41,7 +41,7 @@ namespace :communication do get :children get :static end - end + end resources :authors, controller: '/admin/communication/websites/posts/authors', path: '/:lang/authors', only: [:index, :show] end resources :posts, controller: 'websites/posts', path: '/:lang/posts' do @@ -87,6 +87,7 @@ namespace :communication do end end end + resource :localization, controller: 'websites/localizations', path: '/:lang/localization', only: [:show, :update] end scope "/contents/:about_type/:about_id", as: :contents, controller: 'contents' do get :write diff --git a/db/migrate/20240122132556_create_communication_website_localizations.rb b/db/migrate/20240122132556_create_communication_website_localizations.rb new file mode 100644 index 0000000000000000000000000000000000000000..f079fba2470b8bb132514254c7ab8e73039508c8 --- /dev/null +++ b/db/migrate/20240122132556_create_communication_website_localizations.rb @@ -0,0 +1,23 @@ +class CreateCommunicationWebsiteLocalizations < ActiveRecord::Migration[7.1] + def change + create_table :communication_website_localizations, id: :uuid do |t| + t.references :communication_website, null: false, foreign_key: true, type: :uuid + t.references :language, null: false, foreign_key: true, type: :uuid + t.references :university, null: false, foreign_key: true, type: :uuid + t.string :name + t.string :email + t.string :mastodon + t.string :peertube + t.string :x + t.string :github + t.string :linkedin + t.string :youtube + t.string :vimeo + t.string :instagram + t.string :facebook + t.string :tiktok + + t.timestamps + end + end +end diff --git a/db/migrate/20240122144217_rename_social_attributes_in_localizations.rb b/db/migrate/20240122144217_rename_social_attributes_in_localizations.rb new file mode 100644 index 0000000000000000000000000000000000000000..e9178cd76ac5e0418ca7f50ba3dfa9f93a690168 --- /dev/null +++ b/db/migrate/20240122144217_rename_social_attributes_in_localizations.rb @@ -0,0 +1,15 @@ +class RenameSocialAttributesInLocalizations < ActiveRecord::Migration[7.1] + def change + rename_column :communication_website_localizations, :email, :social_email + rename_column :communication_website_localizations, :mastodon, :social_mastodon + rename_column :communication_website_localizations, :peertube, :social_peertube + rename_column :communication_website_localizations, :x, :social_x + rename_column :communication_website_localizations, :github, :social_github + rename_column :communication_website_localizations, :linkedin, :social_linkedin + rename_column :communication_website_localizations, :youtube, :social_youtube + rename_column :communication_website_localizations, :vimeo, :social_vimeo + rename_column :communication_website_localizations, :instagram, :social_instagram + rename_column :communication_website_localizations, :facebook, :social_facebook + rename_column :communication_website_localizations, :tiktok, :social_tiktok + end +end 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 d002f009cd10229a98f3a5d6de78146e312aae26..abd8aece95f9e7eb6959219640e23a6625d52f70 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_26_112021) 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" @@ -358,6 +358,29 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_26_112021) do t.index ["website_id"], name: "index_communication_website_git_files_on_website_id" end + create_table "communication_website_localizations", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.uuid "communication_website_id", null: false + t.uuid "language_id", null: false + t.uuid "university_id", null: false + t.string "name" + t.string "social_email" + t.string "social_mastodon" + t.string "social_peertube" + t.string "social_x" + t.string "social_github" + t.string "social_linkedin" + t.string "social_youtube" + t.string "social_vimeo" + t.string "social_instagram" + t.string "social_facebook" + t.string "social_tiktok" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["communication_website_id"], name: "idx_on_communication_website_id_ed4630e334" + t.index ["language_id"], name: "index_communication_website_localizations_on_language_id" + t.index ["university_id"], name: "index_communication_website_localizations_on_university_id" + end + create_table "communication_website_menu_items", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false t.uuid "website_id", null: false @@ -1046,6 +1069,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_26_112021) 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" @@ -1204,6 +1228,9 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_26_112021) do add_foreign_key "communication_website_connections", "communication_websites", column: "website_id" add_foreign_key "communication_website_connections", "universities" add_foreign_key "communication_website_git_files", "communication_websites", column: "website_id" + add_foreign_key "communication_website_localizations", "communication_websites" + add_foreign_key "communication_website_localizations", "languages" + add_foreign_key "communication_website_localizations", "universities" add_foreign_key "communication_website_menu_items", "communication_website_menu_items", column: "parent_id" add_foreign_key "communication_website_menu_items", "communication_website_menus", column: "menu_id" add_foreign_key "communication_website_menu_items", "communication_websites", column: "website_id" diff --git a/test/fixtures/communication/website/localizations.yml b/test/fixtures/communication/website/localizations.yml new file mode 100644 index 0000000000000000000000000000000000000000..3c813952b1e1b691d851aa2caeee90ba3498e635 --- /dev/null +++ b/test/fixtures/communication/website/localizations.yml @@ -0,0 +1,7 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +website_with_gitlab_en: + university: default_university + website: website_with_gitlab + language: en + name: Site with gitlab english