Skip to content
Snippets Groups Projects
Unverified Commit 47f8654a authored by Arnaud Levy's avatar Arnaud Levy Committed by GitHub
Browse files

Informations sur les nouveautés d'Osuny (#2417)

parent 4f39c8fb
No related branches found
No related tags found
No related merge requests found
<%= osuny_panel t('admin.chronicles.title') do %>
<div id="chronicles-feed" class="row g-4 mb-3" style="max-height:60vh; overflow-y: scroll"></div>
<% end %>
<script nonce="<%= request.content_security_policy_nonce %>">
const RSS_URL = "https://chroniques.osuny.org/faits/index.xml";
const element = document.getElementById("chronicles-feed");
fetch(RSS_URL)
.then(response => response.text())
.then(str => new window.DOMParser().parseFromString(str, "text/xml"))
.then(data => {
const items = data.querySelectorAll("item");
let html = "";
let index = 0;
items.forEach(item => {
let title = item.querySelector("title");
let link = item.querySelector("link");
if (title == '' || link == '' || index >= 12) {
return;
}
let pubDate = item.querySelector("pubDate");
let date = new Date(pubDate.textContent);
let description = item.querySelector("description");
html += `
<div class="col-lg-6 col-xl-4 col-xxl-3">
<div class="card h-100">
<div class="card-body">
<h3 class="card-title">${title.textContent}</h3>
<p class="small">${description.textContent}</p>
</div>
<p class="card-footer mb-1 small text-end">
${date.getMonth()}/${date.getFullYear()}
<a href="${link.textContent}" target="_blank" rel="noopener">
<%= t('admin.chronicles.read_more') %>
</a>
</p>
</div>
</div>
`;
index += 1;
});
element.insertAdjacentHTML("beforeend", html);
});
</script>
\ No newline at end of file
......@@ -9,6 +9,7 @@
<% end %>
<%= render 'admin/application/favorites/show' %>
<%= render 'admin/dashboard/chronicles' %>
<% if current_university.is_really_a_university? %>
<%= render 'admin/dashboard/really_a_university' %>
......
......@@ -120,6 +120,9 @@ en:
admin:
advanced_settings: Advanced settings
attachment_not_available: Attachment not available
chronicles:
title: Chronicles
read_more: Learn more
dashboard: Dashboard
directory: Directory
duplicate: Duplicate
......
......@@ -120,6 +120,9 @@ fr:
admin:
advanced_settings: Réglages avancés
attachment_not_available: Impossible d'accéder à l'élément
chronicles:
title: Chroniques
read_more: En savoir plus
dashboard: Tableau de bord
directory: Annuaire
duplicate: Dupliquer
......
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