Aggiunta pagina Eventi
This commit is contained in:
parent
3921279d3b
commit
c1a30f2769
@ -91,12 +91,16 @@ email = true
|
||||
weight = 2
|
||||
url = "partecipa/"
|
||||
[[menu.main]]
|
||||
name = "👨💻 Progetti"
|
||||
name = "🗓️ Eventi"
|
||||
weight = 3
|
||||
url = "eventi/"
|
||||
[[menu.main]]
|
||||
name = "👨💻 Progetti"
|
||||
weight = 4
|
||||
url = "progetti/"
|
||||
[[menu.main]]
|
||||
name = "📢 News"
|
||||
weight = 4
|
||||
weight = 5
|
||||
url = "news/"
|
||||
|
||||
|
||||
|
9
content/eventi/index.md
Normal file
9
content/eventi/index.md
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
title: Eventi
|
||||
date: 2023-04-04T21:36:00+02:00
|
||||
type: eventi
|
||||
ics_json: https://este.linux.it/events.ics.php
|
||||
ics_ical: https://share.mailbox.org/ajax/share/0baf84f90c46e84ebe9c8c1c46e84ace8abc1c353555ae64/1/2/Y2FsOi8vMC80Mw
|
||||
include_donations: true
|
||||
---
|
||||
|
75
layouts/eventi/single.html
Normal file
75
layouts/eventi/single.html
Normal file
@ -0,0 +1,75 @@
|
||||
{{ define "title" }}
|
||||
{{ .Title }} · {{ .Site.Title }}
|
||||
{{ end }}
|
||||
{{ define "content" }}
|
||||
<section class="container post">
|
||||
<article>
|
||||
<header>
|
||||
<div class="post-title">
|
||||
<h1 class="title">
|
||||
<a class="title-link" href="{{ .Permalink | safeURL }}">
|
||||
{{ .Title }}
|
||||
</a>
|
||||
</h1>
|
||||
</div>
|
||||
<div class="post-meta">
|
||||
<div id="calendar"></div>
|
||||
|
||||
<hr>
|
||||
<label for="link" style="width:10%;">Link pubblico:</label>
|
||||
<input type="text" id="link" style="width:60%;" value="{{ .Params.ics_ical }}" readonly>
|
||||
<button onclick="copyToClipboard()" style="width:20%;">Copia link</button>
|
||||
<hr>
|
||||
</div>
|
||||
</header>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<script src='{{.Site.BaseURL}}/js/fullcalendar.min.js'></script>
|
||||
<script src='{{.Site.BaseURL}}/js/it.global.min.js'></script>
|
||||
<script>
|
||||
async function start_calendar() {
|
||||
await fetch('{{ .Params.ics_json }}')
|
||||
.then( function(data){
|
||||
console.log(data.text());
|
||||
var calendarEl = document.getElementById('calendar');
|
||||
var calendar = new FullCalendar.Calendar(calendarEl, {
|
||||
initialView: 'timeGridWeek',
|
||||
locale: 'it',
|
||||
nowIndicator: true,
|
||||
stickyHeaderDates: true,
|
||||
expandRows: true,
|
||||
slotMinTime: '07:00:00',
|
||||
slotMaxTime: '23:59:00',
|
||||
headerToolbar: {
|
||||
left: "prev,next today",
|
||||
center: "title",
|
||||
right: "dayGridMonth,timeGridWeek,timeGridDay,listWeek"
|
||||
},
|
||||
eventDisplay: "block",
|
||||
events: data,
|
||||
allDaySlot: false
|
||||
});
|
||||
|
||||
calendar.render();
|
||||
});
|
||||
}
|
||||
|
||||
function copyToClipboard() {
|
||||
var link = document.getElementById("link");
|
||||
link.select();
|
||||
document.execCommand("copy");
|
||||
alert("Link copiato!");
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
start_calendar();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.fc-event-main{
|
||||
line-height: 1.2em;
|
||||
}
|
||||
</style>
|
||||
{{ end }}
|
56
static/events.ics.php
Normal file
56
static/events.ics.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$url = 'https://share.mailbox.org/ajax/share/0baf84f90c46e84ebe9c8c1c46e84ace8abc1c353555ae64/1/2/Y2FsOi8vMC80Mw';
|
||||
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_RETURNTRANSFER => 1,
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_HEADER => 0
|
||||
));
|
||||
$result = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
|
||||
echo icsToJson($result);
|
||||
|
||||
function icsToJson($icsString)
|
||||
{
|
||||
$icsEvents = explode("BEGIN:VEVENT", $icsString);
|
||||
$icsEvents = array_slice($icsEvents, 1);
|
||||
|
||||
$jsonEvents = array();
|
||||
|
||||
foreach ($icsEvents as $event) {
|
||||
$startDate = "";
|
||||
$endDate = "";
|
||||
$summary = "";
|
||||
$description = "";
|
||||
|
||||
$eventLines = explode("\n", $event);
|
||||
|
||||
foreach ($eventLines as $line) {
|
||||
if (strpos($line, "DTSTART") !== false) {
|
||||
$startDate = trim(explode(":", $line)[1]);
|
||||
} elseif (strpos($line, "DTEND") !== false) {
|
||||
$endDate = trim(explode(":", $line)[1]);
|
||||
} elseif (strpos($line, "SUMMARY") !== false) {
|
||||
$summary = trim(str_replace("SUMMARY:", "", $line));
|
||||
} elseif (strpos($line, "DESCRIPTION") !== false) {
|
||||
$description = trim(str_replace("DESCRIPTION:", "", $line));
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($startDate) && !empty($summary)) {
|
||||
$jsonEvents[] = array(
|
||||
"title" => $summary,
|
||||
"start" => date("Y-m-d H:i:s", strtotime($startDate)),
|
||||
"end" => date("Y-m-d H:i:s", strtotime($endDate)),
|
||||
"description" => $description
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($jsonEvents);
|
||||
}
|
6
static/js/fullcalendar.min.js
vendored
Normal file
6
static/js/fullcalendar.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
6
static/js/it.global.min.js
vendored
Normal file
6
static/js/it.global.min.js
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/*!
|
||||
FullCalendar Core v6.1.5
|
||||
Docs & License: https://fullcalendar.io
|
||||
(c) 2023 Adam Shaw
|
||||
*/
|
||||
!function(e){"use strict";var t={code:"it",week:{dow:1,doy:4},buttonText:{prev:"Prec",next:"Succ",today:"Oggi",year:"Anno",month:"Mese",week:"Settimana",day:"Giorno",list:"Agenda"},weekText:"Sm",allDayText:"Tutto il giorno",moreLinkText:e=>"+altri "+e,noEventsText:"Non ci sono eventi da visualizzare"};FullCalendar.globalLocales.push(t)}();
|
Reference in New Issue
Block a user