Преглед на файлове

ajout des événeemnt par ICS

garthh преди 1 месец
родител
ревизия
0536f612b0
променени са 2 файла, в които са добавени 9 реда и са изтрити 12 реда
  1. 1 1
      templates/main/booking.html.twig
  2. 8 11
      templates/main/event.ics.twig

+ 1 - 1
templates/main/booking.html.twig

@@ -47,7 +47,7 @@
 <div class="column">
   <div class="hero is-small">
     <div class="hero-body">
-      <h2 class="title is-2">{{ event.name }}{% if event.moreLink %}<a href="{{ event.moreLink }}" target="_blank" title="En savoir plus sur le site de l'événement.">&nbsp;<small class="icon is-6"><twig:ux:icon name="bi:link-45deg"/></small></a>{% endif %}</h2> 
+      <h2 class="title is-2">{{ event.name }}{% if event.moreLink %}<a href="{{ event.moreLink }}" target="_blank" title="En savoir plus sur le site de l'événement.">&nbsp;<small class="icon is-6"><twig:ux:icon name="bi:link-45deg"/></small></a>{% endif %}<a href="{{ app_url|replace({'https://':'webcal://'}) }}{{ path('app_main_ics', {id: event.id}) }}" target="_blank" title="Ajouter à mon agenda">&nbsp;<small class="icon is-6"><twig:ux:icon name="bi:calendar-plus"/></small></a></h2> 
       <p class="subtitle is-4">du {{ event.startOn|date('d/m/y à H:i', app_timezone) }} au {{ event.endOn|date('d/m/y à H:i', app_timezone)}}</p>
       <article>
         <p>{{ event.description }}</p>

+ 8 - 11
templates/main/event.ics.twig

@@ -1,24 +1,21 @@
-{# génère un fichier vcalendar à partir d'un événement #}
 BEGIN:VCALENDAR
 VERSION:2.0
 PRODID:-//hacksw/handcal//NONSGML v1.0//EN
 
 {% for period in event.getPeriods %}
 BEGIN:VEVENT
+UID:{{ period.getStartOn|date('Ymd\\THis') }}Z-{{ event.id}}@orgasso.net
 DTSTART:{{ period.getStartOn|date('Ymd\\THis') }}Z
 DTEND:{{ period.getEndOn|date('Ymd\\THis') }}Z
 SUMMARY:{{ event.name }}
-DESCRIPTION:{{ event.description }}
-URL:{{ url('app_main_booking', {id: event.id}) }}
-END:VEVENT
-{% endfor %}
-
+{% set description_lines = [] %}
 {% for party in event.getParties %}
-BEGIN:VEVENT
-DTSTART:{{ party.getStartOn|date('Ymd\\THis') }}Z
-DTEND:{{ party.getEndOn|date('Ymd\\THis') }}Z
-SUMMARY:{{ party.getGame.getName }}
-DESCRIPTION:{{ party.getGame.getDescription }}
+    {% set line = party.getGame.getName ~ '\nHoraire : le ' ~ party.getStartOn|date('d/m') ~ ' de ' ~ party.getStartOn|date('H:i') ~ ' à ' ~ party.getEndOn|date('H:i') ~ '\n' ~ party.getGame.getDescription %}
+    {% set description_lines = description_lines|merge([line]) %}
+{% endfor %}
+{% set description = (event.description ~ '\n' ~ description_lines|join('\n'))|replace({',':'\,',';':'\;','\\':'\\\\'}) %}
+DESCRIPTION:{{ description }}
+URL:{{ url('app_main_booking', {id: event.id}) }}
 END:VEVENT
 {% endfor %}