From cff441e9a69bc6345474e180ea80bc4e2c9c1b00 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Mon, 11 Sep 2023 21:37:11 +0200
Subject: [PATCH] programs

---
 .../organization_chart/_static.html.erb       |  2 +-
 .../blocks/templates/pages/_static.html.erb   |  1 +
 .../templates/partners/_static.html.erb       |  2 +-
 .../blocks/templates/posts/_static.html.erb   |  4 ++-
 .../templates/programs/_static.html.erb       | 27 +++++++++++++++++++
 5 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/app/views/admin/communication/blocks/templates/organization_chart/_static.html.erb b/app/views/admin/communication/blocks/templates/organization_chart/_static.html.erb
index a09225842..fd052b23a 100644
--- a/app/views/admin/communication/blocks/templates/organization_chart/_static.html.erb
+++ b/app/views/admin/communication/blocks/templates/organization_chart/_static.html.erb
@@ -19,6 +19,6 @@
             <%= prepare_text_for_static element.person.summary, 6 %>
 <% end %>
           kind: "osuny"
-          path: "<%= element.person.slug %>"
+          slug: "<%= element.person.slug %>"
           url: "<%= element.person.current_permalink_in_website(@website)&.path %>"
 <% end %>
diff --git a/app/views/admin/communication/blocks/templates/pages/_static.html.erb b/app/views/admin/communication/blocks/templates/pages/_static.html.erb
index 0a1dc30e1..1c936ee0a 100644
--- a/app/views/admin/communication/blocks/templates/pages/_static.html.erb
+++ b/app/views/admin/communication/blocks/templates/pages/_static.html.erb
@@ -15,6 +15,7 @@
             <%= prepare_text_for_static element.title %>
           summary: >-
             <%= prepare_text_for_static element.summary, 6 %>
+          slug: "<%= element.slug %>"
           path: "<%= element.path %>"
           url: "<%= element.current_permalink_in_website(@website)&.path %>"
           bodyclass: >-
diff --git a/app/views/admin/communication/blocks/templates/partners/_static.html.erb b/app/views/admin/communication/blocks/templates/partners/_static.html.erb
index 0c153b89c..61dff7dc4 100644
--- a/app/views/admin/communication/blocks/templates/partners/_static.html.erb
+++ b/app/views/admin/communication/blocks/templates/partners/_static.html.erb
@@ -18,7 +18,7 @@
             <%= prepare_text_for_static element.name %>
 <% if element.organization %>
           kind: "osuny"
-          path: "<%= element.organization.slug %>"
+          slug: "<%= element.organization.slug %>"
           url: "<%= element.organization.current_permalink_in_website(@website)&.path %>"
           logo:
 <% if element.organization.logo.attached? %>
diff --git a/app/views/admin/communication/blocks/templates/posts/_static.html.erb b/app/views/admin/communication/blocks/templates/posts/_static.html.erb
index d8a9f1113..0438db07a 100644
--- a/app/views/admin/communication/blocks/templates/posts/_static.html.erb
+++ b/app/views/admin/communication/blocks/templates/posts/_static.html.erb
@@ -14,6 +14,7 @@
             <%= prepare_text_for_static element.title %>
           summary: >-
             <%= prepare_text_for_static element.summary, 6 %>
+          slug: "<%= element.slug %>"
           path: "<%= element.path %>"
           url: "<%= element.current_permalink_in_website(@website)&.path %>"
 <% if element.best_featured_image.attached? %>
@@ -28,6 +29,7 @@
 <% element.categories.each do |category| %>
             - title: >-
                 <%= prepare_text_for_static category.name, 8 %>
+              slug: "<%= category.slug %>"
               path: "<%= category.path %>"
               url: "<%= category.current_permalink_in_website(@website)&.path %>"
 <% end %>
@@ -35,7 +37,7 @@
           author:
             name: >-  
               <%= prepare_text_for_static element.author.name, 7 %>
-            path: "<%= element.author.slug %>"
+            slug: "<%= element.author.slug %>"
             url: "<%= element.author.current_permalink_in_website(@website)&.path %>"
 <% end %>
 <% end %>
diff --git a/app/views/admin/communication/blocks/templates/programs/_static.html.erb b/app/views/admin/communication/blocks/templates/programs/_static.html.erb
index 4f7435b2b..cfbdd424f 100644
--- a/app/views/admin/communication/blocks/templates/programs/_static.html.erb
+++ b/app/views/admin/communication/blocks/templates/programs/_static.html.erb
@@ -2,4 +2,31 @@
 <% block.template.elements.each do |element| %>
 <% next unless element.program %>
         - path: "<%= element.program.path %>"
+<% end %>
+      elements:
+<% block.template.elements.each do |element| %>
+<% program = element.program %>
+<% next unless program %>
+        - title: >-
+            <%= prepare_text_for_static element.program.name %>
+          summary: >-
+            <%= prepare_text_for_static element.program.summary, 6 %>
+          slug: "<%= program.slug %>"
+          path: "<%= program.path %>"
+          url: "<%= program.current_permalink_in_website(@website)&.path %>"
+<% if program.best_featured_image.attached? %>
+          image:
+            id: "<%= program.best_featured_image.blob.id %>"
+            alt: >-
+              <%= prepare_text_for_static program.best_featured_image_alt, 7 %>
+            credit: >-
+              <%= prepare_html_for_static program.best_featured_image_credit, @website.university %>
+<% end %>
+<% diploma = program.diploma %>
+<% if diploma.present? %>
+          diploma:
+            - title: >-
+                <%= prepare_text_for_static diploma.name %>
+              slug: "<%= diploma.slug %>"
+              url: "<%= diploma.current_permalink_in_website(@website)&.path %>"<% end %>
 <% end %>
-- 
GitLab