diff --git a/app/models/communication/block/template/embed.rb b/app/models/communication/block/template/embed.rb index c7075906320f1ca72df2262cc8759b3ed5052362..69df3167241a8a68d6956848afe2006b281a8ea0 100644 --- a/app/models/communication/block/template/embed.rb +++ b/app/models/communication/block/template/embed.rb @@ -1,4 +1,12 @@ class Communication::Block::Template::Embed < Communication::Block::Template def build_git_dependencies end + + def code + "#{data['code']}" + end + + def transcription + "#{data['transcription']}" + end end diff --git a/app/models/communication/block/template/file.rb b/app/models/communication/block/template/file.rb index 0c27e046a361be35560d44cff26f737e611d2ff3..8323b3d853c466db22d20843fb24aba231555a24 100644 --- a/app/models/communication/block/template/file.rb +++ b/app/models/communication/block/template/file.rb @@ -1,4 +1,20 @@ class Communication::Block::Template::File < Communication::Block::Template def build_git_dependencies + add_dependency active_storage_blobs + end + + def files + @files ||= elements.map { |element| + file(element) + }.compact + end + + protected + + def file(element) + { + title: element['title'], + blob: find_blob(element, 'file') + }.to_dot end end diff --git a/app/models/communication/block/template/video.rb b/app/models/communication/block/template/video.rb index 1f3d5d7dd746493ac8cfc53b9d1495ab174fb8ea..1441b9d6d84ae4f1f3c22bde1d6825b5de966b37 100644 --- a/app/models/communication/block/template/video.rb +++ b/app/models/communication/block/template/video.rb @@ -1,4 +1,12 @@ class Communication::Block::Template::Video < Communication::Block::Template def build_git_dependencies end + + def url + "#{data['url']}" + end + + def transcription + "#{data['transcription']}" + end end diff --git a/app/views/admin/communication/blocks/templates/embed/_edit.html.erb b/app/views/admin/communication/blocks/templates/embed/_edit.html.erb index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..980ce3623f822ef230247fdb8b2322a59266997b 100644 --- a/app/views/admin/communication/blocks/templates/embed/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/embed/_edit.html.erb @@ -0,0 +1,29 @@ +<div class="row mb-4"> + <div class="col-md-6"> + <label class="form-label" + for="text"> + <%= t '.code_label' %> + </label> + <div class="mb-3"> + <textarea id="text" + rows="10" + class="form-control" + v-model="data.code" + data-summernote-config="mini-list" + placeholder="<%= t '.code_placeholder' %>"></textarea> + </div> + </div> + <div class="col-md-6"> + <label class="form-label" + for="transcription"> + <%= t '.transcription_label' %> + </label> + <div class="mb-3"> + <textarea id="transcription" + rows="10" + class="form-control" + v-model="data.transcription" + placeholder="<%= t '.transcription_placeholder' %>"></textarea> + </div> + </div> +</div> diff --git a/app/views/admin/communication/blocks/templates/embed/_preview.html.erb b/app/views/admin/communication/blocks/templates/embed/_preview.html.erb index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..560be01fc48e179e78aa9eadbadc9f198988b300 100644 --- a/app/views/admin/communication/blocks/templates/embed/_preview.html.erb +++ b/app/views/admin/communication/blocks/templates/embed/_preview.html.erb @@ -0,0 +1,2 @@ +<%= @block.template.code.html_safe %> +<p><%= @block.template.transcription %></p> \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/embed/_static.html.erb b/app/views/admin/communication/blocks/templates/embed/_static.html.erb index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a5277bb4d8a4f2d3536f72c840fa2d0ffee7434d 100644 --- a/app/views/admin/communication/blocks/templates/embed/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/embed/_static.html.erb @@ -0,0 +1,4 @@ + code: >- + <%= prepare_html_for_static block.template.code, about.university %> + transcription: >- + <%= prepare_text_for_static block.template.transcription %> diff --git a/app/views/admin/communication/blocks/templates/files/_edit.html.erb b/app/views/admin/communication/blocks/templates/files/_edit.html.erb index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..69cf7d16c80f9e3d970203dfee69a9d88424ea53 100644 --- a/app/views/admin/communication/blocks/templates/files/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/files/_edit.html.erb @@ -0,0 +1,55 @@ +<a class="<%= button_classes('mb-4') %>" + v-on:click="data.elements.push({title: '', file: {}})"> + <%= t '.add_file' %> +</a> + +<draggable :list="data.elements" handle=".dragHandle" class="row"> + <div v-for="(element, index) in data.elements" class="col-md-4"> + <div class="card"> + <div class="card-header border-bottom"> + <a class="btn ps-0 pt-0 dragHandle"> + <i class="fa fa-bars handle"></i> + </a> + <div class="float-end"> + <a class="btn btn-sm btn-danger" + v-on:click="data.elements.splice(data.elements.indexOf(element), 1)" + title="<%= t '.remove_file' %>"> + <i class="fas fa-times"></i> + </a> + </div> + </div> + <div class="card-body"> + <div class="d-flex"> + <div class="flex-fill"> + <label class="form-label" + :for="'element-' + index + '-title'"><%= t '.title_label' %></label> + <input class="form-control mb-3" + v-model="element.title" + placeholder="<%= t '.title_placeholder' %>" + type="text" + :id="'element-' + index + '-title'" /> + + <label class="form-label" + :for="'element-' + index + '-file'"> + <%= t '.file_label' %> + </label> + <div v-if="element.file.id"> + <p><b>{{ element.file.filename }}</b></p> + <a class="btn btn-sm btn-danger mt-2" + v-on:click="element.file={}"> + <i class="fas fa-times"></i> + <%= t '.remove_file' %> + </a> + </div> + <div v-if="!element.file.id"> + <input class="form-control mb-4" + type="file" + @change="onFileImageChange( $event, element, 'file' )" + :id="'element-' + index + '-file'"> + </div> + </div> + </div> + </div> + </div> + </div> +</draggable> diff --git a/app/views/admin/communication/blocks/templates/files/_preview.html.erb b/app/views/admin/communication/blocks/templates/files/_preview.html.erb index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..48e6bad1ff4411e5e3f139abddedd493eaa25213 100644 --- a/app/views/admin/communication/blocks/templates/files/_preview.html.erb +++ b/app/views/admin/communication/blocks/templates/files/_preview.html.erb @@ -0,0 +1,19 @@ +<ul> + <% @block.template.files.each do |file| %> + <% file.title ||= file.blob.filename if file.blob %> + <% if file.title + title = file.title + elsif file.blob + title = file.blob.filename + else + title = '' + end %> + <li> + <% if file.blob %> + <a href="<%= file.blob.url %>" download><%= title %> <small>(<%= file.blob.filename %>)</small></a> + <% else %> + <%= title %> <small>(<%= t 'admin.communication.blocks.components.file.not_linked' %>)</small> + <% end %> + </li> + <% end %> +</ul> \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/files/_static.html.erb b/app/views/admin/communication/blocks/templates/files/_static.html.erb index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..cbfb04c22cc65b327b433099652b03f2e2f74168 100644 --- a/app/views/admin/communication/blocks/templates/files/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/files/_static.html.erb @@ -0,0 +1,5 @@ + files: +<% block.template.files.each do |file| %> + - title: "<%= file.title %>" + id: "<%= file.blob.id if file.blob %>" +<% end %> diff --git a/app/views/admin/communication/blocks/templates/video/_edit.html.erb b/app/views/admin/communication/blocks/templates/video/_edit.html.erb index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6860580c3e6b96e271a3b62c68c280563603f6e3 100644 --- a/app/views/admin/communication/blocks/templates/video/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/video/_edit.html.erb @@ -0,0 +1,28 @@ +<div class="row mb-4"> + <div class="col-md-6"> + <label class="form-label" + for="url"> + <%= t '.url_label' %> + </label> + <div class="mb-3"> + <input class="form-control mb-3" + v-model="data.url" + placeholder="<%= t '.url_placeholder' %>" + type="text" + id="url" /> + </div> + </div> + <div class="col-md-6"> + <label class="form-label" + for="text"> + <%= t '.transcription_label' %> + </label> + <div class="mb-3"> + <textarea id="text" + rows="10" + class="form-control" + v-model="data.transcription" + placeholder="<%= t '.transcription_placeholder' %>"></textarea> + </div> + </div> +</div> diff --git a/app/views/admin/communication/blocks/templates/video/_preview.html.erb b/app/views/admin/communication/blocks/templates/video/_preview.html.erb index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..5bbacca7abf25579a7a4dd0c052bd59c6c4634c1 100644 --- a/app/views/admin/communication/blocks/templates/video/_preview.html.erb +++ b/app/views/admin/communication/blocks/templates/video/_preview.html.erb @@ -0,0 +1,2 @@ +<pre><%= @block.template.url %></pre> +<p><%= @block.template.transcription %></p> \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/video/_static.html.erb b/app/views/admin/communication/blocks/templates/video/_static.html.erb index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1828b483312eb8f5f222569532468417b4649e9b 100644 --- a/app/views/admin/communication/blocks/templates/video/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/video/_static.html.erb @@ -0,0 +1,4 @@ + url: >- + <%= prepare_text_for_static block.template.url %> + transcription: >- + <%= prepare_text_for_static block.template.transcription %> diff --git a/app/views/admin/communication/websites/pages/_form.html.erb b/app/views/admin/communication/websites/pages/_form.html.erb index d334eca970ce2a42d5bb7d7a00a8b345ad720640..f2c2e2064d48a4c30dd882dee5e062f3024306ca 100644 --- a/app/views/admin/communication/websites/pages/_form.html.erb +++ b/app/views/admin/communication/websites/pages/_form.html.erb @@ -12,11 +12,7 @@ <%= f.input :title %> <%= f.input :breadcrumb_title %> <%= f.input :description_short, input_html: { value: page.description_short&.gsub('&', '&') } %> - <%= f.input :header_text, - as: :summernote, - input_html: { - data: { 'summernote-config' => 'mini' } - } %> + <%= f.input :header_text, as: :string %> <%= f.input :text, as: :summernote if page.text&.to_plain_text.present? %> <%= f.association :related_category, collection: collection_tree(@website.categories), diff --git a/app/views/admin/communication/websites/pages/static.html.erb b/app/views/admin/communication/websites/pages/static.html.erb index c3f1d35eea17b74b566300a0332448da22fe2097..710adbec98809df944bb1167c0338bbfc653c45f 100644 --- a/app/views/admin/communication/websites/pages/static.html.erb +++ b/app/views/admin/communication/websites/pages/static.html.erb @@ -19,8 +19,8 @@ description: > <%= prepare_text_for_static @about.description %> description_short: > <%= prepare_text_for_static @about.description_short %> -header_text: > - <%= prepare_html_for_static @about.header_text, @website.university %> +header_text: >- + <%= @about.header_text %> legacy_text: > <%= prepare_html_for_static @about.text, @about.university %> <%= render 'admin/communication/blocks/static', about: @about %> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index d7c097cf924abdfe39b50ee4ce172f8cc20b9a10..03e75b9218918a6e371f90e67593e5f78ad7bb54 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -137,13 +137,9 @@ en: credit: label: Credit placeholder: Enter credit + file: + not_linked: Pas de fichier lié template_kinds: - chapter: - edit: - notes_label: Notes - notes_placeholder: Enter notes - text_label: Text - text_placeholder: Enter text call_to_action: edit: button_1: Primary button @@ -162,6 +158,33 @@ en: text_placeholder: Enter text here url_label: Link url_placeholder: Enter the URL with "https://..." + chapter: + edit: + notes_label: Notes + notes_placeholder: Enter notes + text_label: Text + text_placeholder: Enter text + definitions: + edit: + add_definition: Add definition + remove_definition: Delete definition + title_label: Title + title_placeholder: Enter title here + text_label: Text + text_placeholder: Enter text here + embed: + edit: + code_label: Code + code_placeholder: Enter code + transcription_label: Text transcript + transcription_placeholder: Enter text transcript + files: + edit: + add_file: Add a file + file_label: File + title_label: Title + title_placeholder: Enter title here + remove_file: Remove a file gallery: edit: add_image: Add image @@ -215,14 +238,12 @@ en: title_placeholder: Enter title here text_label: Text text_placeholder: Enter text here - definitions: + video: edit: - add_definition: Add definition - remove_definition: Delete definition - title_label: Title - title_placeholder: Enter title here - text_label: Text - text_placeholder: Enter text here + url_label: Video url + url_placeholder: Enter video's url + transcription_label: Text transcript + transcription_placeholder: Enter text transcript website: pages: delete_special_page_notice: Can't delete this page diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 821e146528e359c391bd076db42019f3cc37d669..a406c0e00ede63134167eae90abb283944c11348 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -137,13 +137,55 @@ fr: credit: label: Crédit placeholder: Entrer le crédit + file: + not_linked: Pas de fichier lié + templates: + call_to_action: + edit: + button_1: Bouton principal + button_2: Bouton secondaire + button_label: Texte + button_placeholder: Entrer le texte du bouton ici + buttons: Boutons d'action + image_alt_label: Texte alternatif + image_alt_placeholder: Entrer la description textuelle + image_credit_label: Crédit + image_credit_placeholder: Entrer le crédit de l'image ici + image_label: Fichier + image_title: Image + remove_image: Supprimer l'image + text_label: Texte + text_placeholder: Entrer le texte ici + url_label: Lien + url_placeholder: Entrer le lien ici avec "https://..." chapter: edit: notes_label: Notes notes_placeholder: Entrer les notes text_label: Texte text_placeholder: Entrer le texte + definitions: + edit: + add_definition: Ajouter une définition + remove_definition: Supprimer la définition + title_label: Titre + title_placeholder: Entrer le titre de la définition + text_label: Texte + text_placeholder: Entrer la description de la définition + embed: + edit: + code_label: Code du bloc d'intégration HTML + code_placeholder: Entrez ici le code + transcription_label: Transcription textuelle du contenu + transcription_placeholder: Entrez ici la transcription + files: + edit: + add_file: Ajouter un fichier + file_label: Fichier + title_label: Titre + title_placeholder: Entrer le titre du fichier + remove_file: Supprimer le fichier gallery: edit: add_image: Ajouter une image @@ -199,32 +241,12 @@ fr: title_placeholder: Entrer le titre de l'événement text_label: Texte text_placeholder: Entrer le texte de l'événement - definitions: - edit: - add_definition: Ajouter une définition - remove_definition: Supprimer la définition - title_label: Titre - title_placeholder: Entrer le titre de la définition - text_label: Texte - text_placeholder: Entrer la description de la définition - call_to_action: + video: edit: - button_1: Bouton principal - button_2: Bouton secondaire - button_label: Texte - button_placeholder: Entrer le texte du bouton ici - buttons: Boutons d'action - image_alt_label: Texte alternatif - image_alt_placeholder: Entrer la description textuelle - image_credit_label: Crédit - image_credit_placeholder: Entrer le crédit de l'image ici - image_label: Fichier - image_title: Image - remove_image: Supprimer l'image - text_label: Texte - text_placeholder: Entrer le texte ici - url_label: Lien - url_placeholder: Entrer le lien ici avec "https://..." + url_label: Url de la vidéo + url_placeholder: Entrer l'url de la vidéo + transcription_label: Transcription textuelle du contenu + transcription_placeholder: Entrez ici la transcription website: pages: delete_special_page_notice: Impossible de supprimer cette page diff --git a/lib/tasks/app.rake b/lib/tasks/app.rake index c83caba11e229f3bca805868771096e0cbde6865..d8cb814a9e5b3bece58a93182314ad199923f683 100644 --- a/lib/tasks/app.rake +++ b/lib/tasks/app.rake @@ -12,6 +12,11 @@ namespace :app do person.is_author = person.communication_website_posts.any? person.save end + + Communication::Website::Page.where("header_text ILIKE ?", "%<p>%").find_each { |page| + clean_header_text = ActionController::Base.helpers.strip_tags(page.header_text) + page.update(header_text: clean_header_text) + } end namespace :websites do