diff --git a/app/assets/stylesheets/extranet.sass b/app/assets/stylesheets/extranet.sass index 4d696cd0e819e943695caf8ddc58b633c692dc65..7beab43bb867d71afd0fe6afdbf4e304fc0976d3 100644 --- a/app/assets/stylesheets/extranet.sass +++ b/app/assets/stylesheets/extranet.sass @@ -16,3 +16,4 @@ // Default @import 'extranet/layout/*' @import 'extranet/pages/*' + diff --git a/app/models/communication/extranet/document.rb b/app/models/communication/extranet/document.rb index 081f39cbb290caf496bc1cac72d3051b878208c4..30a353f9f0e1bc72338072f57042b31978c816b4 100644 --- a/app/models/communication/extranet/document.rb +++ b/app/models/communication/extranet/document.rb @@ -8,18 +8,24 @@ # published_at :datetime # created_at :datetime not null # updated_at :datetime not null +# category_id :uuid indexed # extranet_id :uuid not null, indexed +# kind_id :uuid indexed # university_id :uuid not null, indexed # # Indexes # +# extranet_document_categories (category_id) # index_communication_extranet_documents_on_extranet_id (extranet_id) # index_communication_extranet_documents_on_university_id (university_id) +# index_extranet_document_kinds (kind_id) # # Foreign Keys # # fk_rails_1272fd263c (extranet_id => communication_extranets.id) +# fk_rails_51f7db2f66 (kind_id => communication_extranet_document_kinds.id) # fk_rails_af877a8c0c (university_id => universities.id) +# fk_rails_eb351dc444 (category_id => communication_extranet_document_categories.id) # class Communication::Extranet::Document < ApplicationRecord include Sanitizable diff --git a/app/views/admin/communication/blocks/components/code/_preview.html.erb b/app/views/admin/communication/blocks/components/code/_preview.html.erb index b8c9c330c537f5928d296e26c0093e1da1d3eca6..c3042cff636692d6a07ac30c4e82ea8b28cba5a0 100644 --- a/app/views/admin/communication/blocks/components/code/_preview.html.erb +++ b/app/views/admin/communication/blocks/components/code/_preview.html.erb @@ -1 +1 @@ -<%= simple_format value %> +<%= value.html_safe %> diff --git a/app/views/admin/communication/blocks/components/image/_preview.html.erb b/app/views/admin/communication/blocks/components/image/_preview.html.erb index b6b9532baeb829af5314bf474d58e3b9d7231ead..066284dacd6ac732d54134f96f4aec796f0584fe 100644 --- a/app/views/admin/communication/blocks/components/image/_preview.html.erb +++ b/app/views/admin/communication/blocks/components/image/_preview.html.erb @@ -4,7 +4,7 @@ return unless blob %> <figure> - <%= kamifusen_tag blob, width: 600, class: 'img-fluid mb-1', alt: component.template.alt %> + <%= kamifusen_tag blob, width: 600, class: 'img-fluid mb-1', alt: component.template.try(:alt).blank? ? "" : component.template.alt %> <figcaption> <%= sanitize component.template.credit if component.template.try(:credit).present? %> </figcaption> diff --git a/app/views/admin/communication/blocks/templates/call_to_action/_preview.html.erb b/app/views/admin/communication/blocks/templates/call_to_action/_preview.html.erb index ae6f329affaf5a9a0e7150f7f70d05f4c046dfc3..b9f76636bd6aed01b82e5e86b52f1d293fb59e0d 100644 --- a/app/views/admin/communication/blocks/templates/call_to_action/_preview.html.erb +++ b/app/views/admin/communication/blocks/templates/call_to_action/_preview.html.erb @@ -38,7 +38,7 @@ $image_class = "call_to_action--with" + (@block.template.image.empty? ? "out" : </div> <% end %> </div> - <% component = @block.template.public_send "image_component" %> + <% component = @block.template.image_component %> <% if component.blob %> <%= kamifusen_tag component.blob, width: 600, class: 'img-fluid mb-1', alt: @block.template.alt %> <% end %> 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 2e2464610e92f12ad1ac0e0af7f5aff8b2d85780..d6bc1a1e6c77cd1d6c901c0085b98a7adfcdb5c0 100644 --- a/app/views/admin/communication/blocks/templates/embed/_preview.html.erb +++ b/app/views/admin/communication/blocks/templates/embed/_preview.html.erb @@ -1,14 +1,14 @@ <% - $class = "block block-embed" - if @block.title - $class += " block-with-title" + class_name = "block block-embed" + unless @block.title.blank? + class_name += " block-with-title" end %> -<section class="<%= $class %>"> +<section class="<%= class_name %>"> <div class="container"> <div class="block-content"> - <% if @block.title %> + <% unless @block.title.blank? %> <div class="top"> <h2><%= @block.title %></h2> </div> @@ -16,14 +16,16 @@ <%= block_component_preview :code %> - <div class="transcription"> - <details> - <summary>Transcription</summary> - <p> - <%= block_component_preview :transcription %> - </p> - </details> - </div> + <% unless @block.template.transcription.blank? %> + <div class="transcription"> + <details> + <summary>Transcription</summary> + <p> + <%= block_component_preview :transcription %> + </p> + </details> + </div> + <% end %> </div> </div> </section> diff --git a/app/views/admin/communication/blocks/templates/gallery/_preview.html.erb b/app/views/admin/communication/blocks/templates/gallery/_preview.html.erb index fadc3f4aa401aa1426ebf55e62b5c492fb4873eb..1930887a150cc86d8c272c88c9b40751c2b36762 100644 --- a/app/views/admin/communication/blocks/templates/gallery/_preview.html.erb +++ b/app/views/admin/communication/blocks/templates/gallery/_preview.html.erb @@ -1,6 +1,6 @@ <% $class = "block block-gallery" -unless @block.title.blank? +if @block.title.present? $class += " block-with-title" end @@ -10,20 +10,19 @@ $class += " block-gallery--" + @block.template.layout <section class="<%= $class %>"> <div class="container"> <div class="block-content"> - <div class="top"> - <% unless @block.title.blank? && @block.template.description.blank? %> - <div class="top"> - <% unless @block.title.blank? %> - <h2><%= @block.title %></h2> - <% end %> - <% unless @block.template.description.blank? %> - <div class="description"> - <p><%= block_component_preview :description %></p> - </div> - <% end %> - </div> - <% end %> - </div> + <% if @block.title.present? || @block.template.description.present? %> + <div class="top"> + <% if @block.title.present? %> + <h2><%= @block.title %></h2> + <% end %> + <% if @block.template.description.present? %> + <div class="description"> + <p><%= block_component_preview :description %></p> + </div> + <% end %> + </div> + <% end %> + <% if @block.template.layout === "carousel" %> <% if !@block.template.elements.one? %> <div class="splide" role="group" data-splide='{"arrows":true,"pagination":false,"autoWidth":true,"autoplay":false}'> diff --git a/app/views/admin/communication/blocks/templates/testimonials/_preview.html.erb b/app/views/admin/communication/blocks/templates/testimonials/_preview.html.erb index b8c2e89d9a2ccffd7558b8ee55403cd528deb6bd..8bc4c337f1455b78f9a78c212ba58695ef909f7d 100644 --- a/app/views/admin/communication/blocks/templates/testimonials/_preview.html.erb +++ b/app/views/admin/communication/blocks/templates/testimonials/_preview.html.erb @@ -1,14 +1,14 @@ <% - $class = "block block-testimonials" + class_name = "block block-testimonials" unless @block.title.blank? - $class += " block-with-title" + class_name += " block-with-title" end if !@block.template.elements.one? - $class += " with-carousel" + class_name += " with-carousel" end %> -<section class="<%= $class %>"> +<section class="<%= class_name %>"> <div class="container"> <div class="block-content"> <div class="testimonials"> @@ -30,22 +30,25 @@ <% end %> <% @block.template.elements.each do |element| %> + <% element_blob = element.photo_component.blob %> <figure <% if !@block.template.elements.one? %> class="splide__slide" <% end %>> <blockquote> <p><%= block_component_preview :text, template: element %></p> </blockquote> <figcaption> - <% if element.photo %> + <% if element_blob.present? %> <div class="avatar"> - <%#= block_component_preview :photo, template: element %> + <%= kamifusen_tag element_blob, width: 600, class: 'img-fluid mb-1', alt: element.author %> </div> <% end %> - <% if element.author %> - <span class="signature"><%= block_component_preview :author, template: element %></span> - <% end %> - <% if element.job %> - <span class="meta"><%= block_component_preview :job, template: element %></span> - <% end %> + <p> + <% if element.author %> + <span class="signature"><%= block_component_preview :author, template: element %></span> + <% end %> + <% if element.job %> + <span class="meta"><%= block_component_preview :job, template: element %></span> + <% end %> + </p> </figcaption> </figure> <% end %> diff --git a/app/views/admin/communication/blocks/templates/timeline/_preview.html.erb b/app/views/admin/communication/blocks/templates/timeline/_preview.html.erb index d52b51e2b9e76058476b0742e94d2239aa8d34ee..ff8f7921a6131a2a9963d9a012c45f47fe15284b 100644 --- a/app/views/admin/communication/blocks/templates/timeline/_preview.html.erb +++ b/app/views/admin/communication/blocks/templates/timeline/_preview.html.erb @@ -20,8 +20,10 @@ <article class="event"> <h3 class="event-title"> <%= block_component_preview :title, template: element %> - <h3> - <p><%= block_component_preview :text, template: element %></p> + </h3> + + <%# TODO: gérer les sauts de ligne %> + <p><%= element.text %></p> </article> <% end %> </div> @@ -37,7 +39,7 @@ <li class="event"> <p class="title"><%= block_component_preview :title, template: element %><p> <div class="line"></div> - <p class="description"><%= block_component_preview :text, template: element %></p> + <div class="description"><%= block_component_preview :text, template: element %></div> </li> <% end %> </ol> 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 1dc6895c1543ca1fdabff59fcb57d0c5db5cdcd3..62a19434c45d78bf9c6684524b477f0e404091a2 100644 --- a/app/views/admin/communication/blocks/templates/video/_preview.html.erb +++ b/app/views/admin/communication/blocks/templates/video/_preview.html.erb @@ -20,13 +20,13 @@ end <% if @block.template.video_title %> <p><%= block_component_preview :video_title %></p> <% end %> - <% if @block.template.transcription %> - <div class="transcription"> - <details> - <summary><%= t 'accessibility.transcription' %></summary> - <p><%= block_component_preview :transcription %></p> - </details> - </div> + <% unless @block.template.transcription.blank? %> + <div class="transcription"> + <details> + <summary><%= t 'accessibility.transcription' %></summary> + <p><%= block_component_preview :transcription %></p> + </details> + </div> <% end %> </div> </div> diff --git a/app/views/extranet/application/_head.html.erb b/app/views/extranet/application/_head.html.erb index 8ae368ff3c95f76af201c0d748060ae4767df3ad..10b00f355b3fd1cf6aef6aa95a00a0b8a7e9584d 100644 --- a/app/views/extranet/application/_head.html.erb +++ b/app/views/extranet/application/_head.html.erb @@ -5,7 +5,7 @@ <%= csp_meta_tag %> <%= stylesheet_link_tag 'extranet', media: 'all' %> <link rel="stylesheet" href="<%= style_path(format: :css) %>" media="all"> -<%= javascript_include_tag 'extranet' %> +<link rel="stylesheet" href="https://example.osuny.org/assets/css/extranet.min.css" media="all"> <% if current_extranet.favicon.attached? %> <%= favicon_link_tag url_for(current_extranet.favicon.variant(:thumb)) %> <% else %> diff --git a/app/views/extranet/layouts/application.html.erb b/app/views/extranet/layouts/application.html.erb index b72cd0a1427c0965e103acf0702e982701dead7d..8b20a64470b47db0a214116ba3c18c4e12a065a1 100644 --- a/app/views/extranet/layouts/application.html.erb +++ b/app/views/extranet/layouts/application.html.erb @@ -3,7 +3,7 @@ <head> <%= render 'extranet/application/head' %> </head> - <body class="extranet <%= body_classes %>"> + <body class="extranet <%= body_classes %> full-width"> <%= render 'application/notice' %> <%= render 'extranet/application/nav' %> <%= render 'extranet/application/header' %> @@ -13,5 +13,7 @@ <%= render 'extranet/application/footer' %> <%= render 'extranet/gdpr/cookie_consent' %> <%= render 'bugsnag' %> + <%= javascript_include_tag 'extranet' %> + <script src="https://example.osuny.org/js/extranet.js"></script> </body> </html> diff --git a/app/views/extranet/posts/posts/_list.html.erb b/app/views/extranet/posts/posts/_list.html.erb index 1582e0fa981b8f20940a17e40f966ec239d80a08..6d0ba3ad4c0b4cd5be0dfce35e84de33d722192d 100644 --- a/app/views/extranet/posts/posts/_list.html.erb +++ b/app/views/extranet/posts/posts/_list.html.erb @@ -1,6 +1,6 @@ -<div class="row mt-n5"> +<div class="row mt-n5 posts-list"> <% posts.each do |post| %> - <div class="col-lg-4"> + <article class="col-lg-4"> <div class="position-relative mt-5"> <% if post.featured_image.attached? && post.featured_image.representable? %> <%= kamifusen_tag post.featured_image, width: 800, height: 500, class: 'img-fluid' %> @@ -11,6 +11,6 @@ </p> <%= link_to t('extranet.posts.read_post'), posts_post_path(post.slug), class: ' btn btn-outline-primary stretched-link' %> </div> - </div> + </article> <% end %> </div> \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index b33eb378e2f9292532f2d0c40f29124ed0acf236..139e940000b7367c7c1aebf156baea743f74cc9e 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.0].define(version: 2023_03_09_131421) do +ActiveRecord::Schema[7.0].define(version: 2023_03_10_081530) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -105,6 +105,26 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.index ["university_id"], name: "index_communication_extranet_connections_on_university_id" end + create_table "communication_extranet_document_categories", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.uuid "extranet_id", null: false + t.uuid "university_id", null: false + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["extranet_id"], name: "index_communication_extranet_document_categories_on_extranet_id" + t.index ["university_id"], name: "extranet_document_categories_universities" + end + + create_table "communication_extranet_document_kinds", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.uuid "extranet_id", null: false + t.uuid "university_id", null: false + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["extranet_id"], name: "index_communication_extranet_document_kinds_on_extranet_id" + t.index ["university_id"], name: "extranet_document_kinds_universities" + end + create_table "communication_extranet_documents", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "name" t.uuid "university_id", null: false @@ -113,7 +133,11 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do t.datetime "published_at" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.uuid "kind_id" + t.uuid "category_id" + t.index ["category_id"], name: "extranet_document_categories" t.index ["extranet_id"], name: "index_communication_extranet_documents_on_extranet_id" + t.index ["kind_id"], name: "index_extranet_document_kinds" t.index ["university_id"], name: "index_communication_extranet_documents_on_university_id" end @@ -1011,6 +1035,12 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_09_131421) do add_foreign_key "communication_blocks", "universities" add_foreign_key "communication_extranet_connections", "communication_extranets", column: "extranet_id" add_foreign_key "communication_extranet_connections", "universities" + add_foreign_key "communication_extranet_document_categories", "communication_extranets", column: "extranet_id" + add_foreign_key "communication_extranet_document_categories", "universities" + add_foreign_key "communication_extranet_document_kinds", "communication_extranets", column: "extranet_id" + add_foreign_key "communication_extranet_document_kinds", "universities" + add_foreign_key "communication_extranet_documents", "communication_extranet_document_categories", column: "category_id" + add_foreign_key "communication_extranet_documents", "communication_extranet_document_kinds", column: "kind_id" add_foreign_key "communication_extranet_documents", "communication_extranets", column: "extranet_id" add_foreign_key "communication_extranet_documents", "universities" add_foreign_key "communication_extranet_post_categories", "communication_extranets", column: "extranet_id" diff --git a/test/fixtures/communication/extranet/documents.yml b/test/fixtures/communication/extranet/documents.yml index be1d0d6ab57326b590356596a4609a335ddd6e69..fb4fa23733ee89bef580ed42a2418d63d9d1b4cd 100644 --- a/test/fixtures/communication/extranet/documents.yml +++ b/test/fixtures/communication/extranet/documents.yml @@ -8,18 +8,24 @@ # published_at :datetime # created_at :datetime not null # updated_at :datetime not null +# category_id :uuid indexed # extranet_id :uuid not null, indexed +# kind_id :uuid indexed # university_id :uuid not null, indexed # # Indexes # +# extranet_document_categories (category_id) # index_communication_extranet_documents_on_extranet_id (extranet_id) # index_communication_extranet_documents_on_university_id (university_id) +# index_extranet_document_kinds (kind_id) # # Foreign Keys # # fk_rails_1272fd263c (extranet_id => communication_extranets.id) +# fk_rails_51f7db2f66 (kind_id => communication_extranet_document_kinds.id) # fk_rails_af877a8c0c (university_id => universities.id) +# fk_rails_eb351dc444 (category_id => communication_extranet_document_categories.id) # one: diff --git a/test/fixtures/communication/extranet/post/categories.yml b/test/fixtures/communication/extranet/post/categories.yml index 57dfca8c4e88ad04a255f565215fc80d38df9686..b2e20214f6f93f7c730f185ab1748b72468bc882 100644 --- a/test/fixtures/communication/extranet/post/categories.yml +++ b/test/fixtures/communication/extranet/post/categories.yml @@ -20,7 +20,6 @@ # fk_rails_aad7b8db63 (university_id => universities.id) # fk_rails_e53c2a25fc (extranet_id => communication_extranets.id) # -# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html one: name: MyString