From 5956637cdf07d0e5df1948dcfc946d7b10ed991f Mon Sep 17 00:00:00 2001 From: Tykayn Date: Fri, 10 Mar 2023 13:20:25 +0100 Subject: [PATCH] feat: add links for osm coming events --- helpers/agendadulibre_coming_osm.mjs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/helpers/agendadulibre_coming_osm.mjs b/helpers/agendadulibre_coming_osm.mjs index c26972c..6c4c749 100644 --- a/helpers/agendadulibre_coming_osm.mjs +++ b/helpers/agendadulibre_coming_osm.mjs @@ -3,7 +3,10 @@ import sendPostMastodon from "./libs/utils.mjs"; import * as coming_events_json from './../assets/documents/agendadulibre_openstreetmap.json' assert { type: "json" }; import {getArticlesFromDaysInJson} from './libs/rss_management.mjs' +import moment from "moment"; +let event_date_format = 'dddd DD/MM HH:mm' +let event_date_format_end = 'HH:mm' const days_filter = 7; function makeTitleContentFromAgendaDulibre(articles) { @@ -13,11 +16,13 @@ function makeTitleContentFromAgendaDulibre(articles) { if(! articles.length ){ return '- Aucun évènement prévu. T_T' } - articles.forEach(item=>{ - content += `\n* ${item.city} - ${item.title}` ; - let start = new Date(item.start_time) - let end = new Date(item.end_time) - content += `\n <${start} -- ${end}>` ; + articles.forEach(event=>{ + let eventUrl = event.url.replace('.json', '') + let start = moment(new Date(event.start_time)).utcOffset(0).format(event_date_format) + let end = moment(new Date(event.end_time)).utcOffset(0).format(event_date_format_end) + let tags = '#'+event.tags.split(' ').join(' #') + content += `\n* [${event.city} : ${start} - ${end} | ${event.title}](${eventUrl})` ; + content += `\n ${tags}` ; }) return content; }